Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,14 +9,33 @@ from Gradio_UI import GradioUI
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
-
def
|
13 |
-
|
14 |
-
""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
Args:
|
16 |
-
|
17 |
-
arg2: the second argument
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -55,12 +74,12 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
62 |
planning_interval=None,
|
63 |
-
name=
|
64 |
description=None,
|
65 |
prompt_templates=prompt_templates
|
66 |
)
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
def search_arxiv(query: str, max_results: int = 5) -> str:
|
13 |
+
|
14 |
+
url = f"http://export.arxiv.org/api/query?search_query={query}&max_results={max_results}"
|
15 |
+
response = requests.get(url)
|
16 |
+
|
17 |
+
if response.status_code == 200:
|
18 |
+
papers = []
|
19 |
+
for entry in response.text.split("<entry>")[1:max_results+1]:
|
20 |
+
title = entry.split("<title>")[1].split("</title>")[0]
|
21 |
+
link = entry.split("<id>")[1].split("</id>")[0]
|
22 |
+
summary = entry.split("<summary>")[1].split("</summary>")[0]
|
23 |
+
papers.append(f"Title: {title}\nSummary: {summary}\nLink: {link}\n")
|
24 |
+
return "\n\n".joins(papers)
|
25 |
+
return "No papers found"
|
26 |
+
|
27 |
+
@tool
|
28 |
+
def summarize_text(text: str) -> str:
|
29 |
+
"""Summarizes long academic papers or articles.
|
30 |
Args:
|
31 |
+
text: The text to summarize.
|
|
|
32 |
"""
|
33 |
+
model = HfApiModel(
|
34 |
+
max_tokens=512,
|
35 |
+
temperature=0.5,
|
36 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
37 |
+
)
|
38 |
+
return model.generate(f"Summarize this research paper: {text}")
|
39 |
|
40 |
@tool
|
41 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
74 |
|
75 |
agent = CodeAgent(
|
76 |
model=model,
|
77 |
+
tools=[final_answer, search_arxiv, summarize_text], ## add your tools here (don't remove final answer)
|
78 |
max_steps=6,
|
79 |
verbosity_level=1,
|
80 |
grammar=None,
|
81 |
planning_interval=None,
|
82 |
+
name="Research Assistant",
|
83 |
description=None,
|
84 |
prompt_templates=prompt_templates
|
85 |
)
|