Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,37 +1,19 @@
|
|
| 1 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
| 2 |
-
import datetime
|
| 3 |
-
import requests
|
| 4 |
-
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
def get_ai_agent_info(tool: DuckDuckGoSearchTool) -> str:
|
| 11 |
-
"""
|
| 12 |
-
Args:
|
| 13 |
-
tool: The DuckDuckGoSearchTool
|
| 14 |
-
"""
|
| 15 |
search_query = "becoming an AI agent"
|
| 16 |
-
|
| 17 |
-
return result
|
| 18 |
|
| 19 |
-
def get_ai_agent_roadmap() -> str:
|
| 20 |
-
"""
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
"""
|
| 24 |
-
roadmap = """
|
| 25 |
-
Step 1: Learn the basics of programming
|
| 26 |
-
Step 2: Study machine learning and AI
|
| 27 |
-
Step 3: Build a portfolio of projects
|
| 28 |
-
Step 4: Join online communities and forums
|
| 29 |
-
Step 5: Read books and articles on AI
|
| 30 |
-
Step 6: Take online courses and certifications
|
| 31 |
-
"""
|
| 32 |
-
return roadmap
|
| 33 |
|
| 34 |
-
|
| 35 |
model = HfApiModel(
|
| 36 |
max_tokens=2096,
|
| 37 |
temperature=0.5,
|
|
@@ -39,26 +21,25 @@ model = HfApiModel(
|
|
| 39 |
custom_role_conversions=None,
|
| 40 |
)
|
| 41 |
|
| 42 |
-
#
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
# Create instances of the DuckDuckGoSearchTool class
|
| 46 |
search_tool = DuckDuckGoSearchTool()
|
| 47 |
-
|
| 48 |
|
|
|
|
| 49 |
with open("prompts.yaml", 'r') as stream:
|
| 50 |
prompt_templates = yaml.safe_load(stream)
|
| 51 |
|
|
|
|
| 52 |
agent = CodeAgent(
|
| 53 |
model=model,
|
| 54 |
-
tools=[final_answer, search_tool,
|
| 55 |
max_steps=6,
|
| 56 |
verbosity_level=1,
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
name=None,
|
| 60 |
-
description=None,
|
| 61 |
prompt_templates=prompt_templates
|
| 62 |
)
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
| 1 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
|
|
|
|
|
|
|
|
|
| 2 |
import yaml
|
| 3 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 4 |
from Gradio_UI import GradioUI
|
| 5 |
|
| 6 |
def get_ai_agent_info(tool: DuckDuckGoSearchTool) -> str:
|
| 7 |
+
"""Searches the web for information about becoming an AI agent."""
|
|
|
|
|
|
|
|
|
|
| 8 |
search_query = "becoming an AI agent"
|
| 9 |
+
return tool.search(search_query)
|
|
|
|
| 10 |
|
| 11 |
+
def get_ai_agent_roadmap(model: HfApiModel) -> str:
|
| 12 |
+
"""Generates a roadmap for becoming an AI agent using AI model."""
|
| 13 |
+
prompt = "Provide a detailed roadmap for becoming an AI agent."
|
| 14 |
+
return model.generate(prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# Initialize the AI model
|
| 17 |
model = HfApiModel(
|
| 18 |
max_tokens=2096,
|
| 19 |
temperature=0.5,
|
|
|
|
| 21 |
custom_role_conversions=None,
|
| 22 |
)
|
| 23 |
|
| 24 |
+
# Load tools
|
| 25 |
+
final_answer = FinalAnswerTool()
|
|
|
|
|
|
|
| 26 |
search_tool = DuckDuckGoSearchTool()
|
| 27 |
+
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 28 |
|
| 29 |
+
# Load prompt templates
|
| 30 |
with open("prompts.yaml", 'r') as stream:
|
| 31 |
prompt_templates = yaml.safe_load(stream)
|
| 32 |
|
| 33 |
+
# Create AI Agent
|
| 34 |
agent = CodeAgent(
|
| 35 |
model=model,
|
| 36 |
+
tools=[final_answer, search_tool, image_generation_tool],
|
| 37 |
max_steps=6,
|
| 38 |
verbosity_level=1,
|
| 39 |
+
name="AI Career Guide",
|
| 40 |
+
description="An AI-powered assistant for learning how to become an AI agent.",
|
|
|
|
|
|
|
| 41 |
prompt_templates=prompt_templates
|
| 42 |
)
|
| 43 |
|
| 44 |
+
# Launch UI
|
| 45 |
+
GradioUI(agent).launch()
|