1.4 KiB
1.4 KiB
fastchat 调用实现教程
langchain-ChatGLM 现已支持通过调用 FastChat API 进行 LLM 调用,支持的 API 形式为 OpenAI API 形式。
-
首先请参考 FastChat 官方文档 进行 FastChat OpenAI 形式 API 部署
-
依据 FastChat API 启用时的
model_name和api_base链接,在本项目的configs/model_config.py的llm_model_dict中增加选项。如:llm_model_dict = { # 通过 fastchat 调用的模型请参考如下格式 "fastchat-chatglm-6b": { "name": "chatglm-6b", # "name"修改为fastchat服务中的"model_name" "pretrained_model_name": "chatglm-6b", "local_model_path": None, "provides": "FastChatOpenAILLM", # 使用fastchat api时,需保证"provides"为"FastChatOpenAILLM" "api_base_url": "http://localhost:8000/v1" # "name"修改为fastchat服务中的"api_base_url" }, }其中
api_base_url根据 FastChat 部署时的 ip 地址和端口号得到,如 ip 地址设置为localhost,端口号为8000,则应设置的api_base_url为http://localhost:8000/v1 -
将
configs/model_config.py中的LLM_MODEL修改为对应模型名。如:LLM_MODEL = "fastchat-chatglm-6b" -
根据需求运行
api.py,cli_demo.py或webui.py。