diff options
Diffstat (limited to 'useragents/src')
-rw-r--r-- | useragents/src/__init__.py | 0 | ||||
-rw-r--r-- | useragents/src/current_time.py | 20 | ||||
-rw-r--r-- | useragents/src/custom_agents/__init__.py | 0 | ||||
-rw-r--r-- | useragents/src/custom_agents/web_search_tool.py | 17 | ||||
-rw-r--r-- | useragents/src/models.py | 12 | ||||
-rw-r--r-- | useragents/src/registry.py | 11 |
6 files changed, 60 insertions, 0 deletions
diff --git a/useragents/src/__init__.py b/useragents/src/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/useragents/src/__init__.py diff --git a/useragents/src/current_time.py b/useragents/src/current_time.py new file mode 100644 index 0000000..8304464 --- /dev/null +++ b/useragents/src/current_time.py @@ -0,0 +1,20 @@ +from datetime import datetime +from agents import function_tool + + +@function_tool +def fetch_time(): + """ + Fetches the current time. + """ + + return datetime.now().strftime("%H:%M:%S") + + +@function_tool +def fetch_date(): + """ + Fetches the current date. + """ + + return datetime.now().strftime("%Y-%m-%d") diff --git a/useragents/src/custom_agents/__init__.py b/useragents/src/custom_agents/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/useragents/src/custom_agents/__init__.py diff --git a/useragents/src/custom_agents/web_search_tool.py b/useragents/src/custom_agents/web_search_tool.py new file mode 100644 index 0000000..16bf206 --- /dev/null +++ b/useragents/src/custom_agents/web_search_tool.py @@ -0,0 +1,17 @@ +from agents import Agent, WebSearchTool +from src.current_time import fetch_date +from src.models import AgentRequest +from src.registry import agentRegistry + + +@agentRegistry +def web_search_tool(agent_request: AgentRequest) -> Agent: + tools = [WebSearchTool(), fetch_date] + + agent = Agent( + name=agent_request.agent_name, + instructions=agent_request.instructions, + tools=tools, + ) + + return agent diff --git a/useragents/src/models.py b/useragents/src/models.py new file mode 100644 index 0000000..14d37fc --- /dev/null +++ b/useragents/src/models.py @@ -0,0 +1,12 @@ +import pydantic + + +class AgentRequest(pydantic.BaseModel): + agent_name: str + instructions: str + query: str + + +class AgentResponse(pydantic.BaseModel): + agent_name: str + response: str diff --git a/useragents/src/registry.py b/useragents/src/registry.py new file mode 100644 index 0000000..1ea9607 --- /dev/null +++ b/useragents/src/registry.py @@ -0,0 +1,11 @@ +class AgentRegistry: + def __init__(self): + self.registry = {} + + def __call__(self, func): + self.registry[func.__name__] = func + print(f"Registered agent: {func.__name__}") + return func + + +agentRegistry = AgentRegistry() |