36 lines
729 B
Python
36 lines
729 B
Python
from pydantic import BaseModel, Field
|
|
from fastapi import FastAPI
|
|
from fastapi.responses import RedirectResponse
|
|
from langserve import add_routes
|
|
from app.chain import build_chain
|
|
|
|
# Input API
|
|
class QueryInput(BaseModel):
|
|
"""쿼리 입력 모델"""
|
|
question: str = Field(..., description="사용자 질문")
|
|
temperature: float = 0.7
|
|
max_tokens: int = 1000
|
|
|
|
app = FastAPI()
|
|
|
|
rag_chain = build_chain()
|
|
|
|
|
|
@app.get("/")
|
|
async def redirect_root_to_docs():
|
|
return RedirectResponse("/chat")
|
|
|
|
|
|
# Edit this to add the chain you want to add
|
|
add_routes(
|
|
app,
|
|
rag_chain,
|
|
path="/chat",
|
|
input_type=QueryInput
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|