28 lines
516 B
Python
28 lines
516 B
Python
from fastapi import FastAPI
|
|
from fastapi.responses import RedirectResponse
|
|
from langchain.chat_models import ChatOpenAI
|
|
from langserve import add_routes
|
|
|
|
app = FastAPI()
|
|
llm = ChatOpenAI(
|
|
model="gpt-4o-mini",
|
|
temperature=0.9
|
|
)
|
|
|
|
@app.get("/")
|
|
async def redirect_root_to_docs():
|
|
return RedirectResponse("/docs")
|
|
|
|
|
|
# Edit this to add the chain you want to add
|
|
add_routes(
|
|
app,
|
|
llm,
|
|
path="/openai"
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|