Documentation ¶
Index ¶
- Variables
- type ChatCompletionRequest
- type ChatCompletionResponse
- type ChatMessage
- type ChatPrompt
- type ConvRole
- type FunctionCall
- type FunctionSpecs
- type GPT
- func (gpt *GPT) Chat(prompt *ChatPrompt) (*ChatMessage, error)
- func (gpt *GPT) ChatWithFunctions(prompt *ChatPrompt, functions []FunctionSpecs) (*ChatMessage, error)
- func (gpt *GPT) WithCompletionTokenLimit(limit int) *GPT
- func (gpt *GPT) WithPromptTokenLimit(limit int) *GPT
- func (gpt *GPT) WithTemperature(temperature float64) *GPT
- func (gpt *GPT) WithTotalTokenLimit(limit int) *GPT
- type LLM
- type LLMWithFunctionCalls
- type ParameterSpecs
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTokenLimitExceeded = fmt.Errorf("token limit exceeded")
View Source
var OpenAIBaseURL = "https://api.openai.com"
Functions ¶
This section is empty.
Types ¶
type ChatCompletionRequest ¶
type ChatCompletionRequest struct { Model string `json:"model"` Temperature float64 `json:"temperature,omitempty"` Messages []*ChatMessage `json:"messages"` Functions []FunctionSpecs `json:"functions,omitempty"` }
type ChatCompletionResponse ¶
type ChatCompletionResponse struct { Choices []struct { Message *ChatMessage `json:"message"` } `json:"choices"` Usage struct { PromptTokensUsed int `json:"prompt_tokens"` CompletionTokensUsed int `json:"completion_tokens"` } `json:"usage"` }
type ChatMessage ¶
type ChatMessage struct { Role ConvRole `json:"role"` Text string `json:"content"` FunctionCall *FunctionCall `json:"function_call,omitempty"` Name string `json:"name,omitempty"` }
type ChatPrompt ¶
type ChatPrompt struct {
History []*ChatMessage
}
type FunctionCall ¶
type FunctionSpecs ¶
type FunctionSpecs struct { Name string `json:"name"` Description string `json:"description"` Parameters *ParameterSpecs `json:"parameters"` }
type GPT ¶
type GPT struct { APIToken string Model string PromptTokensUsed int CompletionTokensUsed int PromptTokenLimit int CompletionTokenLimit int TotalTokenLimit int Temperature float64 }
func NewGPTEngine ¶
func (*GPT) Chat ¶
func (gpt *GPT) Chat(prompt *ChatPrompt) (*ChatMessage, error)
func (*GPT) ChatWithFunctions ¶
func (gpt *GPT) ChatWithFunctions(prompt *ChatPrompt, functions []FunctionSpecs) (*ChatMessage, error)
func (*GPT) WithCompletionTokenLimit ¶
func (*GPT) WithPromptTokenLimit ¶
func (*GPT) WithTemperature ¶
func (*GPT) WithTotalTokenLimit ¶
type LLM ¶
type LLM interface {
Chat(prompt *ChatPrompt) (*ChatMessage, error)
}
type LLMWithFunctionCalls ¶
type LLMWithFunctionCalls interface { LLM ChatWithFunctions(prompt *ChatPrompt, functions []FunctionSpecs) (*ChatMessage, error) }
type ParameterSpecs ¶
type ParameterSpecs struct { Type string `json:"type"` Description string `json:"description,omitempty"` Properties map[string]*ParameterSpecs `json:"properties,omitempty"` Required []string `json:"required,omitempty"` Items *ParameterSpecs `json:"items,omitempty"` Enum []any `json:"enum,omitempty"` }
Click to show internal directories.
Click to hide internal directories.