agent endpoint updated
Browse files78 unmodified lines79808182838485868788899091929394959697989910010110278 unmodified lines@app.post("/chat/{agent_name}", response_model=dict)async def chat_with_agent(agent_name: str, request: QueryRequest):if agent_name not in AVAILABLE_AGENTS:raise HTTPException(status_code=404, detail="Agent not found")agent = AVAILABLE_AGENTS[agent_name]response_text = agent(request.query)return {"agent_name": agent_name,"query": request.query,"response": response_text,}@app.post("/chat", response_model=dict)async def chat_with_all(request: QueryRequest):response_text = ai_system(request.query)response_text = format_response_to_markdown(response_text)return {"agent_name": "ai_system","query": request.query,"response": response_text,}@app.get("/health", response_model=dict)78 unmodified lines79808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012178 unmodified lines@app.post("/chat/{agent_name}", response_model=dict)async def chat_with_agent(agent_name: str, request: QueryRequest):if agent_name not in AVAILABLE_AGENTS:raise HTTPException(status_code=404, detail=f"Agent '{agent_name}' not found. Available agents: {list(AVAILABLE_AGENTS.keys())}")try:print("agent_name: ", agent_name)agent = AVAILABLE_AGENTS[agent_name]response = agent(request.query)# Format the response using the same formatter as the main chat endpointformatted_response = format_response_to_markdown(response)return {"agent_name": agent_name,"query": request.query,"response": formatted_response,}except Exception as e:raise HTTPException(status_code=500, detail=str(e))@app.post("/chat", response_model=dict)async def chat_with_all(request: QueryRequest):try:response = ai_system(request.query)formatted_response = format_response_to_markdown(response)return {"agent_name": "ai_system","query": request.query,"response": formatted_response,}except Exception as e:raise HTTPException(status_code=500, detail=str(e))# Add an endpoint to list available agents@app.get("/agents", response_model=dict)async def list_agents():return {"available_agents": list(AVAILABLE_AGENTS.keys()),"description": "List of available specialized agents that can be called using @agent_name"}@app.get("/health", response_model=dict)
app.py+32-13