Batnini commited on
Commit
9069208
·
verified ·
1 Parent(s): b56644f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -9
app.py CHANGED
@@ -6,7 +6,7 @@ from tools.tool_agent import ToolCallingAgent
6
  # Initialize models
7
  text_gen = ArabicTextGenerator()
8
  quran = QuranSearchEngine()
9
- tool_agent = ToolCallingAgent() # CPU-only
10
 
11
  TOOLS = [
12
  {
@@ -33,19 +33,43 @@ def format_output(result):
33
  return str(result)
34
 
35
  with gr.Blocks(title="الأدوات العربية") as app:
36
- # Tab 1: Existing Arabic Generator
37
  with gr.Tab("🖊️ مولد النصوص"):
38
- # ... [Keep your existing Arabic generator UI exactly as is] ...
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- # Tab 2: Existing Quran Search
41
  with gr.Tab("📖 القرآن الكريم"):
42
- # ... [Keep your existing Quran search UI exactly as is] ...
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- # Tab 3: New Tool Agent (CPU-optimized)
45
  with gr.Tab("🛠️ مساعد ذكي"):
46
- tool_input = gr.Textbox(label="اكتب طلبك هنا")
47
- tool_output = gr.Textbox(label="النتيجة", lines=10)
48
- run_btn = gr.Button("تشغيل")
 
 
49
 
50
  def process_tool(input_text):
51
  try:
 
6
  # Initialize models
7
  text_gen = ArabicTextGenerator()
8
  quran = QuranSearchEngine()
9
+ tool_agent = ToolCallingAgent()
10
 
11
  TOOLS = [
12
  {
 
33
  return str(result)
34
 
35
  with gr.Blocks(title="الأدوات العربية") as app:
36
+ # Tab 1: Arabic Generator
37
  with gr.Tab("🖊️ مولد النصوص"):
38
+ with gr.Row():
39
+ with gr.Column():
40
+ arabic_input = gr.Textbox(label="النص الأولي")
41
+ length_slider = gr.Slider(50, 300, value=100, label="طول النص")
42
+ generate_btn = gr.Button("توليد")
43
+ arabic_output = gr.Textbox(label="النص المولد", lines=10)
44
+
45
+ generate_btn.click(
46
+ text_gen.generate,
47
+ inputs=[arabic_input, length_slider],
48
+ outputs=arabic_output
49
+ )
50
 
51
+ # Tab 2: Quran Search
52
  with gr.Tab("📖 القرآن الكريم"):
53
+ with gr.Row():
54
+ with gr.Column():
55
+ search_input = gr.Textbox(label="موضوع البحث")
56
+ results_slider = gr.Slider(1, 5, value=3, label="عدد النتائج")
57
+ search_btn = gr.Button("ابحث")
58
+ quran_output = gr.Textbox(label="النتائج", lines=10)
59
+
60
+ search_btn.click(
61
+ lambda q, k: format_output(quran.search(q, k)),
62
+ inputs=[search_input, results_slider],
63
+ outputs=quran_output
64
+ )
65
 
66
+ # Tab 3: Tool Agent
67
  with gr.Tab("🛠️ مساعد ذكي"):
68
+ with gr.Row():
69
+ with gr.Column():
70
+ tool_input = gr.Textbox(label="اكتب طلبك هنا")
71
+ run_btn = gr.Button("تشغيل")
72
+ tool_output = gr.Textbox(label="النتيجة", lines=10)
73
 
74
  def process_tool(input_text):
75
  try: