Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,15 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
@tool
|
| 10 |
def my_custom_tool(arg1:str, arg2:int)-> str: # it's important to specify the return type
|
|
@@ -31,38 +39,39 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 31 |
except Exception as e:
|
| 32 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 33 |
|
| 34 |
-
agent = CodeAgent(tools=[getDeviceInfo()], model=HfApiModel())
|
| 35 |
|
| 36 |
-
agent.run("https://www.google.com")
|
| 37 |
|
|
|
|
| 38 |
final_answer = FinalAnswerTool()
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 42 |
-
|
| 43 |
model = HfApiModel(
|
| 44 |
-
max_tokens=2096,
|
| 45 |
-
temperature=0.5,
|
| 46 |
-
model_id='Qwen/Qwen2.5-Coder-32B-Instruct'
|
| 47 |
-
custom_role_conversions=None,
|
| 48 |
)
|
| 49 |
|
| 50 |
-
|
| 51 |
with open("prompts.yaml", 'r') as stream:
|
| 52 |
prompt_templates = yaml.safe_load(stream)
|
| 53 |
-
|
|
|
|
| 54 |
agent = CodeAgent(
|
| 55 |
model=model,
|
| 56 |
-
tools=[final_answer
|
| 57 |
max_steps=6,
|
| 58 |
verbosity_level=1,
|
| 59 |
grammar=None,
|
| 60 |
planning_interval=None,
|
| 61 |
-
name=
|
| 62 |
-
description=
|
| 63 |
prompt_templates=prompt_templates
|
| 64 |
)
|
| 65 |
|
| 66 |
-
|
|
|
|
| 67 |
GradioUI(agent).launch()
|
| 68 |
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from typing import Any, Optional
|
| 8 |
+
from smolagents.tools import Tool
|
| 9 |
+
import requests
|
| 10 |
+
import markdownify
|
| 11 |
+
import smolagents
|
| 12 |
+
import playwright.sync_api as playwright
|
| 13 |
+
import re
|
| 14 |
+
from tools.final_answer import FinalAnswerTool
|
| 15 |
+
from tools.getDeviceInfo import getDeviceInfo
|
| 16 |
|
| 17 |
@tool
|
| 18 |
def my_custom_tool(arg1:str, arg2:int)-> str: # it's important to specify the return type
|
|
|
|
| 39 |
except Exception as e:
|
| 40 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 41 |
|
| 42 |
+
#agent = CodeAgent(tools=[getDeviceInfo()], model=HfApiModel())
|
| 43 |
|
| 44 |
+
#agent.run("https://www.google.com")
|
| 45 |
|
| 46 |
+
# Initialize the final answer tool
|
| 47 |
final_answer = FinalAnswerTool()
|
| 48 |
|
| 49 |
+
# Define the Hugging Face model
|
|
|
|
|
|
|
| 50 |
model = HfApiModel(
|
| 51 |
+
max_tokens=2096,
|
| 52 |
+
temperature=0.5,
|
| 53 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
| 54 |
+
custom_role_conversions=None,
|
| 55 |
)
|
| 56 |
|
| 57 |
+
# Load prompt templates
|
| 58 |
with open("prompts.yaml", 'r') as stream:
|
| 59 |
prompt_templates = yaml.safe_load(stream)
|
| 60 |
+
|
| 61 |
+
# Create the agent
|
| 62 |
agent = CodeAgent(
|
| 63 |
model=model,
|
| 64 |
+
tools=[final_answer, getDeviceInfo()],
|
| 65 |
max_steps=6,
|
| 66 |
verbosity_level=1,
|
| 67 |
grammar=None,
|
| 68 |
planning_interval=None,
|
| 69 |
+
name="Webpage Visitor Agent",
|
| 70 |
+
description="An agent that visits a webpage and extracts content & device information.",
|
| 71 |
prompt_templates=prompt_templates
|
| 72 |
)
|
| 73 |
|
| 74 |
+
# Launch the agent
|
| 75 |
+
from Gradio_UI import GradioUI
|
| 76 |
GradioUI(agent).launch()
|
| 77 |
|