Documentation
¶
Overview ¶
mistral implements an API client for mistral (https://docs.mistral.ai/api/)
Index ¶
- func WithPrediction(v string) llm.Opt
- type Client
- func (mistral *Client) ChatCompletion(ctx context.Context, context llm.Context, opts ...llm.Opt) (*Response, error)
- func (mistral *Client) GenerateEmbedding(ctx context.Context, name string, prompt []string, _ ...llm.Opt) (*embeddings, error)
- func (c *Client) ListModels(ctx context.Context) ([]llm.Model, error)
- func (c *Client) Model(ctx context.Context, name string) llm.Model
- func (c *Client) Models(ctx context.Context) ([]llm.Model, error)
- func (Client) Name() string
- type Completion
- type Completions
- type Content
- type Embedding
- type Embeddings
- type Image
- type Message
- type Metrics
- type Model
- type Prediction
- type Response
- type RoleContent
- type Text
- type ToolCall
- type ToolCallArray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithPrediction ¶
func WithPrediction(v string) llm.Opt
Types ¶
type Client ¶
type Client struct {
*client.Client
// contains filtered or unexported fields
}
func (*Client) ChatCompletion ¶
func (*Client) GenerateEmbedding ¶
func (*Client) ListModels ¶
ListModels returns all the models
type Completion ¶
type Completion struct {
Index uint64 `json:"index"`
Message *Message `json:"message"`
Delta *Message `json:"delta,omitempty"` // For streaming
Reason string `json:"finish_reason,omitempty"`
}
Completion Variation
type Completions ¶
type Completions []Completion
Possible completions
func (Completions) Message ¶
func (c Completions) Message(index int) *Message
Return message for a specific completion
func (Completions) Text ¶
func (c Completions) Text(index int) string
Return the text content for a specific completion
func (Completions) ToolCalls ¶
func (c Completions) ToolCalls(index int) []llm.ToolCall
Return the current session tool calls given the completion index. Will return nil if no tool calls were returned.
type Content ¶
type Content struct {
Type string `json:"type,omitempty"` // text, reference, image_url
*Text `json:"text,omitempty"` // text content
*Prediction `json:"content,omitempty"` // prediction
*Image `json:"image_url,omitempty"` // image_url
}
func NewContent ¶
Return a Content object with text content (either in "text" or "prediction" field)
func NewImageAttachment ¶
func NewImageAttachment(a *llm.Attachment) *Content
Return an image attachment
func NewTextContent ¶
Return a Content object with text content
type Embedding ¶
type Embedding struct {
Type string `json:"object"`
Index uint64 `json:"index"`
Vector []float64 `json:"embedding"`
}
Embedding is a single vector
func (Embedding) MarshalJSON ¶
type Embeddings ¶
type Embeddings struct {
Id string `json:"id"`
Type string `json:"object"`
Model string `json:"model"`
Data []Embedding `json:"data"`
Metrics
}
Embeddings is the metadata for a generated embedding vector
type Image ¶
type Image string
either a URL or "data:image/png;base64," followed by the base64 encoded image
type Message ¶
type Message struct {
RoleContent
ToolCallArray `json:"tool_calls,omitempty"`
}
Message with text or object content
type Metrics ¶
type Metrics struct {
InputTokens uint64 `json:"prompt_tokens,omitempty"`
OutputTokens uint `json:"completion_tokens,omitempty"`
TotalTokens uint `json:"total_tokens,omitempty"`
}
Metrics
type Model ¶
type Model struct {
Name string `json:"id"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
CreatedAt *uint64 `json:"created,omitempty"`
OwnedBy string `json:"owned_by,omitempty"`
MaxContextLength uint64 `json:"max_context_length,omitempty"`
Aliases []string `json:"aliases,omitempty"`
Deprecation *string `json:"deprecation,omitempty"`
DefaultModelTemperature *float64 `json:"default_model_temperature,omitempty"`
Capabilities struct {
CompletionChat bool `json:"completion_chat,omitempty"`
CompletionFim bool `json:"completion_fim,omitempty"`
FunctionCalling bool `json:"function_calling,omitempty"`
FineTuning bool `json:"fine_tuning,omitempty"`
Vision bool `json:"vision,omitempty"`
} `json:"capabilities,omitempty"`
}
type Response ¶
type Response struct {
Id string `json:"id"`
Type string `json:"object"`
Created uint64 `json:"created"`
Model string `json:"model"`
Completions `json:"choices"`
Metrics `json:"usage,omitempty"`
}
Chat Completion Response
type RoleContent ¶
type RoleContent struct {
Role string `json:"role,omitempty"` // assistant, user, tool, system
Content any `json:"content,omitempty"` // string or array of text, reference, image_url
Id string `json:"tool_call_id,omitempty"` // tool call - when role is tool
Name string `json:"name,omitempty"` // function name - when role is tool
}