Documentation
¶
Overview ¶
Package kimi is the provider-native Kimi (Moonshot) model adapter: an agentcore.ChatModel (llm.LLM) backed by Kimi's chat-completions API. Kimi's own API is OpenAI-shaped, so a plain net/http client IS native here, not a compatibility shim layered over a different provider, and it needs no SDK.
It is the anti-corruption layer between Kimi's wire format and agentcore types, so consumers never see a vendor type. Full scope: real SSE token streaming and tool calling, so kimi-k3 works as a primary conversational model. Kimi-specific extensions beyond standard OpenAI are wired too:
- reasoning_effort (kimi-k3 thinking), mapped from the call's thinking level, with the model's reasoning_content surfaced as an agentcore thinking block,
- partial mode (prefix continuation), triggered by "partial": true metadata on a trailing assistant message,
- EstimateTokens, over Kimi's /tokenizers/estimate-token-count endpoint.
Index ¶
- type Adapter
- func (a *Adapter) EstimateTokens(ctx context.Context, msgs []ac.Message) (int, error)
- func (a *Adapter) Generate(ctx context.Context, msgs []ac.Message, tools []ac.ToolSpec, ...) (*ac.LLMResponse, error)
- func (a *Adapter) GenerateStream(ctx context.Context, msgs []ac.Message, tools []ac.ToolSpec, ...) (<-chan ac.StreamEvent, error)
- func (a *Adapter) ProviderName() string
- func (a *Adapter) SupportsTools() bool
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter wraps Kimi's chat-completions API as an llm.LLM.
func (*Adapter) EstimateTokens ¶
EstimateTokens returns Kimi's server-side token estimate for the given messages under this adapter's model, via /tokenizers/estimate-token-count. Useful for pre-flight budgeting; it is not part of the llm.LLM port.
func (*Adapter) Generate ¶
func (a *Adapter) Generate(ctx context.Context, msgs []ac.Message, tools []ac.ToolSpec, opts ...ac.CallOption) (*ac.LLMResponse, error)
Generate runs a one-shot chat completion.
func (*Adapter) GenerateStream ¶
func (a *Adapter) GenerateStream(ctx context.Context, msgs []ac.Message, tools []ac.ToolSpec, opts ...ac.CallOption) (<-chan ac.StreamEvent, error)
GenerateStream runs a streaming chat completion, emitting the agentcore StreamEvent sequence the loop expects: thinking/text start-delta-end, tool-call start/delta/end with the completed call, a terminal done event carrying the fully assembled message + stop reason, and an error event on failure. reasoning_content deltas become thinking events.
func (*Adapter) ProviderName ¶
ProviderName implements agentcore.ProviderNamer.
func (*Adapter) SupportsTools ¶
SupportsTools reports true: this adapter wires OpenAI-format tool calling.
type Config ¶
type Config struct {
APIKey string
Model string // e.g. "kimi-k3"
BaseURL string
// Meter, if set, receives token/latency Usage for every call.
Meter llm.Meter
// Temperature and TopP are optional sampler params. nil leaves them off the
// wire (the model's own default). Set by a per-model profile.
Temperature *float64
TopP *float64
}
Config configures the adapter. APIKey and Model are required; BaseURL defaults to Kimi's public endpoint (e.g. override for a gateway).