Documentation
¶
Overview ¶
mistral implements an API client for mistral https://docs.mistral.ai/api/
Index ¶
- type Client
- func (mistral *Client) DeleteModel(ctx context.Context, model string) error
- func (mistral *Client) GenerateEmbedding(ctx context.Context, name string, prompt []string, _ ...llm.Opt) (*embeddings, error)
- func (mistral *Client) GetModel(ctx context.Context, model string) (*Model, error)
- func (mistral *Client) ListModels(ctx context.Context) ([]Model, error)
- func (mistral *Client) Model(ctx context.Context, name string) llm.Model
- func (mistral *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 ToolCalls
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *client.Client *impl.ModelCache }
func (*Client) DeleteModel ¶ added in v0.0.6
Delete a fine-tuned model
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
func (Completion) String ¶ added in v0.0.6
func (c Completion) String() string
type Completions ¶
type Completions []Completion
Possible completions
func (Completions) Attachment ¶ added in v0.0.10
func (c Completions) Attachment(index int) *llm.Attachment
Return audio content for a specific completion
func (Completions) Choice ¶ added in v0.0.6
func (c Completions) Choice(index int) llm.Completion
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"` // text or content *Text `json:"text,omitempty"` // text content *Prediction `json:"content,omitempty"` // prediction *Image `json:"image_url,omitempty"` // image_url }
func NewImageData ¶ added in v0.0.6
func NewImageData(image *llm.Attachment) *Content
func NewImageUrl ¶ added in v0.0.6
func NewPrediction ¶ added in v0.0.6
func NewPrediction(content Prediction) *Content
func NewTextContext ¶ added in v0.0.6
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 Calls ToolCalls `json:"tool_calls,omitempty"` }
Message with text or object content
func (*Message) Attachment ¶ added in v0.0.10
Unsupported
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 Name string `json:"name,omitempty"` // function name - when role is tool Id string `json:"tool_call_id,omitempty"` // tool call - when role is tool }
type ToolCall ¶
type ToolCall struct { Id string `json:"id,omitempty"` // tool id Type string `json:"type,omitempty"` // tool type (function) Index uint64 `json:"index,omitempty"` // tool index Function struct { Name string `json:"name,omitempty"` // tool name Arguments string `json:"arguments,omitempty"` // tool arguments } `json:"function"` }