Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,10 @@
|
|
1 |
-
from smolagents import CodeAgent,
|
2 |
import datetime
|
3 |
import requests
|
4 |
import pytz
|
5 |
import yaml
|
6 |
-
|
7 |
-
|
8 |
from Gradio_UI import GradioUI
|
9 |
-
|
10 |
# Tools
|
11 |
@tool
|
12 |
def my_cutom_tool(arg1:str)-> str: #it's import to specify the return type
|
@@ -34,30 +32,42 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
34 |
|
35 |
|
36 |
final_answer = FinalAnswerTool()
|
|
|
|
|
|
|
37 |
model = HfApiModel(
|
38 |
max_tokens=2096,
|
39 |
temperature=0.5,
|
40 |
-
model_id='
|
41 |
custom_role_conversions=None,
|
42 |
)
|
43 |
|
44 |
-
# Import tool from Hub
|
45 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
46 |
-
|
47 |
with open("prompts.yaml", 'r') as stream:
|
48 |
prompt_templates = yaml.safe_load(stream)
|
49 |
|
50 |
agent = CodeAgent(
|
51 |
model=model,
|
52 |
-
tools=[final_answer, image_generation_tool, get_current_time_in_timezone
|
53 |
max_steps=6,
|
54 |
verbosity_level=1,
|
55 |
grammar=None,
|
56 |
planning_interval=None,
|
57 |
-
name=
|
58 |
description=None,
|
59 |
prompt_templates=prompt_templates
|
60 |
)
|
61 |
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
GradioUI(agent).launch()
|
|
|
1 |
+
from smolagents import CodeAgent,GoogleSearchTool, HfApiModel,load_tool,tool,FinalAnswerTool
|
2 |
import datetime
|
3 |
import requests
|
4 |
import pytz
|
5 |
import yaml
|
6 |
+
import os
|
|
|
7 |
from Gradio_UI import GradioUI
|
|
|
8 |
# Tools
|
9 |
@tool
|
10 |
def my_cutom_tool(arg1:str)-> str: #it's import to specify the return type
|
|
|
32 |
|
33 |
|
34 |
final_answer = FinalAnswerTool()
|
35 |
+
google_search = GoogleSearchTool()
|
36 |
+
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
37 |
+
|
38 |
model = HfApiModel(
|
39 |
max_tokens=2096,
|
40 |
temperature=0.5,
|
41 |
+
model_id='meta-llama/Llama-3.2-3B-Instruct',
|
42 |
custom_role_conversions=None,
|
43 |
)
|
44 |
|
|
|
|
|
|
|
45 |
with open("prompts.yaml", 'r') as stream:
|
46 |
prompt_templates = yaml.safe_load(stream)
|
47 |
|
48 |
agent = CodeAgent(
|
49 |
model=model,
|
50 |
+
tools=[final_answer, google_search, image_generation_tool, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
51 |
max_steps=6,
|
52 |
verbosity_level=1,
|
53 |
grammar=None,
|
54 |
planning_interval=None,
|
55 |
+
name="Alpi",
|
56 |
description=None,
|
57 |
prompt_templates=prompt_templates
|
58 |
)
|
59 |
|
60 |
|
61 |
+
"""with gr.Blocks() as demo:
|
62 |
+
chatbot = gr.Chatbot(label="Conversation")
|
63 |
+
message = gr.Textbox(label="Input", placeholder="Type your message here...")
|
64 |
+
|
65 |
+
def respond(user_message, history):
|
66 |
+
response = agent(user_message)
|
67 |
+
history.append((user_message, response))
|
68 |
+
return "", history
|
69 |
+
|
70 |
+
message.submit(respond, inputs=[message, chatbot], outputs=[message, chatbot])
|
71 |
+
|
72 |
+
demo.launch()"""
|
73 |
GradioUI(agent).launch()
|