Documentation
¶
Index ¶
- type ChatCompletionPayload
- type CompletionService
- func (s *CompletionService) PerformCompletion(ctx context.Context, payload *ChatCompletionPayload) (string, error)
- func (s *CompletionService) PerformCompletionStreaming(ctx context.Context, payload *ChatCompletionPayload, showSpinner bool) (<-chan string, error)
- func (s *CompletionService) Run(ctx context.Context, runCfg RunConfig) error
- type Config
- type RunConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatCompletionPayload ¶
type ChatCompletionPayload struct {
Model string `json:"model"`
Messages []llms.MessageContent
Stream bool `json:"stream,omitempty"`
}
type CompletionService ¶
type CompletionService struct {
// contains filtered or unexported fields
}
func NewCompletionService ¶
func NewCompletionService(cfg *Config) (*CompletionService, error)
NewCompletionService creates a new CompletionService with the given configuration.
func (*CompletionService) PerformCompletion ¶
func (s *CompletionService) PerformCompletion(ctx context.Context, payload *ChatCompletionPayload) (string, error)
func (*CompletionService) PerformCompletionStreaming ¶
func (s *CompletionService) PerformCompletionStreaming(ctx context.Context, payload *ChatCompletionPayload, showSpinner bool) (<-chan string, error)
type Config ¶
type Config struct {
Backend string `yaml:"backend"`
Model string `yaml:"modelName"`
Stream bool `yaml:"stream"`
MaxTokens int `yaml:"maxTokens"`
SystemPrompt string `yaml:"systemPrompt"`
LogitBias map[string]float64 `yaml:"logitBias"`
}
Config is the configuration for cgpt.
func LoadConfigFromPath ¶
LoadConfigFromPath loads the config file from the given path. if the file is not found, it returns the default config.
func SetDefaults ¶
SetDefaults sets the default values for the config.
type RunConfig ¶
type RunConfig struct {
// Input is the input text to complete. If "-", read from stdin.
Input string
// Continuous will run the completion API in a loop, using the previous output as the input for the next request.
Continuous bool
// Stream will stream results as they come in.
Stream bool
// HistoryIn is the file to read history from.
HistoryIn string
// HistoryOut is the file to store history in.
HistoryOut string
// NCompletions is the number of completions to complete in a history-enabled context.
NCompletions int
// Verbose will enable verbose output.
Verbose bool
}
RunConfig is the configuration for the Run method.
Click to show internal directories.
Click to hide internal directories.