pdx97 commited on
Commit
bcdfde6
·
verified ·
1 Parent(s): b42ee1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -11
app.py CHANGED
@@ -135,9 +135,16 @@ import numpy as np
135
  from sklearn.feature_extraction.text import TfidfVectorizer
136
  from sklearn.metrics.pairwise import cosine_similarity
137
  import gradio as gr
138
- from smolagents import CodeAgent, HfApiModel, tool
139
  import nltk
140
 
 
 
 
 
 
 
 
141
  nltk.download("stopwords")
142
  from nltk.corpus import stopwords
143
 
@@ -226,6 +233,10 @@ model = HfApiModel(
226
  custom_role_conversions=None,
227
  )
228
 
 
 
 
 
229
  # Load prompt templates
230
  with open("prompts.yaml", 'r') as stream:
231
  prompt_templates = yaml.safe_load(stream)
@@ -303,17 +314,20 @@ def search_papers(user_input):
303
  print("DEBUG: No results found.")
304
  return "No results found. Try different keywords."
305
 
 
 
 
306
 
307
- # Create Gradio UI
308
- with gr.Blocks() as demo:
309
- gr.Markdown("# ScholarAgent")
310
- keyword_input = gr.Textbox(label="Enter keywords (comma-separated)", placeholder="e.g., deep learning, reinforcement learning")
311
- output_display = gr.Markdown()
312
- search_button = gr.Button("Search")
313
 
314
- search_button.click(search_papers, inputs=[keyword_input], outputs=[output_display])
315
 
316
- print("DEBUG: Gradio UI is running. Waiting for user input...")
317
 
318
- # Launch Gradio App
319
- demo.launch()
 
135
  from sklearn.feature_extraction.text import TfidfVectorizer
136
  from sklearn.metrics.pairwise import cosine_similarity
137
  import gradio as gr
138
+ from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
139
  import nltk
140
 
141
+ import datetime
142
+ import requests
143
+ import pytz
144
+ from tools.final_answer import FinalAnswerTool
145
+
146
+ from Gradio_UI import GradioUI
147
+
148
  nltk.download("stopwords")
149
  from nltk.corpus import stopwords
150
 
 
233
  custom_role_conversions=None,
234
  )
235
 
236
+ # Import tool from Hub
237
+ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
238
+
239
+
240
  # Load prompt templates
241
  with open("prompts.yaml", 'r') as stream:
242
  prompt_templates = yaml.safe_load(stream)
 
314
  print("DEBUG: No results found.")
315
  return "No results found. Try different keywords."
316
 
317
+ # Launch Gradio UI with CodeAgent
318
+ GradioUI(agent).launch()
319
+
320
 
321
+ # # Create Gradio UI
322
+ # with gr.Blocks() as demo:
323
+ # gr.Markdown("# ScholarAgent")
324
+ # keyword_input = gr.Textbox(label="Enter keywords (comma-separated)", placeholder="e.g., deep learning, reinforcement learning")
325
+ # output_display = gr.Markdown()
326
+ # search_button = gr.Button("Search")
327
 
328
+ # search_button.click(search_papers, inputs=[keyword_input], outputs=[output_display])
329
 
330
+ # print("DEBUG: Gradio UI is running. Waiting for user input...")
331
 
332
+ # # Launch Gradio App
333
+ # demo.launch()