feat(moonshot): add Moonshot (Kimi) ChatModel implementation#817
Open
Narizis wants to merge 3 commits into
Open
feat(moonshot): add Moonshot (Kimi) ChatModel implementation#817Narizis wants to merge 3 commits into
Narizis wants to merge 3 commits into
Conversation
Thin wrapper over libs/acl/openai exposing the Moonshot OpenAI-compatible endpoint. Supports Generate / Stream / tool calling / JSON mode, and provides WithExtraFields / WithExtraHeader as an escape hatch for Moonshot-specific parameters (e.g. partial, context_cache).
Required by the repo's compliant CI check for newly added components.
…ation and options
Author
|
@shentongmartin @JonXSnow could you take a look when you have a chance? |
Contributor
@Narizis What's the difference between this and the OpenAI ChatModel? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
components/model/moonshotpackage that implementsmodel.ToolCallingChatModelfor Moonshot AI (Kimi) via its OpenAI-compatible API.The implementation is a thin wrapper over
libs/acl/openai(same shape ascomponents/model/qwen):BaseURLset tohttps://api.moonshot.cn/v1.Generate/Stream/WithTools/BindTools/BindForcedToolsforwarded to the shared OpenAI client.ChatModelConfig(model, max_tokens, temperature, top_p, stop, presence/frequency penalty, response_format, user).partialfor prefix completion,context_cache) can be passed throughWithExtraFields.Test plan
go build ./...andgo vet ./...pass under Go 1.23 insidecomponents/model/moonshot/.moonshot-v1-8k):Generatereturned a valid completion with usage info (33 prompt + 11 completion tokens).Streamreturned the same content via streaming chunks.moonshot-v1-8k) withWithTools:Generatereturned atool_callsentry with the correct function name and JSON arguments.Streamchunks merged viaschema.ConcatMessagesproduced the sametool_callsentry (noIndex=nilworkaround needed, unlike Qwen / DashScope).schema.Toolmessage produced the expected final assistant reply.