- After opening the codespace, install the dependencies:
pip install -e .- Configure the required environment variables:
export OPENAI_API_KEY=<your-openai-api-key>
export DATABASE_URL=<your-database-url>- Run the application:
cd ecommerce_calculator
python main.pyOPENAI_API_KEY: Your OpenAI API key for AI functionalityDATABASE_URL: Connection string for your database (format:postgresql://user:password@host:port/dbname)
For local development, you can create a .env file in the root directory with the above environment variables.
Test Product IDs:
985b030a-f6b0-47d9-98d3-98c3c7d35f06d7d13480-fe01-4a2c-85f2-bcdee4c2a5b04a5cfd0f-bda6-460b-a4b2-af5e608ced99
- Support multiple agents
from typing import Dict, Any
from abc import ABC, abstractmethod
class Agent(ABC):
"""Base class for LLM agents"""
def __init__(self, agent_id: str, capabilities: List[str]):
self.agent_id = agent_id
self.capabilities = capabilities
self.metrics = AgentMetrics()
@abstractmethod
def process_request(self, request: Dict[str, Any]) -> Dict[str, Any]:
"""Process incoming requests using available tools"""
pass
@abstractmethod
def validate_access(self, tool_name: str) -> bool:
"""Validate agent's access to requested tool"""
passclass AgentManager:
"""Manages multiple LLM agents and their tool access"""
def __init__(self):
self._agents: Dict[str, Agent] = {}
self._tool_repository = ToolRepository()
def register_agent(self, agent: Agent):
"""Register a new agent"""
self._agents[agent.agent_id] = agent
def route_request(self, agent_id: str, request: Dict[str, Any]) -> Dict[str, Any]:
"""Route request to appropriate agent"""
agent = self._agents.get(agent_id)
if not agent:
raise ValueError(f"Unknown agent: {agent_id}")
return agent.process_request(request)