LiteLLM
info
LiteLLM提供了一个统一的接口,可以用相同的输入/输出格式调用100多种大语言模型,包括OpenAI、Huggingface、Anthropic、vLLM、Cohere甚至自定义的LLM API服务器。通过LiteLLM作为桥梁,许多大语言模型都可以接入TaskWeaver。这里我们使用LiteLLM提供的OpenAI代理服务器进行配置。
- Install LiteLLM Proxy and configure the LLM server by following the instruction here. In general, there are a few steps:
- 安装包
pip install litellm[proxy] - 设置API密钥和其他必要的环境变量,这些变量因LLM而异。以Cohere为例,需要设置
export COHERE_API_KEY=my-api-key。 - 通过运行
litellm --model MODEL_NAME --drop_params启动LiteLLM代理服务器,例如在Cohere平台中,模型名称可以是command-nightly。drop-params参数用于确保API兼容性。随后,系统将自动在http://0.0.0.0:8000地址上启动服务。
- 安装包
tip
LiteLLM支持的全部模型列表可在页面查看。
- 将以下内容添加到您的
taskweaver_config.json文件中:
{
"llm.api_base": "http://0.0.0.0:8000",
"llm.api_key": "anything",
"llm.model": "gpt-3.5-turbo"
}
info
llm.api_key 和 llm.model 主要作为API调用的占位符,其实际值不会被使用。如果配置无效,请参考LiteLLM文档在本地测试是否能向大语言模型发送请求。
- 打开一个新的终端,启动TaskWeaver并开始对话。 您可以参考快速入门获取更多详细信息。