feat(chat): 完善 Chat Completions 兼容层 #4

Open
chensipeng wants to merge 0 commits from feat/chat-completions-compat into main
Owner

变更

  • 完善 /api/v1/chat/completions OpenAI-compatible SSE 输出,补齐 [DONE]、created、role chunk、usage chunk、finish_reason、tool_calls 与 reasoning_content。
  • 增加 reasoning_details / content 内联推理剥离与工具调用多格式归一化。
  • 支持请求侧格式还原:OpenAI-compatible 消息规整与 Gemini functionCall/functionResponse 映射。
  • 增加 reasoning_effort 开放字符串定义,并同步 OpenAPI、管理端与设计文档。

验证

  • git diff --check
  • go test ./...(apps/api)
  • pnpm --filter @easyai-ai-gateway/web typecheck
## 变更 - 完善 `/api/v1/chat/completions` OpenAI-compatible SSE 输出,补齐 `[DONE]`、created、role chunk、usage chunk、finish_reason、tool_calls 与 reasoning_content。 - 增加 reasoning_details / content 内联推理剥离与工具调用多格式归一化。 - 支持请求侧格式还原:OpenAI-compatible 消息规整与 Gemini functionCall/functionResponse 映射。 - 增加 reasoning_effort 开放字符串定义,并同步 OpenAPI、管理端与设计文档。 ## 验证 - `git diff --check` - `go test ./...`(apps/api) - `pnpm --filter @easyai-ai-gateway/web typecheck`
chensipeng added 1 commit 2026-05-19 17:47:02 +08:00
Author
Owner

可以通过该命令验证可以得到 reasoning_content 增量输出。

curl --request POST \
  --url http://localhost:8088/api/v1/chat/completions \
  --header 'authorization: Bearer sk-key' \
  --header 'content-type: application/json' \
  --data '{
  "max_tokens": 512,
  "messages": [
    {
      "content": "Hello",
      "role": "user"
    }
  ],
  "model": "Doubao Seed 2.0 Lite",
  "stream": true
}'
可以通过该命令验证可以得到 reasoning_content 增量输出。 ```bash curl --request POST \ --url http://localhost:8088/api/v1/chat/completions \ --header 'authorization: Bearer sk-key' \ --header 'content-type: application/json' \ --data '{ "max_tokens": 512, "messages": [ { "content": "Hello", "role": "user" } ], "model": "Doubao Seed 2.0 Lite", "stream": true }' ```
chensipeng requested review from wangbo 2026-05-19 17:51:40 +08:00
chensipeng removed review request for wangbo 2026-05-19 17:55:32 +08:00
This branch is already included in the target branch. There is nothing to merge.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/chat-completions-compat:feat/chat-completions-compat
git checkout feat/chat-completions-compat
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: BCAI/easyai-ai-gateway#4
No description provided.