mistral

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mistral provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.16.2 DO NOT EDIT.

Package mistral provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.16.2 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCreateChatCompletionRequest

func NewCreateChatCompletionRequest(server string, body CreateChatCompletionJSONRequestBody) (*http.Request, error)

NewCreateChatCompletionRequest calls the generic CreateChatCompletion builder with application/json body

func NewCreateChatCompletionRequestWithBody

func NewCreateChatCompletionRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewCreateChatCompletionRequestWithBody generates requests for CreateChatCompletion with any type of body

func NewCreateEmbeddingRequest

func NewCreateEmbeddingRequest(server string, body CreateEmbeddingJSONRequestBody) (*http.Request, error)

NewCreateEmbeddingRequest calls the generic CreateEmbedding builder with application/json body

func NewCreateEmbeddingRequestWithBody

func NewCreateEmbeddingRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewCreateEmbeddingRequestWithBody generates requests for CreateEmbedding with any type of body

func NewListModelsRequest

func NewListModelsRequest(server string) (*http.Request, error)

NewListModelsRequest generates requests for ListModels

Types

type ChatCompletionRequest

type ChatCompletionRequest struct {
	// MaxTokens The maximum number of tokens to generate in the completion.
	//
	// The token count of your prompt plus `max_tokens` cannot exceed the model's context length.
	MaxTokens *int `json:"max_tokens"`

	// Messages The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be `user` or `system`.
	Messages []struct {
		Content *string                            `json:"content,omitempty"`
		Role    *ChatCompletionRequestMessagesRole `json:"role,omitempty"`
	} `json:"messages"`

	// Model ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions.
	Model string `json:"model"`

	// RandomSeed The seed to use for random sampling. If set, different calls will generate deterministic results.
	RandomSeed *int `json:"random_seed,omitempty"`

	// SafeMode Whether to inject a safety prompt before all conversations.
	SafeMode *bool `json:"safe_mode,omitempty"`

	// Stream Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
	Stream *bool `json:"stream"`

	// Temperature What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
	//
	// We generally recommend altering this or `top_p` but not both.
	Temperature *float32 `json:"temperature"`

	// TopP Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or `temperature` but not both.
	TopP *float32 `json:"top_p"`
}

ChatCompletionRequest defines model for ChatCompletionRequest.

type ChatCompletionRequestMessagesRole

type ChatCompletionRequestMessagesRole string

ChatCompletionRequestMessagesRole defines model for ChatCompletionRequest.Messages.Role.

const (
	ChatCompletionRequestMessagesRoleAssistant ChatCompletionRequestMessagesRole = "assistant"
	ChatCompletionRequestMessagesRoleSystem    ChatCompletionRequestMessagesRole = "system"
	ChatCompletionRequestMessagesRoleUser      ChatCompletionRequestMessagesRole = "user"
)

Defines values for ChatCompletionRequestMessagesRole.

type ChatCompletionResponse

type ChatCompletionResponse struct {
	Choices *[]struct {
		FinishReason ChatCompletionResponseChoicesFinishReason `json:"finish_reason"`
		Index        int                                       `json:"index"`
		Message      *struct {
			Content *string                                   `json:"content,omitempty"`
			Role    *ChatCompletionResponseChoicesMessageRole `json:"role,omitempty"`
		} `json:"message,omitempty"`
	} `json:"choices,omitempty"`
	Created *int    `json:"created,omitempty"`
	Id      *string `json:"id,omitempty"`
	Model   *string `json:"model,omitempty"`
	Object  *string `json:"object,omitempty"`
	Usage   *struct {
		CompletionTokens int `json:"completion_tokens"`
		PromptTokens     int `json:"prompt_tokens"`
		TotalTokens      int `json:"total_tokens"`
	} `json:"usage,omitempty"`
}

ChatCompletionResponse defines model for ChatCompletionResponse.

type ChatCompletionResponseChoicesFinishReason

type ChatCompletionResponseChoicesFinishReason string

ChatCompletionResponseChoicesFinishReason defines model for ChatCompletionResponse.Choices.FinishReason.

Defines values for ChatCompletionResponseChoicesFinishReason.

type ChatCompletionResponseChoicesMessageRole

type ChatCompletionResponseChoicesMessageRole string

ChatCompletionResponseChoicesMessageRole defines model for ChatCompletionResponse.Choices.Message.Role.

const (
	ChatCompletionResponseChoicesMessageRoleAssistant ChatCompletionResponseChoicesMessageRole = "assistant"
	ChatCompletionResponseChoicesMessageRoleUser      ChatCompletionResponseChoicesMessageRole = "user"
)

Defines values for ChatCompletionResponseChoicesMessageRole.

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) CreateChatCompletion

func (c *Client) CreateChatCompletion(ctx context.Context, body CreateChatCompletionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) CreateChatCompletionWithBody

func (c *Client) CreateChatCompletionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) CreateEmbedding

func (c *Client) CreateEmbedding(ctx context.Context, body CreateEmbeddingJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) CreateEmbeddingWithBody

func (c *Client) CreateEmbeddingWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// CreateChatCompletionWithBody request with any body
	CreateChatCompletionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	CreateChatCompletion(ctx context.Context, body CreateChatCompletionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// CreateEmbeddingWithBody request with any body
	CreateEmbeddingWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	CreateEmbedding(ctx context.Context, body CreateEmbeddingJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ListModels request
	ListModels(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) CreateChatCompletionWithBodyWithResponse

func (c *ClientWithResponses) CreateChatCompletionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateChatCompletionResponse, error)

CreateChatCompletionWithBodyWithResponse request with arbitrary body returning *CreateChatCompletionResponse

func (*ClientWithResponses) CreateChatCompletionWithResponse

func (c *ClientWithResponses) CreateChatCompletionWithResponse(ctx context.Context, body CreateChatCompletionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateChatCompletionResponse, error)

func (*ClientWithResponses) CreateEmbeddingWithBodyWithResponse

func (c *ClientWithResponses) CreateEmbeddingWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateEmbeddingResponse, error)

CreateEmbeddingWithBodyWithResponse request with arbitrary body returning *CreateEmbeddingResponse

func (*ClientWithResponses) CreateEmbeddingWithResponse

func (c *ClientWithResponses) CreateEmbeddingWithResponse(ctx context.Context, body CreateEmbeddingJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateEmbeddingResponse, error)

func (*ClientWithResponses) ListModelsWithResponse

func (c *ClientWithResponses) ListModelsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListModelsResponse, error)

ListModelsWithResponse request returning *ListModelsResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// CreateChatCompletionWithBodyWithResponse request with any body
	CreateChatCompletionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateChatCompletionResponse, error)

	CreateChatCompletionWithResponse(ctx context.Context, body CreateChatCompletionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateChatCompletionResponse, error)

	// CreateEmbeddingWithBodyWithResponse request with any body
	CreateEmbeddingWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateEmbeddingResponse, error)

	CreateEmbeddingWithResponse(ctx context.Context, body CreateEmbeddingJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateEmbeddingResponse, error)

	// ListModelsWithResponse request
	ListModelsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListModelsResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type CreateChatCompletionJSONRequestBody

type CreateChatCompletionJSONRequestBody = ChatCompletionRequest

CreateChatCompletionJSONRequestBody defines body for CreateChatCompletion for application/json ContentType.

type CreateChatCompletionResponse

type CreateChatCompletionResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *ChatCompletionResponse
}

func ParseCreateChatCompletionResponse

func ParseCreateChatCompletionResponse(rsp *http.Response) (*CreateChatCompletionResponse, error)

ParseCreateChatCompletionResponse parses an HTTP response from a CreateChatCompletionWithResponse call

func (CreateChatCompletionResponse) Status

Status returns HTTPResponse.Status

func (CreateChatCompletionResponse) StatusCode

func (r CreateChatCompletionResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type CreateEmbeddingJSONRequestBody

type CreateEmbeddingJSONRequestBody = EmbeddingRequest

CreateEmbeddingJSONRequestBody defines body for CreateEmbedding for application/json ContentType.

type CreateEmbeddingResponse

type CreateEmbeddingResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *EmbeddingResponse
}

func ParseCreateEmbeddingResponse

func ParseCreateEmbeddingResponse(rsp *http.Response) (*CreateEmbeddingResponse, error)

ParseCreateEmbeddingResponse parses an HTTP response from a CreateEmbeddingWithResponse call

func (CreateEmbeddingResponse) Status

func (r CreateEmbeddingResponse) Status() string

Status returns HTTPResponse.Status

func (CreateEmbeddingResponse) StatusCode

func (r CreateEmbeddingResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type EmbeddingRequest

type EmbeddingRequest struct {
	// EncodingFormat The format of the output data.
	EncodingFormat *EmbeddingRequestEncodingFormat `json:"encoding_format,omitempty"`

	// Input The list of strings to embed.
	Input *[]string `json:"input,omitempty"`

	// Model The ID of the model to use for this request.
	Model *string `json:"model,omitempty"`
}

EmbeddingRequest defines model for EmbeddingRequest.

type EmbeddingRequestEncodingFormat

type EmbeddingRequestEncodingFormat string

EmbeddingRequestEncodingFormat The format of the output data.

const (
	Float EmbeddingRequestEncodingFormat = "float"
)

Defines values for EmbeddingRequestEncodingFormat.

type EmbeddingResponse

type EmbeddingResponse struct {
	Data []struct {
		Embedding *[]float32 `json:"embedding,omitempty"`
		Index     *int       `json:"index,omitempty"`
		Object    *string    `json:"object,omitempty"`
	} `json:"data"`
	Id     string `json:"id"`
	Model  string `json:"model"`
	Object string `json:"object"`
	Usage  struct {
		PromptTokens int `json:"prompt_tokens"`
		TotalTokens  int `json:"total_tokens"`
	} `json:"usage"`
}

EmbeddingResponse defines model for EmbeddingResponse.

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type ListModelsResponse

type ListModelsResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *ModelList
}

func ParseListModelsResponse

func ParseListModelsResponse(rsp *http.Response) (*ListModelsResponse, error)

ParseListModelsResponse parses an HTTP response from a ListModelsWithResponse call

func (ListModelsResponse) Status

func (r ListModelsResponse) Status() string

Status returns HTTPResponse.Status

func (ListModelsResponse) StatusCode

func (r ListModelsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Model

type Model struct {
	Created int    `json:"created"`
	Id      string `json:"id"`
	Object  string `json:"object"`
	OwnedBy string `json:"owned_by"`
}

Model defines model for Model.

type ModelList

type ModelList struct {
	Data   []Model `json:"data"`
	Object string  `json:"object"`
}

ModelList defines model for ModelList.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

Jump to

Keyboard shortcuts

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