Skip to content

fix: proper Claude model tones, expand model lineup, add auto-context matching - #1

Merged
HEXUXIU merged 3 commits into
HEXUXIU:mainfrom
lezi-fun:main
Jul 6, 2026
Merged

HEXUXIU merged 3 commits into
HEXUXIU:mainfrom
lezi-fun:main

Conversation

@lezi-fun

@lezi-fun lezi-fun commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

改动内容

1. ✅ 修复 Claude 模型路由(核心修复)

之前 claude 模型配置为 tone: "Magic" + override: "Claude_Sonnet",实际走的是 GPT-5 而非 Claude。
已修复为 tone: "Claude_Sonnet",经实测(June 2026)服务器端会路由到真正的 Anthropic Claude Sonnet 4.6。

2. ✅ 扩展模型列表

新增模型 Tone 说明
claude-sonnet Claude_Sonnet 真实 Claude Sonnet 4.6
claude-reasoning Claude_Sonnet_Reasoning Claude + 深度推理
claude-opus Claude_Opus Claude Opus
gpt5.2-reasoning ~ gpt5.5-reasoning Gpt_5_N_Reasoning GPT 各版本推理模式
claude-sonnet-4-20250514 Claude_Sonnet Anthropic API 兼容别名

所有 GPT 模型的 tone 也从 Magic 改为对应的具体 tone(例如 gpt5.5 → Gpt_5_5_Chat),不再依赖 gptIdOverride。

3. ✅ 消息前缀自动上下文匹配

当客户端不传 session_id 时,服务器通过哈希消息历史前缀自动匹配同一对话。
例如客户端连续发送 [m1] → [m1, m2] → [m1, m2, m3] 会自动续传到同一 conversation。

兼容性

  • 向后兼容:所有原有模型名继续可用
  • 移除 gptIdOverride 字段(tone 直接选择模型,更简洁可靠)
  • session_id 显式传入时优先级高于自动匹配

lezi-fun added 3 commits July 5, 2026 12:10
Key changes:

1. models.py - Fix Claude model routing (was using tone=Magic with
   gptIdOverride=Claude_Sonnet, now uses proper Claude_Sonnet tone
   for real Anthropic Claude, verified working June 2026)

   - Claude tones now correctly set: Claude_Sonnet, Claude_Sonnet_Reasoning,
     Claude_Opus
   - Added GPT-5.x reasoning variants (gpt5.2-reasoning through
     gpt5.5-reasoning)
   - Added proper model name aliases for OpenAI/Anthropic compatibility
   - Removed unnecessary gptIdOverride (tone alone selects the model)

2. openai.py - Add message-prefix auto-context matching

   When no session_id is provided by the client, the server now
   automatically matches conversations by hashing the message history
   prefix (all messages except the last). This provides seamless
   multi-turn context without requiring the client to manage session
   IDs - works out of the box with standard OpenAI clients.

   Example: [m1] -> [m1, m2] auto-matches to same conversation
…document auto-context

- Removed '假实现的: Claude 模型标签(前端壳,后端统一走 GPT-5)'
- Updated model descriptions to reflect real Claude Sonnet/Opus support
- Added auto-context matching to features table
- Updated CLI examples to reflect correct model behavior
The previous approach matched on messages[:-1] hash, which would never
match because subsequent turns have more messages. Now uses the first
user message content as the session key - consistent across all turns
in the same conversation.
@HEXUXIU
HEXUXIU merged commit 4d6213c into HEXUXIU:main Jul 6, 2026
HEXUXIU pushed a commit that referenced this pull request Jul 21, 2026
jeck5001 pushed a commit to jeck5001/M365-Copilot2API that referenced this pull request Aug 11, 2026
…e-errors

fix: report API key persistence failures
yorushikasama pushed a commit to yorushikasama/M365-Copilot2API that referenced this pull request Sep 11, 2026
…w-api ordering

Clients that read only the role off SSE chunk HEXUXIU#1 dropped whatever text
shared that chunk, so answers arrived truncated at the very start (a
lost list number, a missing first word). All three chat streaming paths
now declare the role with an empty content chunk and stream text in its
own chunks — the same lazy-first-frame contract as new-api's
ensureStart(). The /v1/responses adapters now emit
response.content_part.added between output_item.added and the first
output_text.delta, matching the OpenAI event sequence, so the opening
delta can no longer land on a part the client never created.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants