Documentation
¶
Index ¶
- func App(configFile string, loader *model.ModelLoader, ...) *fiber.App
- func Finetune(config Config, input, prediction string) string
- func ImageGeneration(height, width, mode, step, seed int, ...) (func() error, error)
- func ModelEmbedding(s string, tokens []int, loader *model.ModelLoader, c Config) (func() ([]float32, error), error)
- func ModelInference(s string, loader *model.ModelLoader, c Config, tokenCallback func(string) bool) (func() (string, error), error)
- type APIError
- type Choice
- type Config
- type ConfigMerger
- type ErrorResponse
- type Item
- type Message
- type OpenAIModel
- type OpenAIRequest
- type OpenAIResponse
- type OpenAIUsage
- type TemplateConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ImageGeneration ¶ added in v1.12.0
func ModelEmbedding ¶ added in v1.7.0
Types ¶
type APIError ¶ added in v1.3.2
type APIError struct {
Code any `json:"code,omitempty"`
Message string `json:"message"`
Param *string `json:"param,omitempty"`
Type string `json:"type"`
}
APIError provides error information returned by the OpenAI API.
type Choice ¶
type Choice struct {
Index int `json:"index,omitempty"`
FinishReason string `json:"finish_reason,omitempty"`
Message *Message `json:"message,omitempty"`
Delta *Message `json:"delta,omitempty"`
Text string `json:"text,omitempty"`
}
func ComputeChoices ¶ added in v1.5.0
type Config ¶ added in v1.4.0
type Config struct {
OpenAIRequest `yaml:"parameters"`
Name string `yaml:"name"`
StopWords []string `yaml:"stopwords"`
Cutstrings []string `yaml:"cutstrings"`
TrimSpace []string `yaml:"trimspace"`
ContextSize int `yaml:"context_size"`
F16 bool `yaml:"f16"`
Threads int `yaml:"threads"`
Debug bool `yaml:"debug"`
Roles map[string]string `yaml:"roles"`
Embeddings bool `yaml:"embeddings"`
Backend string `yaml:"backend"`
TemplateConfig TemplateConfig `yaml:"template"`
MirostatETA float64 `yaml:"mirostat_eta"`
MirostatTAU float64 `yaml:"mirostat_tau"`
Mirostat int `yaml:"mirostat"`
NGPULayers int `yaml:"gpu_layers"`
ImageGenerationAssets string `yaml:"asset_dir"`
PromptStrings, InputStrings []string
InputToken [][]int
}
func ReadConfig ¶ added in v1.4.0
func ReadConfigFile ¶ added in v1.4.0
type ConfigMerger ¶ added in v1.4.0
func (ConfigMerger) LoadConfig ¶ added in v1.4.0
func (cm ConfigMerger) LoadConfig(file string) error
func (ConfigMerger) LoadConfigFile ¶ added in v1.4.0
func (cm ConfigMerger) LoadConfigFile(file string) error
func (ConfigMerger) LoadConfigs ¶ added in v1.4.0
func (cm ConfigMerger) LoadConfigs(path string) error
type ErrorResponse ¶ added in v1.3.2
type ErrorResponse struct {
Error *APIError `json:"error,omitempty"`
}
type OpenAIModel ¶
type OpenAIRequest ¶
type OpenAIRequest struct {
Model string `json:"model" yaml:"model"`
// whisper
File string `json:"file" validate:"required"`
Language string `json:"language"`
//whisper/image
ResponseFormat string `json:"response_format"`
// image
Size string `json:"size"`
// Prompt is read only by completion/image API calls
Prompt interface{} `json:"prompt" yaml:"prompt"`
// Edit endpoint
Instruction string `json:"instruction" yaml:"instruction"`
Input interface{} `json:"input" yaml:"input"`
Stop interface{} `json:"stop" yaml:"stop"`
// Messages is read only by chat/completion API calls
Messages []Message `json:"messages" yaml:"messages"`
Stream bool `json:"stream"`
Echo bool `json:"echo"`
// Common options between all the API calls
TopP float64 `json:"top_p" yaml:"top_p"`
TopK int `json:"top_k" yaml:"top_k"`
Temperature float64 `json:"temperature" yaml:"temperature"`
Maxtokens int `json:"max_tokens" yaml:"max_tokens"`
N int `json:"n"`
// Custom parameters - not present in the OpenAI API
Batch int `json:"batch" yaml:"batch"`
F16 bool `json:"f16" yaml:"f16"`
IgnoreEOS bool `json:"ignore_eos" yaml:"ignore_eos"`
RepeatPenalty float64 `json:"repeat_penalty" yaml:"repeat_penalty"`
Keep int `json:"n_keep" yaml:"n_keep"`
MirostatETA float64 `json:"mirostat_eta" yaml:"mirostat_eta"`
MirostatTAU float64 `json:"mirostat_tau" yaml:"mirostat_tau"`
Mirostat int `json:"mirostat" yaml:"mirostat"`
Seed int `json:"seed" yaml:"seed"`
// Image (not supported by OpenAI)
Mode int `json:"mode"`
Step int `json:"step"`
}
type OpenAIResponse ¶
type OpenAIUsage ¶ added in v1.6.1
type TemplateConfig ¶ added in v1.4.0
Click to show internal directories.
Click to hide internal directories.