octoml

package
v0.0.0-...-df6d72d Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyResponse = errors.New("empty response")
)

ErrEmptyResponse is returned when the OctoML API returns an empty response.

Functions

This section is empty.

Types

type ChatRequest

type ChatRequest struct {
	Model            string                `json:"model"`
	Messages         []schemas.ChatMessage `json:"messages"`
	Temperature      float64               `json:"temperature,omitempty"`
	TopP             float64               `json:"top_p,omitempty"`
	MaxTokens        int                   `json:"max_tokens,omitempty"`
	StopWords        []string              `json:"stop,omitempty"`
	Stream           bool                  `json:"stream,omitempty"`
	FrequencyPenalty int                   `json:"frequency_penalty,omitempty"`
	PresencePenalty  int                   `json:"presence_penalty,omitempty"`
}

ChatRequest is an octoml-specific request schema

func NewChatRequestFromConfig

func NewChatRequestFromConfig(cfg *Config) *ChatRequest

NewChatRequestFromConfig fills the struct from the config. Not using reflection because of performance penalty it gives

func (*ChatRequest) ApplyParams

func (r *ChatRequest) ApplyParams(params *schemas.ChatParams)

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for accessing OctoML API

func NewClient

func NewClient(providerConfig *Config, clientConfig *clients.ClientConfig, tel *telemetry.Telemetry) (*Client, error)

NewClient creates a new OctoML client for the OctoML API.

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, params *schemas.ChatParams) (*schemas.ChatResponse, error)

Chat sends a chat request to the specified octoml model.

func (*Client) ChatStream

func (c *Client) ChatStream(_ context.Context, _ *schemas.ChatParams) (clients.ChatStream, error)

func (*Client) ModelName

func (c *Client) ModelName() string

func (*Client) Provider

func (c *Client) Provider() string

func (*Client) SupportChatStream

func (c *Client) SupportChatStream() bool

type Config

type Config struct {
	BaseURL       string        `yaml:"base_url" json:"base_url" validate:"required"`
	ChatEndpoint  string        `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
	ModelName     string        `yaml:"model" json:"model" validate:"required"`
	APIKey        fields.Secret `yaml:"api_key" json:"-" validate:"required"`
	DefaultParams *Params       `yaml:"default_params,omitempty" json:"default_params"`
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig for OctoML models

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

type ErrorMapper

type ErrorMapper struct {
	// contains filtered or unexported fields
}

func NewErrorMapper

func NewErrorMapper(tel *telemetry.Telemetry) *ErrorMapper

func (*ErrorMapper) Map

func (m *ErrorMapper) Map(resp *http.Response) error

type Params

type Params struct {
	Temperature      float64  `yaml:"temperature,omitempty" json:"temperature"`
	TopP             float64  `yaml:"top_p,omitempty" json:"top_p"`
	MaxTokens        int      `yaml:"max_tokens,omitempty" json:"max_tokens"`
	StopWords        []string `yaml:"stop,omitempty" json:"stop"`
	FrequencyPenalty int      `yaml:"frequency_penalty,omitempty" json:"frequency_penalty"`
	PresencePenalty  int      `yaml:"presence_penalty,omitempty" json:"presence_penalty"`
}

Params defines OctoML-specific model params with the specific validation of values TODO: Add validations

func DefaultParams

func DefaultParams() Params

func (*Params) UnmarshalYAML

func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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