Versions in this module Expand all Collapse all v0 v0.1.9 Feb 28, 2024 Changes in this version type MessageContent + Name string v0.1.8 Feb 27, 2024 v0.1.7 Feb 27, 2024 v0.1.6 Feb 27, 2024 Changes in this version + func CalculateMaxTokens(model, text string) int + func CountTokens(model, text string) int + func GenerateFromSinglePrompt(ctx context.Context, llm Model, prompt string, options ...CallOption) (string, error) + func GetModelContextSize(model string) int + type BinaryContent struct + Data []byte + MIMEType string + func BinaryPart(mime string, data []byte) BinaryContent + type CallOption func(*CallOptions) + func WithCandidateCount(c int) CallOption + func WithFrequencyPenalty(frequencyPenalty float64) CallOption + func WithFunctionCallBehavior(behavior FunctionCallBehavior) CallOption + func WithFunctions(functions []FunctionDefinition) CallOption + func WithMaxLength(maxLength int) CallOption + func WithMaxTokens(maxTokens int) CallOption + func WithMinLength(minLength int) CallOption + func WithModel(model string) CallOption + func WithN(n int) CallOption + func WithOptions(options CallOptions) CallOption + func WithPresencePenalty(presencePenalty float64) CallOption + func WithRepetitionPenalty(repetitionPenalty float64) CallOption + func WithSeed(seed int) CallOption + func WithStopWords(stopWords []string) CallOption + func WithStreamingFunc(streamingFunc func(ctx context.Context, chunk []byte) error) CallOption + func WithTemperature(temperature float64) CallOption + func WithTopK(topK int) CallOption + func WithTopP(topP float64) CallOption + type CallOptions struct + CandidateCount int + FrequencyPenalty float64 + FunctionCallBehavior FunctionCallBehavior + Functions []FunctionDefinition + MaxLength int + MaxTokens int + MinLength int + Model string + N int + PresencePenalty float64 + RepetitionPenalty float64 + Seed int + StopWords []string + StreamingFunc func(ctx context.Context, chunk []byte) error + Temperature float64 + TopK int + TopP float64 + type ContentChoice struct + Content string + FuncCall *schema.FunctionCall + GenerationInfo map[string]any + StopReason string + type ContentPart interface + type ContentResponse struct + Choices []*ContentChoice + type FunctionCallBehavior string + const FunctionCallBehaviorAuto + const FunctionCallBehaviorNone + type FunctionDefinition struct + Description string + Name string + Parameters any + type ImageURLContent struct + URL string + func ImageURLPart(url string) ImageURLContent + func (iuc ImageURLContent) MarshalJSON() ([]byte, error) + type LLM = Model + type MessageContent struct + Parts []ContentPart + Role schema.ChatMessageType + func TextParts(role schema.ChatMessageType, parts ...string) MessageContent + type Model interface + Call func(ctx context.Context, prompt string, options ...CallOption) (string, error) + GenerateContent func(ctx context.Context, messages []MessageContent, options ...CallOption) (*ContentResponse, error) + type TextContent struct + Text string + func TextPart(s string) TextContent + func (tc TextContent) MarshalJSON() ([]byte, error)