Spaces:
No application file
No application file
push updated backend changes
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# main.py
|
| 2 |
+
import uvicorn
|
| 3 |
+
from fastapi import FastAPI
|
| 4 |
+
from pydantic import BaseModel
|
| 5 |
+
from agents import TutorAgent, BioUser
|
| 6 |
+
|
| 7 |
+
# Initialize FastAPI
|
| 8 |
+
app = FastAPI(title="Bioinformatics Tutor API")
|
| 9 |
+
|
| 10 |
+
# Initialize agents
|
| 11 |
+
user_agent = BioUser()
|
| 12 |
+
tutor_agent = TutorAgent()
|
| 13 |
+
|
| 14 |
+
# Request model
|
| 15 |
+
class QueryRequest(BaseModel):
|
| 16 |
+
question: str
|
| 17 |
+
|
| 18 |
+
# Response model
|
| 19 |
+
class QueryResponse(BaseModel):
|
| 20 |
+
answer: str
|
| 21 |
+
|
| 22 |
+
@app.post("/ask", response_model=QueryResponse)
|
| 23 |
+
def ask_tutor(request: QueryRequest):
|
| 24 |
+
"""
|
| 25 |
+
Ask the Bioinformatics Tutor a question.
|
| 26 |
+
"""
|
| 27 |
+
answer = tutor_agent.process_query(request.question)
|
| 28 |
+
return QueryResponse(answer=answer)
|
| 29 |
+
|
| 30 |
+
@app.get("/")
|
| 31 |
+
def root():
|
| 32 |
+
return {"message": "Bioinformatics Tutor API is running."}
|
| 33 |
+
|