Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,43 +1,37 @@
|
|
| 1 |
-
import yaml
|
| 2 |
-
import os
|
| 3 |
-
from smolagents import GradioUI, CodeAgent, LiteLLMModel
|
| 4 |
-
|
| 5 |
-
# Get current directory path
|
| 6 |
-
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
executor_kwargs={},
|
| 39 |
-
max_print_outputs_length=None,
|
| 40 |
-
prompt_templates=prompt_templates
|
| 41 |
-
)
|
| 42 |
-
if __name__ == "__main__":
|
| 43 |
-
GradioUI(agent).launch()
|
|
|
|
| 1 |
+
import yaml
|
| 2 |
+
import os
|
| 3 |
+
from smolagents import GradioUI, CodeAgent, LiteLLMModel, DuckDuckGoSearchTool, FinalAnswerTool
|
| 4 |
+
|
| 5 |
+
# Get current directory path
|
| 6 |
+
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 7 |
+
|
| 8 |
+
model = LiteLLMModel(
|
| 9 |
+
num_ctx=8192,
|
| 10 |
+
model_id='ollama_chat/qwen3:4b',
|
| 11 |
+
api_base='http://127.0.0.1:11434',
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
web_search = DuckDuckGoSearchTool()
|
| 15 |
+
final_answer = FinalAnswerTool()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
|
| 19 |
+
prompt_templates = yaml.safe_load(stream)
|
| 20 |
+
|
| 21 |
+
agent = CodeAgent(
|
| 22 |
+
model=model,
|
| 23 |
+
tools=[web_search],
|
| 24 |
+
managed_agents=[],
|
| 25 |
+
max_steps=20,
|
| 26 |
+
verbosity_level=1,
|
| 27 |
+
grammar=None,
|
| 28 |
+
planning_interval=None,
|
| 29 |
+
name=None,
|
| 30 |
+
description=None,
|
| 31 |
+
executor_type='local',
|
| 32 |
+
executor_kwargs={},
|
| 33 |
+
max_print_outputs_length=None,
|
| 34 |
+
prompt_templates=prompt_templates
|
| 35 |
+
)
|
| 36 |
+
if __name__ == "__main__":
|
| 37 |
+
GradioUI(agent).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|