feat:更新智能体架构
This commit is contained in:
25
main.py
25
main.py
@@ -1,22 +1,25 @@
|
||||
from dotenv import load_dotenv
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from router import router
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
from starlette.responses import StreamingResponse
|
||||
|
||||
# 初始化FastAPI
|
||||
app = FastAPI(
|
||||
title="Sweet Hut Agent",
|
||||
description="智能体",
|
||||
version="0.1.0"
|
||||
)
|
||||
from modes.agent import QueryRequest
|
||||
from services import query_bill_agent
|
||||
|
||||
app = FastAPI(title="Integrate Agent API")
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
load_dotenv()
|
||||
|
||||
app.include_router(router)
|
||||
@app.post("/query/bill")
|
||||
async def query_agent(query: QueryRequest):
|
||||
"""流式对话"""
|
||||
return StreamingResponse(
|
||||
query_bill_agent(query),
|
||||
media_type="text/event-stream"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user