Files
SI_KG_2026_PlanningLaw/dofile/graphrag_pipeline/ENV_SETUP.md
T

1.6 KiB

环境变量配置说明

创建 .env 文件

dofile 目录下创建 .env 文件,添加以下配置:

# LLM API Keys
OPENAI_API_KEY=your_openai_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here
DASHSCOPE_API_KEY=your_dashscope_api_key_here
VOLCENGINE_ACCESS_KEY=your_volcengine_access_key_here
VOLCENGINE_SECRET_KEY=your_volcengine_secret_key_here
ZHIPUAI_API_KEY=your_zhipuai_api_key_here

# SiliconFlow API配置(硅基流动)
SILICONFLOW_API_KEY=sk-pvvtosiglncktlucwarxilvsypqcttqizgpcfdvodgcuaezn
SILICONFLOW_API_BASE=https://api.siliconflow.cn/v1

# 路径配置
DATA_DIR=../data
OUTPUT_DIR=./output

# 日志配置
LOG_LEVEL=INFO

# HanLP配置(可选)
HANLP_MODEL_PATH=

# LLM配置
TEMPERATURE=0.4
FREQUENCY_PENALTY=0.6
PRESENCE_PENALTY=0.6

# 文本处理配置
MAX_TEXTUNIT_LENGTH=500

硅基流动配置

硅基流动的API已经配置完成,您可以使用以下方式调用:

from src.utils.llm_client import LLMClient, LLMProvider
from src.utils.config import load_config

config = load_config()
client = LLMClient(
    provider=LLMProvider.SILICONFLOW,
    model="你的模型名称",  # 例如:Qwen/Qwen2.5-72B-Instruct
    config=config
)

messages = [
    {"role": "user", "content": "你好"}
]
response = client.chat(messages)
print(response)

支持的模型

硅基流动支持多种模型,常用的包括:

  • Qwen/Qwen2.5-72B-Instruct
  • meta-llama/Llama-3.1-70B-Instruct
  • 01-ai/Yi-1.5-34B-Chat
  • 等等...

具体可用模型请查看硅基流动官网:https://siliconflow.cn/