Files
mistral-go-sdk/agents/request.go
vikingowl 07505b333f feat: Phase 3 core completions — FIM, Agents, Embeddings
Add FIM, Agents, and Embedding endpoints:
- fim/request.go: FIMCompletionRequest (prompt/suffix model)
- agents/request.go: AgentsCompletionRequest (agent_id + messages)
- embedding/embedding.go: Request/Response/Data types with dtype/encoding
- FIMComplete, FIMCompleteStream, AgentsComplete, AgentsCompleteStream,
  CreateEmbeddings service methods
- All reuse chat.CompletionResponse/CompletionChunk for responses
- 11 new httptest-based tests
2026-03-05 19:36:49 +01:00

46 lines
1.8 KiB
Go

package agents
import (
"encoding/json"
"somegit.dev/vikingowl/mistral-go-sdk/chat"
)
// CompletionRequest represents an agents completion request.
type CompletionRequest struct {
AgentID string `json:"agent_id"`
Messages []chat.Message `json:"-"`
MaxTokens *int `json:"max_tokens,omitempty"`
Stop []string `json:"stop,omitempty"`
RandomSeed *int `json:"random_seed,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
ResponseFormat *chat.ResponseFormat `json:"response_format,omitempty"`
Tools []chat.Tool `json:"tools,omitempty"`
ToolChoice *chat.ToolChoice `json:"tool_choice,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
N *int `json:"n,omitempty"`
ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Prediction *chat.Prediction `json:"prediction,omitempty"`
PromptMode *chat.PromptMode `json:"prompt_mode,omitempty"`
stream bool
}
// SetStream is used internally to set the stream field.
func (r *CompletionRequest) SetStream(v bool) { r.stream = v }
func (r *CompletionRequest) MarshalJSON() ([]byte, error) {
type Alias CompletionRequest
return json.Marshal(&struct {
Messages []chat.Message `json:"messages"`
Stream bool `json:"stream"`
*Alias
}{
Messages: r.Messages,
Stream: r.stream,
Alias: (*Alias)(r),
})
}