Files
mistral-go-sdk/chat/response.go
vikingowl 2b980e14b3 fix: post-review fixes — metadata, unknown types, typed tools, API polish
1. Add README, LICENSE (MIT), .gitignore, Makefile, CHANGELOG
2. Add Version constant and User-Agent header to all requests
3. Rename SetStream to EnableStream (narrower API surface)
4. Fix FinishReason in CompletionStreamChoice to use typed *FinishReason
5. Type conversation entry Content as chat.Content instead of json.RawMessage
6. Graceful unknown type handling — UnknownEntry, UnknownEvent,
   UnknownChunk, UnknownMessage, UnknownAgentTool all return data
   instead of erroring on unrecognized discriminator values
7. Type agent tools with AgentTool sealed interface + UnmarshalAgentTool
8. Add pagination params to ListConversations and ListLibraries
9. Move openapi.yaml to docs/openapi.yaml
2026-03-05 20:51:24 +01:00

51 lines
1.8 KiB
Go

package chat
// CompletionResponse represents a chat completion response.
type CompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Model string `json:"model"`
Created int64 `json:"created"`
Usage UsageInfo `json:"usage"`
Choices []CompletionChoice `json:"choices"`
}
// CompletionChoice represents a single completion choice.
type CompletionChoice struct {
Index int `json:"index"`
Message AssistantMessage `json:"message"`
FinishReason FinishReason `json:"finish_reason"`
}
// UsageInfo contains token usage information.
type UsageInfo struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
PromptAudioSeconds *int `json:"prompt_audio_seconds,omitempty"`
}
// CompletionChunk represents a streaming completion chunk.
type CompletionChunk struct {
ID string `json:"id"`
Object string `json:"object,omitempty"`
Model string `json:"model"`
Created int64 `json:"created,omitempty"`
Usage *UsageInfo `json:"usage,omitempty"`
Choices []CompletionStreamChoice `json:"choices"`
}
// CompletionStreamChoice represents a streaming completion choice.
type CompletionStreamChoice struct {
Index int `json:"index"`
Delta DeltaMessage `json:"delta"`
FinishReason *FinishReason `json:"finish_reason"`
}
// DeltaMessage represents a partial message in a streaming response.
type DeltaMessage struct {
Role string `json:"role,omitempty"`
Content Content `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}