llmapi server
1.0.0
Self-Host LLMAPI服务器
中文文档
llmapi-server是一个抽象的后端,它封装了各种大型语言模型(LLM,例如Chatgpt,GPT-3,GPT-4等),并通过OpenAPI提供简单的访问服务
?如果对您有帮助,请播放吗?
图LR
子图LLMAPI服务器
OpenAPI->会话
OpenAPI-> PRE_POST
子图后端
样式后端填充:#f9f
pre_post-> chatgpt
pre_post-> dall-e
pre_post->骆驼
pre_post-> ...
结尾
结尾
文字 - > OpenAPI
图像 - > OpenAPI
嵌入 - > OpenAPI
其他 - > Openapi
chatgpt :OpenAI的官方Chatgpt界面gpt3 :OpenAI的官方GPT-3界面gpt-embedding :OpenAI的官方嵌入界面dall-e :Openai的官方dall·e界面welm :微信的LLM界面newbing :基于chatgpt的新bing搜索(非官方) # python >= 3.8
python3 -m pip install -r requirements.txt
python3 run_api_server.py./build_docker.sh
./start_docker.shcurl命令访问: # 1. Start a new session
curl -X POST -H " Content-Type: application/json " -d ' {"bot_type":"mock"} ' http://127.0.0.1:5050/v1/chat/start
# response sample: {"code":0,"msg":"Success","session":"123456"}
# 2. chat with LLMs
curl -X POST -H " Content-Type: application/json " -d ' {"session":"123456","content":"hello"} ' http://127.0.0.1:5050/v1/chat/ask
# response sample: {"code":0,"msg":"Success","reply":"Text mock reply for your prompt:hello","timestamp":1678865301.0842562}
# 3. Close the session and end chat
curl -X POST -H " Content-Type: application/json " -d ' {"session":"123456"} ' http://127.0.0.1:5050/v1/chat/end
# response: {"code":0,"msg":"Success"}llmapi_cli --host= " http://127.0.0.1:5050 " --bot=mock from llmapi_cli import LLMClient
client = LLMClient ( host = "http://127.0.0.1:5050" , bot = "mock" )
rep = client . ask ( "hello" )
print ( rep )newllm ),您可以直接cp -r mock newllmmock的实现,将后端名称更改为newllmnewllm目录中,添加必要的依赖项,所有相关的开发都与此目录绑定backend.py中添加对newllm的支持