-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (31 loc) · 1.38 KB
/
main.py
File metadata and controls
40 lines (31 loc) · 1.38 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
from fastapi import FastAPI
import models
from db_postgres import engine
from routers import agents, topics, topic_instructions, users
from fastapi.middleware.cors import CORSMiddleware
from routers.graph_router import router as graph_router
# Ensure all tables are created in the database
models.Base.metadata.create_all(bind=engine)
# Initialize the FastAPI app
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include the users router with a prefix and tags for better API documentation
app.include_router(users.router, prefix="/api", tags=["users"])
# Include the agents router with a prefix and tags for better API documentation
app.include_router(agents.router, prefix="/api", tags=["agents"])
# Include the topics router with a prefix and tags for better API documentation
app.include_router(topics.router, prefix="/api", tags=["topics"])
# Include the topic instructions router with a prefix and tags for better API documentation
app.include_router(topic_instructions.router, prefix="/api", tags=["topic_instructions"])
# Include the graph router for handling graph-related operations
app.include_router(graph_router, prefix="/api", tags=["graph"])
# Root endpoint to verify the application is running
@app.get("/")
def root():
return {"message": "Agent Builder API is running"}