Versions in this module Expand all Collapse all v1 v1.0.12 Sep 1, 2024 v1.0.11 Sep 1, 2024 v1.0.10 Sep 1, 2024 v1.0.9 Sep 1, 2024 v1.0.8 Sep 1, 2024 v1.0.7 Sep 1, 2024 v1.0.6 Sep 1, 2024 v1.0.5 Aug 31, 2024 v1.0.4 Aug 31, 2024 v1.0.3 Aug 31, 2024 Changes in this version + var ErrUnexpectedChatMessageType = errors.New("unexpected chat message type") + 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 GetBufferString(messages []ChatMessage, humanPrefix string, aiPrefix string) (string, error) + func GetModelContextSize(model string) int + func ShowMessageContents(w io.Writer, msgs []MessageContent) + type AIChatMessage struct + Content string + FunctionCall *FunctionCall + ToolCalls []ToolCall + func (m AIChatMessage) GetContent() string + func (m AIChatMessage) GetFunctionCall() *FunctionCall + func (m AIChatMessage) GetType() ChatMessageType + type BinaryContent struct + Data []byte + MIMEType string + func BinaryPart(mime string, data []byte) BinaryContent + func (bc *BinaryContent) UnmarshalJSON(data []byte) error + func (bc BinaryContent) MarshalJSON() ([]byte, error) + func (bc BinaryContent) String() string + 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 WithJSONMode() CallOption + func WithMaxLength(maxLength int) CallOption + func WithMaxTokens(maxTokens int) CallOption + func WithMetadata(metadata map[string]interface{}) 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 WithToolChoice(choice any) CallOption + func WithTools(tools []Tool) CallOption + func WithTopK(topK int) CallOption + func WithTopP(topP float64) CallOption + type CallOptions struct + CandidateCount int + FrequencyPenalty float64 + FunctionCallBehavior FunctionCallBehavior + Functions []FunctionDefinition + JSONMode bool + MaxLength int + MaxTokens int + Metadata map[string]interface{} + MinLength int + Model string + N int + PresencePenalty float64 + RepetitionPenalty float64 + Seed int + StopWords []string + StreamingFunc func(ctx context.Context, chunk []byte) error + Temperature float64 + ToolChoice any + Tools []Tool + TopK int + TopP float64 + type ChatMessage interface + GetContent func() string + GetType func() ChatMessageType + type ChatMessageModel struct + Data ChatMessageModelData + Type string + func ConvertChatMessageToModel(m ChatMessage) ChatMessageModel + func (c ChatMessageModel) ToChatMessage() ChatMessage + type ChatMessageModelData struct + Content string + Type string + type ChatMessageType string + const ChatMessageTypeAI + const ChatMessageTypeFunction + const ChatMessageTypeGeneric + const ChatMessageTypeHuman + const ChatMessageTypeSystem + const ChatMessageTypeTool + type ContentChoice struct + Content string + FuncCall *FunctionCall + GenerationInfo map[string]any + StopReason string + ToolCalls []ToolCall + type ContentPart interface + type ContentResponse struct + Choices []*ContentChoice + type FunctionCall struct + Arguments string + Name string + type FunctionCallBehavior string + const FunctionCallBehaviorAuto + const FunctionCallBehaviorNone + type FunctionChatMessage struct + Content string + Name string + func (m FunctionChatMessage) GetContent() string + func (m FunctionChatMessage) GetName() string + func (m FunctionChatMessage) GetType() ChatMessageType + type FunctionDefinition struct + Description string + Name string + Parameters any + type FunctionReference struct + Name string + type GenericChatMessage struct + Content string + Name string + Role string + func (m GenericChatMessage) GetContent() string + func (m GenericChatMessage) GetName() string + func (m GenericChatMessage) GetType() ChatMessageType + type HumanChatMessage struct + Content string + func (m HumanChatMessage) GetContent() string + func (m HumanChatMessage) GetType() ChatMessageType + type ImageURLContent struct + Detail string + URL string + func ImageURLPart(url string) ImageURLContent + func ImageURLWithDetailPart(url string, detail string) ImageURLContent + func (iuc *ImageURLContent) UnmarshalJSON(data []byte) error + func (iuc ImageURLContent) MarshalJSON() ([]byte, error) + func (iuc ImageURLContent) String() string + type LLM = Model + type MessageContent struct + Parts []ContentPart + Role ChatMessageType + func TextParts(role ChatMessageType, parts ...string) MessageContent + func (mc *MessageContent) UnmarshalJSON(data []byte) error + func (mc MessageContent) MarshalJSON() ([]byte, error) + 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 Named interface + GetName func() string + type PromptValue interface + Messages func() []ChatMessage + String func() string + type SystemChatMessage struct + Content string + func (m SystemChatMessage) GetContent() string + func (m SystemChatMessage) GetType() ChatMessageType + type TextContent struct + Text string + func TextPart(s string) TextContent + func (tc *TextContent) UnmarshalJSON(data []byte) error + func (tc TextContent) MarshalJSON() ([]byte, error) + func (tc TextContent) String() string + type Tool struct + Function *FunctionDefinition + Type string + type ToolCall struct + FunctionCall *FunctionCall + ID string + Type string + func (tc *ToolCall) UnmarshalJSON(data []byte) error + func (tc ToolCall) MarshalJSON() ([]byte, error) + type ToolCallResponse struct + Content string + Name string + ToolCallID string + func (tc *ToolCallResponse) UnmarshalJSON(data []byte) error + func (tc ToolCallResponse) MarshalJSON() ([]byte, error) + type ToolChatMessage struct + Content string + ID string + func (m ToolChatMessage) GetContent() string + func (m ToolChatMessage) GetID() string + func (m ToolChatMessage) GetType() ChatMessageType + type ToolChoice struct + Function *FunctionReference + Type string