mistral

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

Mistral API Client

This package provides a client for Mistral API, which is used to interact with the Mistral LLM models.

References:

Documentation

Overview

mistral implements an API client for mistral (https://docs.mistral.ai/api/)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback added in v1.0.4

type Callback func(schema.MessageChoice)

Callback when new stream data is received

type Client

type Client struct {
	*client.Client
}

func New

func New(ApiKey string, opts ...client.ClientOpt) (*Client, error)

Create a new client

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, messages []*schema.Message, opts ...Opt) ([]*schema.Content, error)

Chat creates a model response for the given chat conversation.

func (*Client) CreateEmbedding

func (c *Client) CreateEmbedding(content any, opts ...Opt) (schema.Embeddings, error)

CreateEmbedding creates an embedding from a string or array of strings

func (*Client) ListModels

func (c *Client) ListModels() ([]Model, error)

ListModels returns all the models

type Opt added in v1.0.4

type Opt func(*options) error

Opt is a function which can be used to set options on a request

func OptEncodingFormat added in v1.0.4

func OptEncodingFormat(v string) Opt

Set the embedding encoding format

func OptMaxTokens added in v1.0.4

func OptMaxTokens(v int) Opt

Set the maximum number of tokens

func OptModel added in v1.0.4

func OptModel(v string) Opt

Set the model

func OptSafePrompt added in v1.0.4

func OptSafePrompt() Opt

Inject a safety prompt before all conversations.

func OptSeed added in v1.0.4

func OptSeed(v int) Opt

The seed to use for random sampling. If set, different calls will generate deterministic results.

func OptStream added in v1.0.4

func OptStream(fn Callback) Opt

Set streaming response

func OptTemperature added in v1.0.4

func OptTemperature(v float32) Opt

Amount of randomness injected into the response.

func OptTool added in v1.0.6

func OptTool(value ...*schema.Tool) Opt

A list of tools the model may call.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL