Open lloydzhou opened 1 year ago
少导入了一个
from fastapi import HTTPException,status
而且也没有处理跨域问题
from fastapi.middleware.cors import CORSMiddleware
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
注:我纯路人,不是rwkv.cpp的开发者
docker build -t lloydzhou/rwkv-cpp-api -f Dockerfile .
# run docker
docker run --rm -it -v `pwd`/RWKV-4-World-3B-v1-20230619-ctx4096_Q4_0.bin:/RWKV-4-World-3B-v1-20230619-ctx4096_Q4_0.bin -e MODEL_PATH=/RWKV-4-World-3B-v1-20230619-ctx4096_Q4_0.bin -p 8000:8000 lloydzhou/rwkv-cpp-api
# test
curl localhost:8000/v1/chat/completions -X POST -H 'Content-Type: application/json' -d '{"messages": [{"role": "system", "content": "你是一个历史老师"}, {"role": "user", "content": "请告诉我周文王是谁?"}], "stream": false}'
这个是兼容OpenAI的接口吗?
@az13js 格式是和openai的api一样的,也支持stream模式
Add API server
start
/completions
/chat/completions