You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.6 KiB
3.6 KiB
配置文件说明
概述
config.json 用于存储基础配置信息,避免每次使用时重复填写。程序启动时会自动加载此文件。
文件位置
simple72/
└── config.json # 配置文件(不存在时使用默认值)
└── config.json.example # 配置示例文件
配置结构
{
"brain": {
"username": "your_username",
"password": "your_password"
},
"llm": {
"api_key": "your_api_key",
"base_url": "https://api.moonshot.cn/v1",
"model": "kimi-k2.5"
},
"transformer": {
"top_n_datafield": 50,
"data_type": "MATRIX"
}
}
各配置项说明
brain - BRAIN 平台凭证
| 字段 | 类型 | 说明 | 示例 |
|---|---|---|---|
username |
string | BRAIN 平台用户名 | your_email@example.com |
password |
string | BRAIN 平台密码 | your_password |
注意: 密码明文存储,请确保文件权限安全。
llm - 大模型配置
| 字段 | 类型 | 说明 | 示例 |
|---|---|---|---|
api_key |
string | LLM API 密钥 | sk-xxxxx |
base_url |
string | LLM 服务地址 | https://api.moonshot.cn/v1 |
model |
string | 模型名称 | kimi-k2.5 |
支持的 LLM 服务:
- Kimi:
https://api.moonshot.cn/v1 - OpenAI:
https://api.openai.com/v1 - 其他 OpenAI 兼容服务
transformer - Transformer 配置
| 字段 | 类型 | 说明 | 默认值 |
|---|---|---|---|
top_n_datafield |
int | 数据字段候选数量 | 50 |
data_type |
string | 数据类型 | MATRIX |
使用方式
方式一:手动编辑配置文件
-
复制
config.json.example为config.jsoncp config.json.example config.json -
编辑
config.json,填入你的配置信息 -
启动服务
python main.py -
打开 http://localhost:8000,表单项会自动填充默认值
方式二:通过页面保存配置
(功能开发中)
- 在页面填写配置信息
- (可选)配置会自动保存到
config.json
安全性建议
⚠️ 重要提示
-
保护 config.json 文件
# 设置文件权限为仅所有者可读写 chmod 600 config.json -
添加到 .gitignore
echo "config.json" >> .gitignore -
使用环境变量(高级)
如果不想在文件中存储敏感信息,可以:
- 使用空字符串作为占位符
- 每次使用时手动填写
示例配置
Kimi (Moonshot) 配置
{
"brain": {
"username": "your_email@example.com",
"password": "your_password"
},
"llm": {
"api_key": "sk-xxxxx",
"base_url": "https://api.moonshot.cn/v1",
"model": "kimi-k2.5"
},
"transformer": {
"top_n_datafield": 50,
"data_type": "MATRIX"
}
}
OpenAI 配置
{
"brain": {
"username": "your_email@example.com",
"password": "your_password"
},
"llm": {
"api_key": "sk-xxxxx",
"base_url": "https://api.openai.com/v1",
"model": "gpt-4"
},
"transformer": {
"top_n_datafield": 50,
"data_type": "MATRIX"
}
}
故障排查
配置未生效?
-
检查
config.json文件是否存在ls -la config.json -
检查 JSON 格式是否正确
python -c "import json; json.load(open('config.json'))" -
检查字段是否为空字符串
- 如果字段值为空字符串
"",则不会填充默认值 - 这是为了保护隐私,不想存储某些信息时可以留空
- 如果字段值为空字符串
想清除所有配置?
rm config.json
程序会使用空配置启动,所有字段都需要手动填写。