Skip to content

Go: add tools for gitee, volcengine and zhipuAI - #17091

Merged
JinHai-CN merged 7 commits into
infiniflow:mainfrom
Haruko386:master
Jul 20, 2026
Merged

JinHai-CN merged 7 commits into
infiniflow:mainfrom
Haruko386:master

Conversation

@Haruko386

Copy link
Copy Markdown
Member

Summary

As title

@Haruko386 Haruko386 added the ci Continue Integration label Jul 20, 2026
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jul 20, 2026
@Haruko386
Haruko386 marked this pull request as draft July 20, 2026 06:01
@Haruko386
Haruko386 marked this pull request as ready for review July 20, 2026 06:01
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ec7cbba2-36e7-46e0-8a91-5fcca38b06d1

📥 Commits

Reviewing files that changed from the base of the PR and between 6f089a0 and faf008b.

📒 Files selected for processing (3)
  • internal/entity/models/gitee.go
  • internal/entity/models/volcengine.go
  • internal/entity/models/zhipu-ai.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/entity/models/volcengine.go
  • internal/entity/models/gitee.go

📝 Walkthrough

Walkthrough

Gitee, VolcEngine, and Zhipu chat models now serialize tool calls, accept tool configuration, parse non-streaming tool-call responses, and collect streamed tool-call fragments. Zhipu adds SSE integration coverage, while comments are clarified in model types and handler code.

Changes

Tool-call support across chat providers

Layer / File(s) Summary
Tool-call request and response wiring
internal/entity/models/gitee.go, internal/entity/models/volcengine.go, internal/entity/models/zhipu-ai.go
Provider requests now carry tool-related message fields and configuration, and non-streaming responses populate returned tool calls. VolcEngine also supports xhigh reasoning effort and conditional generation parameters.
Streaming tool-call aggregation
internal/entity/models/gitee.go, internal/entity/models/volcengine.go, internal/entity/models/zhipu-ai.go
Streaming requests use configured options, SSE tool-call fragments are merged by index, and ordered results are stored after stream completion.
Streaming validation and documentation
internal/entity/models/zhipu_ai_test.go, internal/entity/models/types.go, internal/handler/models.go
A mocked Zhipu SSE test verifies tool-call and usage collection, and model and handler documentation comments are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: 💞 feature, go

Suggested reviewers: jinhai-cn, dexterity104

Poem

A rabbit hops through tool-call streams,
Merging fragments into dreams.
Names and arguments, neatly spun,
Sorted when the stream is done.
“Nibble on!” the bunny cheers.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description only says 'As title' and lacks the required summary detail and background context. Expand the Summary with the problem, purpose, and a brief explanation of the tool-call changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is clear and matches the main change: adding tool support for Gitee, Volcengine, and ZhipuAI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (1)
internal/entity/models/gitee.go (1)

412-417: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Concatenating id across fragments can corrupt the tool-call id.

OpenAI-style streaming emits id only in the first fragment, but if an upstream ever repeats it, existing["id"] = eid + id yields e.g. call-1call-1. id should be set-once, not concatenated (unlike arguments). Same pattern exists in volcengine.go and zhipu-ai.go.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/gitee.go` around lines 412 - 417, Update the tool-call
fragment merging logic in gitee.go so the `id` field is set only when no
existing ID is present, never concatenated across fragments. Apply the same
set-once behavior to the corresponding tool-call merge logic in volcengine.go
and zhipu-ai.go, while preserving argument concatenation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/entity/models/gitee.go`:
- Around line 212-229: Update the non-streaming response parsing in the
content-extraction logic of internal/entity/models/gitee.go (site 212-229) and
internal/entity/models/volcengine.go (site 226-233) so missing or non-string
message content defaults to an empty string instead of returning an error;
preserve the existing tool_calls extraction so tool-only responses populate
ToolCalls in both drivers.
- Around line 128-131: Forward chatModelConfig.ToolChoice in the Gitee request
body wherever chatModelConfig.Tools is forwarded, including both non-streaming
and streaming request construction paths. Preserve the existing conditional
handling and use the same request key expected by the other providers.

In `@internal/entity/models/types.go`:
- Line 69: Update the documentation comment for the TokenUsage type to remove
the stale “ChatUsage” name, so the comment begins with “TokenUsage” and
accurately describes the current type.

In `@internal/entity/models/volcengine.go`:
- Around line 320-343: Update the streaming effort switch in the
request-building logic to handle "xhigh" consistently with the non-streaming
switch, enabling it with the appropriate reasoning_effort value. Keep existing
handling for all other effort levels and avoid routing "xhigh" to the
invalid-effort default.

In `@internal/entity/models/zhipu-ai.go`:
- Around line 485-488: In the OpenAI-compatible end-of-stream block, replace the
invalid new("[DONE]") expression with a string variable initialized to "[DONE]"
and pass its pointer to sender. Preserve the existing error return behavior in
the surrounding stream completion logic.

In `@internal/handler/models.go`:
- Around line 27-32: Update the GoDoc comments for ModelHandler and
NewModelHandler to start with their current symbol names and describe the model
handler directly; remove the stale ProviderHandler and NewProviderHandler
references without changing the implementation.

---

Nitpick comments:
In `@internal/entity/models/gitee.go`:
- Around line 412-417: Update the tool-call fragment merging logic in gitee.go
so the `id` field is set only when no existing ID is present, never concatenated
across fragments. Apply the same set-once behavior to the corresponding
tool-call merge logic in volcengine.go and zhipu-ai.go, while preserving
argument concatenation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d91fe8f4-cc36-4494-bce6-8ddc4d83cb7e

📥 Commits

Reviewing files that changed from the base of the PR and between 2e39662 and 3d4accd.

📒 Files selected for processing (6)
  • internal/entity/models/gitee.go
  • internal/entity/models/types.go
  • internal/entity/models/volcengine.go
  • internal/entity/models/zhipu-ai.go
  • internal/entity/models/zhipu_ai_test.go
  • internal/handler/models.go

Comment thread internal/entity/models/gitee.go Resolved
Comment thread internal/entity/models/gitee.go Resolved
Comment thread internal/entity/models/types.go Resolved
Comment thread internal/entity/models/volcengine.go Resolved
Comment thread internal/entity/models/zhipu-ai.go Resolved
Comment thread internal/handler/models.go Resolved
Haruko386 and others added 5 commits July 20, 2026 14:11
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, forget to push

Comment thread internal/entity/models/gitee.go Resolved
@JinHai-CN
JinHai-CN merged commit 0cd06e4 into infiniflow:main Jul 20, 2026
3 checks passed
@Haruko386
Haruko386 deleted the master branch July 21, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants