Skip to content
Snippets Groups Projects

Added middleware

Merged Ask Markestad requested to merge test-alternative-endpoint into master
1 file
+ 12
1
Compare changes
  • Side-by-side
  • Inline
+ 12
1
@@ -3,7 +3,8 @@ import asyncio
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from langserve import add_routes
# from langserve import add_routes
from fastapi.middleware.cors import CORSMiddleware
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
@@ -16,6 +17,16 @@ app = FastAPI(
description="Spin up a simple api server using Langchain's Runnable interfaces",
)
# Set all CORS enabled origins
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
expose_headers=["*"],
)
class InvokeRequest(BaseModel):
question: str
chat_history: list[str]
Loading