Skip to content

Commit a9a0d2e

Browse files
committed
doc(config.md): Improve the config documentation, enriched the configuration descriptions of api_config, and added relevant examples.
1 parent 6e59ef3 commit a9a0d2e

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

doc/config.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,60 @@
66
- 主流模型只需要修改`api_config`即可接入,无需修改该参数
77
- 实现默认不支持的大模型接入,可实现`llm_api_interface`接口,并将类名传入该参数。
88
- `api_config`: 大模型API配置
9-
- 具体配置参见[UnionLLM仓库](https://github.com/EvalsOne/UnionLLM/)[LiteLLM文档](https://docs.litellm.ai/docs)
10-
- `MODEL_NAME` 传入模型名称
11-
- `PROVIDER` 传入模型提供商
9+
> 除必选参数外,其他参数根据模型需求填写,具体模型对应的参数参见[LiteLLM文档](https://docs.litellm.ai/docs)以及[UnionLLM仓库-DOC目录](https://github.com/EvalsOne/UnionLLM/tree/main/docs)中相应模型部分。具体而言:
10+
>
11+
> 国外模型请查找[LiteLLM文档](https://docs.litellm.ai/docs),并将`LiteLLM`示例中`litellm.completion`内的参数填写到`api_config`中,若示例需要通过环境变量鉴权,也请填写到`api_config`中。
12+
>
13+
> 国内模型请查找[UnionLLM仓库-DOC目录](https://github.com/EvalsOne/UnionLLM/tree/main/docs),并将`UnionLLM`示例中`unionchat`内的参数填写到`api_config`中,若示例需要通过环境变量鉴权,也请填写到`api_config`中。
14+
- 必选参数
15+
- `model` 传入模型名称
16+
- `provider` 传入模型提供商
17+
- 常用可选参数
18+
- `api_base` 传入API地址
19+
- `api_key` 传入API密钥
20+
- 其他可选参数
21+
- `max_tokens` 设置生成文本的最大长度
22+
- `temperature` 控制生成文本的随机性
23+
- `top_p` 控制生成文本的多样性
24+
- `n` 设置生成的文本数量
25+
- `logprobs` 返回生成文本的对数概率
26+
- `stream` 是否以流式方式返回生成结果
27+
- `stop` 设置生成文本的停止标记
28+
- `presence_penalty` 控制生成文本中重复内容的惩罚
29+
- `frequency_penalty` 控制生成文本中频繁出现内容的惩罚
30+
- `best_of` 从多次生成中选择最佳结果
31+
- `logit_bias` 调整生成文本中某些词的概率
32+
- `api_url` 传入API地址
33+
- `api_version` 传入API版本
34+
- `extra_headers` 传入额外的HTTP头信息
35+
- 其他参数请参考上述文档
1236
- 该配置会自动传给`llm_api_impl``set_config`方法,用于初始化大模型API。
37+
### 示例
38+
#### ChatGPT
39+
```python
40+
# 直接传入
41+
api_config = {
42+
"api_key": "your openai key",
43+
"api_base": "https://api.openai.com/v1",
44+
"model": "gpt-3.5-turbo",
45+
"provider": "openai",
46+
}
47+
# 通过环境变量传入
48+
api_config = {
49+
"OPENAI_API_KEY": "your openai key",
50+
"OPENAI_API_BASE": "https://api.openai.com/v1",
51+
"model": "gpt-3.5-turbo",
52+
"provider": "openai",
53+
}
54+
```
55+
#### Ollama
56+
```python
57+
api_config = {
58+
"api_base": "http://localhost:11434",
59+
"model": "llama3.2",
60+
"provider": "ollama",
61+
}
62+
```
1363

1464

1565
## Gitlab配置

0 commit comments

Comments
 (0)