-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (38 loc) · 1.17 KB
/
Copy pathmain.py
File metadata and controls
44 lines (38 loc) · 1.17 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
from dotenv import load_dotenv
load_dotenv()
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.routes import router
# Initialize FastAPI app
app = FastAPI(
title="ReAct Agent API",
description="API for Agent with tools",
version="1.0.0"
)
# Configure CORS (Critical for frontend communication)
# Allowing all origins ("*") for development.
# In production, replace with your frontend URL.
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include the router defined in app/api/routes.py
app.include_router(router, prefix="/api")
@app.get("/")
def health_check():
"""Simple health check endpoint."""
return {
"status": "running",
"service": "ReAct Agent with tools",
"version": "1.0.0",
"docs": "http://127.0.0.1:8000/docs"
}
if __name__ == "__main__":
import uvicorn
# Run the server using Uvicorn
# reload=True enables auto-restart when code changes (dev mode)
print("Starting server on http://127.0.0.1:8000")
uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)