File size: 825 Bytes
a8ab4cd 2e5aca2 a8ab4cd 2e5aca2 a8ab4cd 2e5aca2 a8ab4cd |
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 |
from dotenv import load_dotenv
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from langserve import add_routes
from graph import create_graph
from utils.chat_types import ChatInputType
# Load environment variables from .env file
load_dotenv()
app = FastAPI(
title="CRAG Backend",
version="1.0",
description="Backend to run agent performing corrective RAG over annual reports",
)
# Configure CORS
origins = [
"http://localhost",
"http://localhost:3000",
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
graph = create_graph()
runnable = graph.with_types(input_type=ChatInputType, output_type=dict)
add_routes(app, runnable, path="/chat", playground_type="default")
|