Loading ai_agent/requirements.txt +1 −1 Changes for ai_agent/requirements.txt: 1 added line, 1 removed line. Original line number Diff line number Diff line langchain_groq==1.1.3 mcp_use==1.7.0 mcp>=1.24,<2 mcp==1.30.0 objgraph==3.6.2 python-dotenv==1.2.1 fastapi==0.129.0 Loading ai_agent/routes/groq.py +9 −4 Changes for ai_agent/routes/groq.py: 9 added lines, 4 removed lines. Original line number Diff line number Diff line import logging from typing import Annotated from fastapi import APIRouter, Body, Query from fastapi import APIRouter, Body, Depends, Query from fastapi.responses import JSONResponse, StreamingResponse from ai_agent.memory import RedisShortTermMemory from ai_agent.security import get_authorization from ai_agent.sub_agents.groq_agent import create_groq_agent from ai_agent.utils import stream_agent_response Loading @@ -15,14 +16,17 @@ memory_store = RedisShortTermMemory() @router.post("/groq-mcp") async def groq_query(payload: Annotated[dict | None, Body()] = None): async def groq_query( authorization: Annotated[str, Depends(get_authorization)], payload: Annotated[dict | None, Body()] = None, ): query = payload.get("query") if payload else None session_id = payload.get("session_id") if payload else None if not query: return JSONResponse(status_code=400, content={"error": "No query provided"}) agent = await create_groq_agent() agent = await create_groq_agent(authorization) try: effective_query = await memory_store.augment_query(query, session_id) result = await agent.run(effective_query) Loading @@ -40,13 +44,14 @@ async def groq_query(payload: Annotated[dict | None, Body()] = None): @router.get("/groq-mcp/stream") async def groq_stream( authorization: Annotated[str, Depends(get_authorization)], query: str | None = Query(default=None), session_id: str | None = Query(default=None), ): if not query: return JSONResponse(status_code=400, content={"error": "No query provided"}) agent = await create_groq_agent() agent = await create_groq_agent(authorization) try: effective_query = await memory_store.augment_query(query, session_id) Loading ai_agent/security.py 0 → 100644 +18 −0 Changes for ai_agent/security.py: 18 added lines, 0 removed lines. Original line number Diff line number Diff line from typing import Annotated from fastapi import Header, HTTPException def get_authorization( authorization: Annotated[str | None, Header()] = None, ) -> str: if authorization is not None: scheme, _, token = authorization.partition(" ") if scheme.lower() == "bearer" and token.strip(): return f"Bearer {token.strip()}" raise HTTPException( status_code=401, detail="Bearer token required", headers={"WWW-Authenticate": "Bearer"}, ) ai_agent/sub_agents/groq_agent.py +11 −3 Changes for ai_agent/sub_agents/groq_agent.py: 11 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import os from dotenv import load_dotenv from langchain_groq import ChatGroq from mcp_use import MCPAgent, MCPClient # type: ignore[import-untyped] from pydantic import SecretStr from ai_agent.prompts import CONVERSATION_MEMORY_PROMPT Loading @@ -20,7 +21,7 @@ def require_env(name: str) -> str: return value.strip() async def create_groq_agent(): async def create_groq_agent(authorization: str): """Create an MCPAgent using Groq backend.""" try: mcp_server_url = require_env("MCP_SERVER_URL") Loading @@ -36,7 +37,14 @@ async def create_groq_agent(): client = MCPClient( { "mcpServers": {"http": {"url": mcp_server_url}}, "mcpServers": { "http": { "url": mcp_server_url, "headers": { "Authorization": authorization, }, } }, "use-oauth2": False, "use-oidc": False, } Loading @@ -50,7 +58,7 @@ async def create_groq_agent(): reasoning_format="parsed", timeout=15, max_retries=3, api_key=groq_api_key, api_key=SecretStr(groq_api_key), ) agent = MCPAgent( Loading deployment/docker/README.md +1 −1 Changes for deployment/docker/README.md: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ This deployment relies on a `.env` file that is loaded at runtime by Docker Compose. ``` GROQ_API_KEY=your-groq-api-key OEG_SERVICE_URL=http://your-oeg-api-url/oeg/1.0.0 OEG_SERVICE_URL=http://your-oeg-api-url GROQ_MODEL_NAME=qwen/qwen3.8-27b ``` Loading Loading
ai_agent/requirements.txt +1 −1 Changes for ai_agent/requirements.txt: 1 added line, 1 removed line. Original line number Diff line number Diff line langchain_groq==1.1.3 mcp_use==1.7.0 mcp>=1.24,<2 mcp==1.30.0 objgraph==3.6.2 python-dotenv==1.2.1 fastapi==0.129.0 Loading
ai_agent/routes/groq.py +9 −4 Changes for ai_agent/routes/groq.py: 9 added lines, 4 removed lines. Original line number Diff line number Diff line import logging from typing import Annotated from fastapi import APIRouter, Body, Query from fastapi import APIRouter, Body, Depends, Query from fastapi.responses import JSONResponse, StreamingResponse from ai_agent.memory import RedisShortTermMemory from ai_agent.security import get_authorization from ai_agent.sub_agents.groq_agent import create_groq_agent from ai_agent.utils import stream_agent_response Loading @@ -15,14 +16,17 @@ memory_store = RedisShortTermMemory() @router.post("/groq-mcp") async def groq_query(payload: Annotated[dict | None, Body()] = None): async def groq_query( authorization: Annotated[str, Depends(get_authorization)], payload: Annotated[dict | None, Body()] = None, ): query = payload.get("query") if payload else None session_id = payload.get("session_id") if payload else None if not query: return JSONResponse(status_code=400, content={"error": "No query provided"}) agent = await create_groq_agent() agent = await create_groq_agent(authorization) try: effective_query = await memory_store.augment_query(query, session_id) result = await agent.run(effective_query) Loading @@ -40,13 +44,14 @@ async def groq_query(payload: Annotated[dict | None, Body()] = None): @router.get("/groq-mcp/stream") async def groq_stream( authorization: Annotated[str, Depends(get_authorization)], query: str | None = Query(default=None), session_id: str | None = Query(default=None), ): if not query: return JSONResponse(status_code=400, content={"error": "No query provided"}) agent = await create_groq_agent() agent = await create_groq_agent(authorization) try: effective_query = await memory_store.augment_query(query, session_id) Loading
ai_agent/security.py 0 → 100644 +18 −0 Changes for ai_agent/security.py: 18 added lines, 0 removed lines. Original line number Diff line number Diff line from typing import Annotated from fastapi import Header, HTTPException def get_authorization( authorization: Annotated[str | None, Header()] = None, ) -> str: if authorization is not None: scheme, _, token = authorization.partition(" ") if scheme.lower() == "bearer" and token.strip(): return f"Bearer {token.strip()}" raise HTTPException( status_code=401, detail="Bearer token required", headers={"WWW-Authenticate": "Bearer"}, )
ai_agent/sub_agents/groq_agent.py +11 −3 Changes for ai_agent/sub_agents/groq_agent.py: 11 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import os from dotenv import load_dotenv from langchain_groq import ChatGroq from mcp_use import MCPAgent, MCPClient # type: ignore[import-untyped] from pydantic import SecretStr from ai_agent.prompts import CONVERSATION_MEMORY_PROMPT Loading @@ -20,7 +21,7 @@ def require_env(name: str) -> str: return value.strip() async def create_groq_agent(): async def create_groq_agent(authorization: str): """Create an MCPAgent using Groq backend.""" try: mcp_server_url = require_env("MCP_SERVER_URL") Loading @@ -36,7 +37,14 @@ async def create_groq_agent(): client = MCPClient( { "mcpServers": {"http": {"url": mcp_server_url}}, "mcpServers": { "http": { "url": mcp_server_url, "headers": { "Authorization": authorization, }, } }, "use-oauth2": False, "use-oidc": False, } Loading @@ -50,7 +58,7 @@ async def create_groq_agent(): reasoning_format="parsed", timeout=15, max_retries=3, api_key=groq_api_key, api_key=SecretStr(groq_api_key), ) agent = MCPAgent( Loading
deployment/docker/README.md +1 −1 Changes for deployment/docker/README.md: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ This deployment relies on a `.env` file that is loaded at runtime by Docker Compose. ``` GROQ_API_KEY=your-groq-api-key OEG_SERVICE_URL=http://your-oeg-api-url/oeg/1.0.0 OEG_SERVICE_URL=http://your-oeg-api-url GROQ_MODEL_NAME=qwen/qwen3.8-27b ``` Loading