Spaces:
Sleeping
Sleeping
File size: 1,414 Bytes
345269d c19d193 6aae614 9b5b26a ed22e6d 1602537 345269d 1602537 345269d 1602537 8c01ffb 1602537 e121372 345269d 13d500a 8c01ffb 1602537 56f1c1f 1602537 56f1c1f 1602537 861422e 345269d 1602537 8c01ffb 8fe992b 1602537 8c01ffb 1602537 861422e 8fe992b 1602537 6c00dd4 |
1 2 3 4 5 6 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 39 40 41 42 43 44 45 46 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
import yaml
from tools.final_answer import FinalAnswerTool
from Gradio_UI import GradioUI
def get_ai_agent_info(tool: DuckDuckGoSearchTool) -> str:
"""Searches the web for information about becoming an AI agent."""
search_query = "becoming an AI agent"
return tool.search(search_query)
def get_ai_agent_roadmap(model: HfApiModel) -> str:
"""Generates a roadmap for becoming an AI agent using AI model."""
prompt = "Provide a detailed roadmap for becoming an AI agent."
return model.generate(prompt)
# Initialize the AI model
model = HfApiModel(
max_tokens=2096,
temperature=0.5,
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
custom_role_conversions=None,
)
# Load tools
final_answer = FinalAnswerTool()
search_tool = DuckDuckGoSearchTool()
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
# Load prompt templates
with open("prompts.yaml", 'r') as stream:
prompt_templates = yaml.safe_load(stream)
# Create AI Agent
agent = CodeAgent(
model=model,
tools=[final_answer, search_tool, image_generation_tool],
max_steps=6,
verbosity_level=1,
name="AI Career Guide",
description="An AI-powered assistant for learning how to become an AI agent.",
prompt_templates=prompt_templates
)
# Launch UI
GradioUI(agent).launch()
|