|
26 | 26 |
|
27 | 27 | load_dotenv() |
28 | 28 |
|
29 | | -# Import agent service and models |
30 | | -from agents import AgentRequest, AgentResponse, AgentService |
31 | 29 |
|
32 | 30 | # Import unified operation system |
33 | 31 | from api_decorators import operation |
|
51 | 49 | task_service = TaskService() |
52 | 50 | ollama_service = OllamaService() |
53 | 51 |
|
54 | | -# Initialize agent service (may fail if Azure OpenAI not configured) |
55 | | -try: |
56 | | - agent_service = AgentService() |
57 | | - print("✓ Agent service initialized with Azure OpenAI") |
58 | | -except ValueError as e: |
59 | | - agent_service = None |
60 | | - print(f"⚠ Agent service disabled: {e}") |
61 | | - print(" To enable agents, configure Azure OpenAI in .env file") |
62 | | - |
63 | 52 |
|
64 | 53 | # ============================================================================ |
65 | 54 | # UTILITY FUNCTIONS |
@@ -209,37 +198,6 @@ async def op_list_ollama_models() -> ModelListResponse: |
209 | 198 | """ |
210 | 199 | return await ollama_service.list_models() |
211 | 200 |
|
212 | | -@operation( |
213 | | - name="run_agent", |
214 | | - description="Execute an AI agent with access to task management tools", |
215 | | - http_method="POST", |
216 | | - http_path="/api/agents/run" |
217 | | -) |
218 | | -async def op_run_agent(request: AgentRequest) -> AgentResponse: |
219 | | - """ |
220 | | - Run a LangGraph ReAct agent with task management capabilities. |
221 | | - |
222 | | - The agent has access to all @operation decorated functions as tools, |
223 | | - including create_task, update_task, delete_task, list_tasks, etc. |
224 | | - |
225 | | - Requires Azure OpenAI to be configured in .env file. |
226 | | - |
227 | | - Args: |
228 | | - request: AgentRequest with prompt and agent_type |
229 | | - |
230 | | - Returns: |
231 | | - AgentResponse with agent output and metadata |
232 | | - |
233 | | - Raises: |
234 | | - ValueError: If agent service is not initialized (missing Azure config) |
235 | | - """ |
236 | | - if agent_service is None: |
237 | | - raise ValueError( |
238 | | - "Agent service is not available. " |
239 | | - "Please configure Azure OpenAI credentials in .env file. " |
240 | | - "See .env.example for required variables." |
241 | | - ) |
242 | | - return await agent_service.run_agent(request) |
243 | 201 |
|
244 | 202 | # ============================================================================ |
245 | 203 | # REST API WRAPPERS |
@@ -341,20 +299,6 @@ async def rest_list_ollama_models(): |
341 | 299 | return jsonify({"error": str(e)}), 500 |
342 | 300 |
|
343 | 301 |
|
344 | | -@app.route("/api/agents/run", methods=["POST"]) |
345 | | -async def rest_run_agent(): |
346 | | - """REST wrapper: run AI agent with task management tools.""" |
347 | | - try: |
348 | | - data = await request.get_json() |
349 | | - agent_request = AgentRequest(**data) |
350 | | - response = await op_run_agent(agent_request) |
351 | | - return jsonify(response.model_dump()), 200 |
352 | | - except ValidationError as e: |
353 | | - return jsonify({"error": str(e)}), 400 |
354 | | - except ValueError as e: |
355 | | - return jsonify({"error": str(e)}), 503 |
356 | | - except Exception as e: |
357 | | - return jsonify({"error": str(e)}), 500 |
358 | 302 |
|
359 | 303 |
|
360 | 304 | # ============================================================================ |
|
0 commit comments