-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
70 lines (59 loc) · 1.84 KB
/
main.py
File metadata and controls
70 lines (59 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from fastapi import FastAPI, APIRouter
from fastapi.middleware.cors import CORSMiddleware
from routes import file_processing_routes
from routes import question_gen_routes
from routes import summarizer_routes
from routes import qa_routes
from dotenv import load_dotenv
load_dotenv()
app = FastAPI(
title="CourseTA API",
version="1.0.0",
description="API for CourseTA agentic system including preprocessing and graph-based agents."
)
# Add CORS middleware to allow requests from Gradio frontend
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # In production, replace with specific origins
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
api_v1_router = APIRouter(prefix="/api/v1")
# --- Direct Routes (no prefix) --- #
# Making the file_processing_routes accessible directly for easier Gradio integration
app.include_router(
file_processing_routes.router,
tags=["File Processing"]
)
# --- Preprocessing Routes --- #
api_v1_router.include_router(
file_processing_routes.router,
prefix="/preprocessing",
tags=["Preprocessing"]
)
# --- Graph Agent Routes --- #
graph_base_router = APIRouter(prefix="/graph", tags=["Graph Agents"])
graph_base_router.include_router(
question_gen_routes.router,
prefix="/qg",
tags=["Question Generation Agent"]
)
graph_base_router.include_router(
summarizer_routes.router,
prefix="/summarizer",
tags=["Summarization Agent"]
)
graph_base_router.include_router(
qa_routes.router,
prefix="/qa",
tags=["Question Answering Agent"]
)
api_v1_router.include_router(graph_base_router)
app.include_router(api_v1_router)
@app.get("/", tags=["Root"])
async def read_root():
return {"message": "Welcome to CourseTA API."}
if __name__ == "__main__":
import uvicorn
uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)