feat: 模型调用,以及模型服务代理
This commit is contained in:
@@ -75,6 +75,35 @@ async def redirect_root_to_docs():
|
|||||||
return RedirectResponse("/docs")
|
return RedirectResponse("/docs")
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/chat")
|
||||||
|
async def chat():
|
||||||
|
model = init_chat_model(
|
||||||
|
model="qwen2.5-vl-7b-instruct", # 你的模型名
|
||||||
|
model_provider="openai", # 必须填 openai(兼容协议)
|
||||||
|
base_url="http://127.0.0.1:1234/v1", # 你的自定义 API URL
|
||||||
|
api_key="1234", # 本地模型随便填
|
||||||
|
temperature=0.7,
|
||||||
|
)
|
||||||
|
output = model.invoke("你好").content
|
||||||
|
|
||||||
|
print(f"output:{output}")
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
# Edit this to add the chain you want to add
|
||||||
|
# add_routes(app, NotImplemented)
|
||||||
|
|
||||||
|
model = init_chat_model(
|
||||||
|
model="doubao-1-5-pro-32k-250115", # 你的模型名
|
||||||
|
model_provider="openai", # 必须填 openai(兼容协议)
|
||||||
|
base_url="https://ark.cn-beijing.volces.com/api/v3/", # 你的自定义 API URL
|
||||||
|
api_key="b1e7c7e0-33af-480e-b0a8-2812ba97f7b1", # 本地模型随便填
|
||||||
|
temperature=0.7,
|
||||||
|
streaming=False
|
||||||
|
)
|
||||||
|
|
||||||
|
add_routes(app=app,runnable=model,path="/qwen")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user