fix: content=None 导致 TypeError + /v1/models 本地返回
This commit is contained in:
1 parent
29d6fac6cc
commit
2b073f2e3f
1 file changed
+10
-1
+10
-1
@@ -306,7 +306,7 @@ def auto_compact(raw_body, real_token, orig_request):
|
||||
MAX_MSG_CHARS = 500
|
||||
truncated_msgs = []
|
||||
for m in convo_msgs:
|
||||
content = m.get('content', '')
|
||||
content = m.get('content', '') or ''
|
||||
if len(content) > MAX_MSG_CHARS:
|
||||
truncated_msgs.append({**m, 'content': content[:MAX_MSG_CHARS] + '...[截断]'})
|
||||
else:
|
||||
@@ -816,6 +816,15 @@ def proxy(subpath):
|
||||
|
||||
target_url = f'https://{TARGET_HOST}/v2/{subpath}'
|
||||
|
||||
# ============ /models 请求直接返回,不转发上游 ============
|
||||
if subpath in ('models', 'models/'):
|
||||
return {
|
||||
"object": "list",
|
||||
"data": [
|
||||
{"id": "glm-5.1", "object": "model", "owned": "zhipu"},
|
||||
]
|
||||
}
|
||||
|
||||
# ============ 请求体处理:大小校验 + 动态超时 ============
|
||||
raw_body = request.get_data()
|
||||
body_size = len(raw_body)
|
||||
|
||||
Reference in new issue
Block a user