Spaces:
Sleeping
Sleeping
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool | |
import datetime | |
import requests | |
import pytz | |
import yaml | |
from tools.final_answer import FinalAnswerTool | |
from typing import Any, Optional | |
from smolagents.tools import Tool | |
import markdownify | |
import smolagents | |
import re | |
from tools.visit_webpage import VisitWebpageTool | |
# Initialize the final answer tool | |
final_answer = FinalAnswerTool() | |
# Define the Hugging Face model | |
model = HfApiModel( | |
max_tokens=2096, | |
temperature=0.5, | |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct', | |
custom_role_conversions=None, | |
) | |
# Load prompt templates | |
with open("prompts.yaml", 'r') as stream: | |
prompt_templates = yaml.safe_load(stream) | |
# Create the agent | |
agent = CodeAgent( | |
model=model, | |
tools=[final_answer, VisitWebpageTool()], | |
max_steps=6, | |
verbosity_level=1, | |
grammar=None, | |
planning_interval=None, | |
name="Webpage Visitor Agent", | |
description="An agent that visits a webpage and extracts content & device information.", | |
prompt_templates=prompt_templates | |
) | |
# Launch the agent | |
from Gradio_UI import GradioUI | |
GradioUI(agent).launch() | |