Thanh Vinh Vo
commited on
Commit
·
f45d60f
1
Parent(s):
f39fa20
update
Browse files
app.py
CHANGED
|
@@ -11,6 +11,7 @@ from smolagents import (
|
|
| 11 |
load_tool,
|
| 12 |
tool,
|
| 13 |
Tool,
|
|
|
|
| 14 |
)
|
| 15 |
|
| 16 |
|
|
@@ -35,8 +36,9 @@ def to_markdown(arg1: str) -> str: # it's important to specify the return type
|
|
| 35 |
class BasicAgent:
|
| 36 |
def __init__(self):
|
| 37 |
print("BasicAgent initialized.")
|
|
|
|
| 38 |
self.agent = CodeAgent(
|
| 39 |
-
tools=[to_markdown],
|
| 40 |
model=InferenceClientModel(),
|
| 41 |
additional_authorized_imports=["requests", "bs4", "html_to_markdown"],
|
| 42 |
max_steps=10,
|
|
@@ -45,9 +47,7 @@ class BasicAgent:
|
|
| 45 |
def __call__(self, question: str) -> str:
|
| 46 |
print(f"Agent received question: {question}")
|
| 47 |
prompt = f"""
|
| 48 |
-
Answer the following question: `{question}`.
|
| 49 |
-
Please follow the following rules:
|
| 50 |
-
1. When there is need to extract information from web page please use `to_markdown` tool to parse HTML content first, and then extract the information you need.
|
| 51 |
"""
|
| 52 |
result = self.agent.run(prompt)
|
| 53 |
print(f"Agent responded with: {result}")
|
|
|
|
| 11 |
load_tool,
|
| 12 |
tool,
|
| 13 |
Tool,
|
| 14 |
+
VisitWebpageTool,
|
| 15 |
)
|
| 16 |
|
| 17 |
|
|
|
|
| 36 |
class BasicAgent:
|
| 37 |
def __init__(self):
|
| 38 |
print("BasicAgent initialized.")
|
| 39 |
+
|
| 40 |
self.agent = CodeAgent(
|
| 41 |
+
tools=[DuckDuckGoSearchTool(), VisitWebpageTool(), to_markdown],
|
| 42 |
model=InferenceClientModel(),
|
| 43 |
additional_authorized_imports=["requests", "bs4", "html_to_markdown"],
|
| 44 |
max_steps=10,
|
|
|
|
| 47 |
def __call__(self, question: str) -> str:
|
| 48 |
print(f"Agent received question: {question}")
|
| 49 |
prompt = f"""
|
| 50 |
+
Answer the following question: `{question}`.
|
|
|
|
|
|
|
| 51 |
"""
|
| 52 |
result = self.agent.run(prompt)
|
| 53 |
print(f"Agent responded with: {result}")
|