Documentation ¶
Index ¶
- Variables
- type ChatRequest
- type Client
- func (c *Client) Chat(ctx context.Context, params *schemas.ChatParams) (*schemas.ChatResponse, error)
- func (c *Client) ChatStream(_ context.Context, _ *schemas.ChatParams) (clients.ChatStream, error)
- func (c *Client) ModelName() string
- func (c *Client) Provider() string
- func (c *Client) SupportChatStream() bool
- type Config
- type ErrorMapper
- type Params
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) SupportChatStream ¶
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 (*Config) UnmarshalYAML ¶
type ErrorMapper ¶
type ErrorMapper struct {
// contains filtered or unexported fields
}
func NewErrorMapper ¶
func NewErrorMapper(tel *telemetry.Telemetry) *ErrorMapper
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 ¶
Click to show internal directories.
Click to hide internal directories.