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
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
package fim
|
|
|
|
import "encoding/json"
|
|
|
|
// CompletionRequest represents a Fill-In-the-Middle completion request.
|
|
type CompletionRequest struct {
|
|
Model string `json:"model"`
|
|
Prompt string `json:"prompt"`
|
|
Suffix *string `json:"suffix,omitempty"`
|
|
Temperature *float64 `json:"temperature,omitempty"`
|
|
TopP *float64 `json:"top_p,omitempty"`
|
|
MaxTokens *int `json:"max_tokens,omitempty"`
|
|
MinTokens *int `json:"min_tokens,omitempty"`
|
|
Stop []string `json:"stop,omitempty"`
|
|
RandomSeed *int `json:"random_seed,omitempty"`
|
|
Metadata map[string]any `json:"metadata,omitempty"`
|
|
stream bool
|
|
}
|
|
|
|
// EnableStream is used by the mistral package to enable streaming on requests.
|
|
// It is not intended for direct use by consumers.
|
|
func (r *CompletionRequest) EnableStream() { r.stream = true }
|
|
|
|
func (r *CompletionRequest) MarshalJSON() ([]byte, error) {
|
|
type Alias CompletionRequest
|
|
return json.Marshal(&struct {
|
|
Stream bool `json:"stream"`
|
|
*Alias
|
|
}{
|
|
Stream: r.stream,
|
|
Alias: (*Alias)(r),
|
|
})
|
|
}
|