ZyphrZero commited on
Commit
7561cf7
·
1 Parent(s): ed184b6

🔧 chore(security): replace hardcoded API key with placeholder

Browse files
Files changed (3) hide show
  1. README.md +4 -4
  2. main.py +1 -1
  3. tests/test_weather.py +1 -1
README.md CHANGED
@@ -52,7 +52,7 @@
52
 
53
  2. 配置服务(可选):
54
  编辑 `main.py` 中的 `ServerConfig` 类以调整服务行为:
55
- - `AUTH_TOKEN`: 客户端 API 密钥
56
  - `API_ENDPOINT`: Z.ai 上游 API 地址
57
  - `BACKUP_TOKEN`: 固定认证 token(匿名模式失败时使用)
58
  - `LISTEN_PORT`: 服务监听端口
@@ -75,7 +75,7 @@
75
  # 初始化客户端
76
  client = openai.OpenAI(
77
  base_url="http://localhost:8080/v1",
78
- api_key="sk-tbkFoKzk9a531YyUNNF5" # 使用配置的 AUTH_TOKEN
79
  )
80
 
81
  # 流式调用示例
@@ -108,7 +108,7 @@ import openai
108
  # 初始化客户端
109
  client = openai.OpenAI(
110
  base_url="http://localhost:8080/v1",
111
- api_key="sk-tbkFoKzk9a531YyUNNF5"
112
  )
113
 
114
  # 定义天气查询工具
@@ -345,7 +345,7 @@ python function_call_demo.py
345
  | 配置项 | 描述 | 默认值 |
346
  |--------|------|--------|
347
  | `API_ENDPOINT` | Z.ai 的上游 API 地址 | `https://chat.z.ai/api/chat/completions` |
348
- | `AUTH_TOKEN` | 下游客户端鉴权 key | `sk-tbkFoKzk9a531YyUNNF5` |
349
  | `BACKUP_TOKEN` | 上游 API 的 token (匿名模式失败时使用) | JWT token |
350
  | `PRIMARY_MODEL` | 默认模型名称 | `GLM-4.5` |
351
  | `THINKING_MODEL` | 思考模型名称 | `GLM-4.5-Thinking` |
 
52
 
53
  2. 配置服务(可选):
54
  编辑 `main.py` 中的 `ServerConfig` 类以调整服务行为:
55
+ - `AUTH_TOKEN`: 客户端 API Key 密钥
56
  - `API_ENDPOINT`: Z.ai 上游 API 地址
57
  - `BACKUP_TOKEN`: 固定认证 token(匿名模式失败时使用)
58
  - `LISTEN_PORT`: 服务监听端口
 
75
  # 初始化客户端
76
  client = openai.OpenAI(
77
  base_url="http://localhost:8080/v1",
78
+ api_key="sk-your-api-key"
79
  )
80
 
81
  # 流式调用示例
 
108
  # 初始化客户端
109
  client = openai.OpenAI(
110
  base_url="http://localhost:8080/v1",
111
+ api_key="sk-your-api-key"
112
  )
113
 
114
  # 定义天气查询工具
 
345
  | 配置项 | 描述 | 默认值 |
346
  |--------|------|--------|
347
  | `API_ENDPOINT` | Z.ai 的上游 API 地址 | `https://chat.z.ai/api/chat/completions` |
348
+ | `AUTH_TOKEN` | 下游客户端鉴权 key | `sk-your-api-key` |
349
  | `BACKUP_TOKEN` | 上游 API 的 token (匿名模式失败时使用) | JWT token |
350
  | `PRIMARY_MODEL` | 默认模型名称 | `GLM-4.5` |
351
  | `THINKING_MODEL` | 思考模型名称 | `GLM-4.5-Thinking` |
main.py CHANGED
@@ -29,7 +29,7 @@ class ServerConfig:
29
 
30
  # API Configuration
31
  API_ENDPOINT: str = "https://chat.z.ai/api/chat/completions"
32
- AUTH_TOKEN: str = "sk-tbkFoKzk9a531YyUNNF5"
33
  BACKUP_TOKEN: str = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjMxNmJjYjQ4LWZmMmYtNGExNS04NTNkLWYyYTI5YjY3ZmYwZiIsImVtYWlsIjoiR3Vlc3QtMTc1NTg0ODU4ODc4OEBndWVzdC5jb20ifQ.PktllDySS3trlyuFpTeIZf-7hl8Qu1qYF3BxjgIul0BrNux2nX9hVzIjthLXKMWAf9V0qM8Vm_iyDqkjPGsaiQ"
34
 
35
  # Model Configuration
 
29
 
30
  # API Configuration
31
  API_ENDPOINT: str = "https://chat.z.ai/api/chat/completions"
32
+ AUTH_TOKEN: str = "sk-your-api-key"
33
  BACKUP_TOKEN: str = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjMxNmJjYjQ4LWZmMmYtNGExNS04NTNkLWYyYTI5YjY3ZmYwZiIsImVtYWlsIjoiR3Vlc3QtMTc1NTg0ODU4ODc4OEBndWVzdC5jb20ifQ.PktllDySS3trlyuFpTeIZf-7hl8Qu1qYF3BxjgIul0BrNux2nX9hVzIjthLXKMWAf9V0qM8Vm_iyDqkjPGsaiQ"
34
 
35
  # Model Configuration
tests/test_weather.py CHANGED
@@ -5,7 +5,7 @@ import requests
5
 
6
  # API 配置
7
  API_BASE = "http://localhost:8080"
8
- API_KEY = "sk-tbkFoKzk9a531YyUNNF5"
9
 
10
  def test_weather_query():
11
  """测试天气查询"""
 
5
 
6
  # API 配置
7
  API_BASE = "http://localhost:8080"
8
+ API_KEY = "sk-your-api-key"
9
 
10
  def test_weather_query():
11
  """测试天气查询"""