24 lines
644 B
Python
24 lines
644 B
Python
# DeepAgents from scratch example
|
|
from deepagents import Agent, Tool
|
|
|
|
class SearchTool(Tool):
|
|
def __init__(self):
|
|
super().__init__(name="search", description="Search the web")
|
|
|
|
def run(self, query: str) -> str:
|
|
# placeholder implementation
|
|
return f"Results for {query}"
|
|
|
|
class MyAgent(Agent):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.add_tool(SearchTool())
|
|
|
|
def plan_and_execute(self, task: str) -> str:
|
|
# simple loop
|
|
result = self.run(task)
|
|
return result
|
|
|
|
if __name__ == "__main__":
|
|
agent = MyAgent()
|
|
print(agent.plan_and_execute("Python programming")) |