From 099747169aa416c5c281b9f6fe4eb8ec7c7dec55 Mon Sep 17 00:00:00 2001 From: AndrewVFranco <129307231+AndrewVFranco@users.noreply.github.com> Date: Thu, 9 Apr 2026 10:22:30 -0700 Subject: [PATCH 1/3] Refactor compiled agent name --- requirements.txt | 5 ++++- src/agent/graph.py | 2 +- tests/pipeline_runner.py | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 10f8a0a..3ad1a2d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -33,4 +33,7 @@ redis>=5.0.0 # General numpy>=2.4.0 -torch>=2.11.0 \ No newline at end of file +torch>=2.11.0 + +# FastAPI +fastapi>=0.110.0 \ No newline at end of file diff --git a/src/agent/graph.py b/src/agent/graph.py index b42e758..97d6c1f 100644 --- a/src/agent/graph.py +++ b/src/agent/graph.py @@ -35,4 +35,4 @@ graph.set_finish_point("assembly") # Compile -app = graph.compile() \ No newline at end of file +agent = graph.compile() \ No newline at end of file diff --git a/tests/pipeline_runner.py b/tests/pipeline_runner.py index 8642a98..c038a3c 100644 --- a/tests/pipeline_runner.py +++ b/tests/pipeline_runner.py @@ -1,8 +1,8 @@ -from src.agent.graph import app +from src.agent.graph import agent import sys def main(): - result = app.invoke({ + result = agent.invoke({ "query": "What are the first line treatments for atrial fibrillation?", "cache_hit": False, "abstracts": [], From 98502a07b08a53b49c96e2d46508330cb6b99d35 Mon Sep 17 00:00:00 2001 From: AndrewVFranco <129307231+AndrewVFranco@users.noreply.github.com> Date: Sun, 12 Apr 2026 12:58:39 -0700 Subject: [PATCH 2/3] Add FastAPI query endpoint with Pydantic request validation and health check --- requirements.txt | 3 ++- src/api/main.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/api/main.py diff --git a/requirements.txt b/requirements.txt index 3ad1a2d..3205f5b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,4 +36,5 @@ numpy>=2.4.0 torch>=2.11.0 # FastAPI -fastapi>=0.110.0 \ No newline at end of file +fastapi>=0.110.0 +uvicorn>=0.29.0 \ No newline at end of file diff --git a/src/api/main.py b/src/api/main.py new file mode 100644 index 0000000..c492de0 --- /dev/null +++ b/src/api/main.py @@ -0,0 +1,35 @@ +from fastapi import FastAPI, Request, HTTPException +from contextlib import asynccontextmanager +from src.agent.graph import agent +from pydantic import BaseModel + +class QueryRequest(BaseModel): + query: str + +@asynccontextmanager +async def lifespan(app): + yield +app = FastAPI(lifespan=lifespan) + +@app.post("/query") +async def query(request: QueryRequest): + try: + result = agent.invoke({ + "query": request.query, + "search_query": None, + "cache_hit": False, + "abstracts": [], + "llm_response": None, + "claims": None, + "scored_claims": None, + "confidence_score": None, + "final_response": None + }) + + return result + except Exception as e: + raise HTTPException(status_code=500, detail=f"Inference failed: {str(e)}") + +@app.get("/health") +async def health(): + return {"status": "ok"} \ No newline at end of file From 4f5f1943b2a7f92d38b74076919af0c3d767596e Mon Sep 17 00:00:00 2001 From: AndrewVFranco <129307231+AndrewVFranco@users.noreply.github.com> Date: Sun, 12 Apr 2026 13:03:08 -0700 Subject: [PATCH 3/3] Remove unused import --- src/api/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/main.py b/src/api/main.py index c492de0..c455dce 100644 --- a/src/api/main.py +++ b/src/api/main.py @@ -1,4 +1,4 @@ -from fastapi import FastAPI, Request, HTTPException +from fastapi import FastAPI, HTTPException from contextlib import asynccontextmanager from src.agent.graph import agent from pydantic import BaseModel