Documentation
¶
Index ¶
- func ChatMessageToMap(cm ChatMessage) map[string]string
- type AIChatMessage
- type AdditionalChatMessageAttributes
- type Agent
- type AgentAction
- type AgentActionInput
- type AgentActionManagerInput
- type AgentFinish
- type AgentFinishInput
- type AgentFinishManagerInput
- type AgentStep
- type CallOptions
- type Callback
- type CallbackManager
- type CallbackManagerForChainRun
- type CallbackManagerForModelRun
- type CallbackManagerForToolRun
- type CallbackOptions
- type Chain
- type ChainEndInput
- type ChainEndManagerInput
- type ChainErrorInput
- type ChainErrorManagerInput
- type ChainStartInput
- type ChainStartManagerInput
- type ChainValues
- type ChatMessage
- type ChatMessageHistory
- type ChatMessageType
- type ChatMessages
- type ChatModel
- type ChatModelStartInput
- type ChatModelStartManagerInput
- type Document
- type DocumentLoader
- type Embedder
- type FunctionCall
- type FunctionChatMessage
- type FunctionDefinition
- type FunctionDefinitionParameters
- type GenerateOptions
- type Generation
- type GenericChatMessage
- type HumanChatMessage
- type LLM
- type LLMStartInput
- type LLMStartManagerInput
- type Memory
- type Model
- type ModelEndInput
- type ModelEndManagerInput
- type ModelErrorInput
- type ModelErrorManagerInput
- type ModelNewTokenInput
- type ModelNewTokenManagerInput
- type ModelResult
- type OutputParser
- type PromptValue
- type Retriever
- type StringifyChatMessagesOptions
- type SystemChatMessage
- type TextInput
- type TextManagerInput
- type TextSplitter
- type Tokenizer
- type Tool
- type ToolEndInput
- type ToolEndManagerInput
- type ToolErrorInput
- type ToolErrorManagerInput
- type ToolStartInput
- type ToolStartManagerInput
- type VectorStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChatMessageToMap ¶ added in v0.0.12
func ChatMessageToMap(cm ChatMessage) map[string]string
Types ¶
type AIChatMessage ¶
type AIChatMessage struct {
// contains filtered or unexported fields
}
func NewAIChatMessage ¶
func NewAIChatMessage(text string) *AIChatMessage
func (AIChatMessage) AdditionalAttributes ¶ added in v0.0.27
func (m AIChatMessage) AdditionalAttributes() AdditionalChatMessageAttributes
func (AIChatMessage) Text ¶
func (m AIChatMessage) Text() string
func (AIChatMessage) Type ¶
func (m AIChatMessage) Type() ChatMessageType
type AdditionalChatMessageAttributes ¶ added in v0.0.27
type AdditionalChatMessageAttributes struct {
FunctionCall FunctionCall `json:"functionCall,omitempty"`
}
type Agent ¶
type Agent interface {
Plan(ctx context.Context, intermediateSteps []AgentStep, inputs map[string]string) ([]*AgentAction, *AgentFinish, error)
InputKeys() []string
OutputKeys() []string
}
type AgentAction ¶
AgentAction is the agent's action to take.
type AgentActionInput ¶ added in v0.0.27
type AgentActionInput struct {
*AgentActionManagerInput
RunID string
}
type AgentActionManagerInput ¶ added in v0.0.27
type AgentActionManagerInput struct {
Action *AgentAction
}
type AgentFinish ¶
AgentFinish is the agent's return value.
type AgentFinishInput ¶ added in v0.0.27
type AgentFinishInput struct {
*AgentFinishManagerInput
RunID string
}
type AgentFinishManagerInput ¶ added in v0.0.27
type AgentFinishManagerInput struct {
Finish *AgentFinish
}
type AgentStep ¶
type AgentStep struct {
Action *AgentAction
Observation string
}
AgentStep is a step of the agent.
type CallOptions ¶ added in v0.0.22
type CallOptions struct {
CallbackManger CallbackManagerForChainRun
Stop []string
}
type Callback ¶
type Callback interface {
AlwaysVerbose() bool
RaiseError() bool
OnLLMStart(ctx context.Context, input *LLMStartInput) error
OnChatModelStart(ctx context.Context, input *ChatModelStartInput) error
OnModelNewToken(ctx context.Context, input *ModelNewTokenInput) error
OnModelEnd(ctx context.Context, input *ModelEndInput) error
OnModelError(ctx context.Context, input *ModelErrorInput) error
OnChainStart(ctx context.Context, input *ChainStartInput) error
OnChainEnd(ctx context.Context, input *ChainEndInput) error
OnChainError(ctx context.Context, input *ChainErrorInput) error
OnAgentAction(ctx context.Context, input *AgentActionInput) error
OnAgentFinish(ctx context.Context, input *AgentFinishInput) error
OnToolStart(ctx context.Context, input *ToolStartInput) error
OnToolEnd(ctx context.Context, input *ToolEndInput) error
OnToolError(ctx context.Context, input *ToolErrorInput) error
OnText(ctx context.Context, input *TextInput) error
}
type CallbackManager ¶ added in v0.0.22
type CallbackManager interface {
OnLLMStart(ctx context.Context, input *LLMStartManagerInput) (CallbackManagerForModelRun, error)
OnChatModelStart(ctx context.Context, input *ChatModelStartManagerInput) (CallbackManagerForModelRun, error)
OnChainStart(ctx context.Context, input *ChainStartManagerInput) (CallbackManagerForChainRun, error)
OnToolStart(ctx context.Context, input *ToolStartManagerInput) (CallbackManagerForToolRun, error)
RunID() string
}
type CallbackManagerForChainRun ¶ added in v0.0.28
type CallbackManagerForChainRun interface {
OnChainEnd(ctx context.Context, input *ChainEndManagerInput) error
OnChainError(ctx context.Context, input *ChainErrorManagerInput) error
OnAgentAction(ctx context.Context, input *AgentActionManagerInput) error
OnAgentFinish(ctx context.Context, input *AgentFinishManagerInput) error
OnText(ctx context.Context, input *TextManagerInput) error
GetInheritableCallbacks() []Callback
RunID() string
}
type CallbackManagerForModelRun ¶ added in v0.0.28
type CallbackManagerForModelRun interface {
OnModelNewToken(ctx context.Context, input *ModelNewTokenManagerInput) error
OnModelEnd(ctx context.Context, input *ModelEndManagerInput) error
OnModelError(ctx context.Context, input *ModelErrorManagerInput) error
OnText(ctx context.Context, input *TextManagerInput) error
GetInheritableCallbacks() []Callback
RunID() string
}
type CallbackManagerForToolRun ¶ added in v0.0.28
type CallbackManagerForToolRun interface {
OnToolEnd(ctx context.Context, input *ToolEndManagerInput) error
OnToolError(ctx context.Context, input *ToolErrorManagerInput) error
OnText(ctx context.Context, input *TextManagerInput) error
}
type CallbackOptions ¶ added in v0.0.13
type Chain ¶
type Chain interface {
// Call executes the chain with the given context and inputs.
// It returns the outputs of the chain or an error, if any.
Call(ctx context.Context, inputs ChainValues, optFns ...func(o *CallOptions)) (ChainValues, error)
// Type returns the type of the chain.
Type() string
// Verbose returns the verbosity setting of the chain.
Verbose() bool
// Callbacks returns the callbacks associated with the chain.
Callbacks() []Callback
// Memory returns the memory associated with the chain.
Memory() Memory
// InputKeys returns the expected input keys.
InputKeys() []string
// OutputKeys returns the output keys the chain will return.
OutputKeys() []string
}
type ChainEndInput ¶ added in v0.0.27
type ChainEndInput struct {
*ChainEndManagerInput
RunID string
}
type ChainEndManagerInput ¶ added in v0.0.27
type ChainEndManagerInput struct {
Outputs ChainValues
}
type ChainErrorInput ¶ added in v0.0.27
type ChainErrorInput struct {
*ChainErrorManagerInput
RunID string
}
type ChainErrorManagerInput ¶ added in v0.0.27
type ChainErrorManagerInput struct {
Error error
}
type ChainStartInput ¶ added in v0.0.27
type ChainStartInput struct {
*ChainStartManagerInput
RunID string
}
type ChainStartManagerInput ¶ added in v0.0.27
type ChainStartManagerInput struct {
ChainType string
Inputs ChainValues
}
type ChainValues ¶
type ChatMessage ¶
type ChatMessage interface {
Text() string
Type() ChatMessageType
AdditionalAttributes() AdditionalChatMessageAttributes
}
func MapToChatMessage ¶ added in v0.0.12
func MapToChatMessage(m map[string]string) (ChatMessage, error)
type ChatMessageHistory ¶
type ChatMessageHistory interface {
// Messages returns the messages stored in the store.
Messages(ctx context.Context) (ChatMessages, error)
// Add a user message to the store.
AddUserMessage(ctx context.Context, text string) error
// Add an AI message to the store.
AddAIMessage(ctx context.Context, text string) error
// Add a self-created message to the store.
AddMessage(ctx context.Context, message ChatMessage) error
// Remove all messages from the store.
Clear(ctx context.Context) error
}
type ChatMessageType ¶
type ChatMessageType string
const ( ChatMessageTypeHuman ChatMessageType = "human" ChatMessageTypeAI ChatMessageType = "ai" ChatMessageTypeSystem ChatMessageType = "system" ChatMessageTypeGeneric ChatMessageType = "generic" ChatMessageTypeFunction ChatMessageType = "function" )
type ChatMessages ¶ added in v0.0.9
type ChatMessages []ChatMessage
func (ChatMessages) Format ¶ added in v0.0.9
func (cm ChatMessages) Format(optFns ...func(o *StringifyChatMessagesOptions)) (string, error)
type ChatModel ¶ added in v0.0.13
type ChatModel interface {
Model
Generate(ctx context.Context, messages ChatMessages, optFns ...func(o *GenerateOptions)) (*ModelResult, error)
}
type ChatModelStartInput ¶ added in v0.0.27
type ChatModelStartInput struct {
*ChatModelStartManagerInput
RunID string
}
type ChatModelStartManagerInput ¶ added in v0.0.27
type ChatModelStartManagerInput struct {
ChatModelType string
Messages []ChatMessages
InvocationParams map[string]any
}
type DocumentLoader ¶
type Embedder ¶
type Embedder interface {
// EmbedDocuments returns a vector for each text.
EmbedDocuments(ctx context.Context, texts []string) ([][]float64, error)
// EmbedQuery embeds a single text.
EmbedQuery(ctx context.Context, text string) ([]float64, error)
}
Embedder is the interface for creating vector embeddings from texts.
type FunctionCall ¶ added in v0.0.27
type FunctionChatMessage ¶ added in v0.0.24
type FunctionChatMessage struct {
// contains filtered or unexported fields
}
func NewFunctionChatMessage ¶ added in v0.0.24
func NewFunctionChatMessage(text, name string) *FunctionChatMessage
func (FunctionChatMessage) AdditionalAttributes ¶ added in v0.0.27
func (m FunctionChatMessage) AdditionalAttributes() AdditionalChatMessageAttributes
func (FunctionChatMessage) Name ¶ added in v0.0.24
func (m FunctionChatMessage) Name() string
func (FunctionChatMessage) Text ¶ added in v0.0.24
func (m FunctionChatMessage) Text() string
func (FunctionChatMessage) Type ¶ added in v0.0.24
func (m FunctionChatMessage) Type() ChatMessageType
type FunctionDefinition ¶ added in v0.0.26
type FunctionDefinition struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Parameters FunctionDefinitionParameters `json:"parameters"`
}
type FunctionDefinitionParameters ¶ added in v0.0.26
type FunctionDefinitionParameters struct {
Type string `json:"type"`
Properties map[string]*jsonschema.Schema `json:"properties"`
Required []string `json:"required"`
}
type GenerateOptions ¶
type GenerateOptions struct {
CallbackManger CallbackManagerForModelRun
Stop []string
Functions []FunctionDefinition
}
type Generation ¶
type Generation struct {
Text string
Message ChatMessage
Info map[string]any
}
type GenericChatMessage ¶
type GenericChatMessage struct {
// contains filtered or unexported fields
}
func NewGenericChatMessage ¶
func NewGenericChatMessage(text, role string) *GenericChatMessage
func (GenericChatMessage) AdditionalAttributes ¶ added in v0.0.27
func (m GenericChatMessage) AdditionalAttributes() AdditionalChatMessageAttributes
func (GenericChatMessage) Role ¶
func (m GenericChatMessage) Role() string
func (GenericChatMessage) Text ¶
func (m GenericChatMessage) Text() string
func (GenericChatMessage) Type ¶
func (m GenericChatMessage) Type() ChatMessageType
type HumanChatMessage ¶
type HumanChatMessage struct {
// contains filtered or unexported fields
}
func NewHumanChatMessage ¶
func NewHumanChatMessage(text string) *HumanChatMessage
func (HumanChatMessage) AdditionalAttributes ¶ added in v0.0.27
func (m HumanChatMessage) AdditionalAttributes() AdditionalChatMessageAttributes
func (HumanChatMessage) Text ¶
func (m HumanChatMessage) Text() string
func (HumanChatMessage) Type ¶
func (m HumanChatMessage) Type() ChatMessageType
type LLM ¶
type LLM interface {
Model
Generate(ctx context.Context, prompts []string, optFns ...func(o *GenerateOptions)) (*ModelResult, error)
}
type LLMStartInput ¶ added in v0.0.27
type LLMStartInput struct {
*LLMStartManagerInput
RunID string
}
type LLMStartManagerInput ¶ added in v0.0.27
type Memory ¶
type Memory interface {
// Input keys this memory class will load dynamically.
MemoryKeys() []string
// Return key-value pairs given the text input to the chain.
// If None, return all memories
LoadMemoryVariables(ctx context.Context, inputs map[string]any) (map[string]any, error)
// Save the context of this model run to memory.
SaveContext(ctx context.Context, inputs map[string]any, outputs map[string]any) error
// Clear memory contents.
Clear(ctx context.Context) error
}
type ModelEndInput ¶ added in v0.0.27
type ModelEndInput struct {
*ModelEndManagerInput
RunID string
}
type ModelEndManagerInput ¶ added in v0.0.27
type ModelEndManagerInput struct {
Result *ModelResult
}
type ModelErrorInput ¶ added in v0.0.27
type ModelErrorInput struct {
*ModelErrorManagerInput
RunID string
}
type ModelErrorManagerInput ¶ added in v0.0.27
type ModelErrorManagerInput struct {
Error error
}
type ModelNewTokenInput ¶ added in v0.0.27
type ModelNewTokenInput struct {
*ModelNewTokenManagerInput
RunID string
}
type ModelNewTokenManagerInput ¶ added in v0.0.27
type ModelNewTokenManagerInput struct {
Token string
}
type ModelResult ¶ added in v0.0.26
type ModelResult struct {
Generations [][]Generation
LLMOutput map[string]any
}
type OutputParser ¶
type OutputParser[T any] interface { // Parse parses the output of an LLM call. ParseResult(result []Generation) (any, error) // Parse parses the output of an LLM call. Parse(text string) (T, error) // ParseWithPrompt parses the output of an LLM call with the prompt used. ParseWithPrompt(text string, prompt PromptValue) (T, error) // GetFormatInstructions returns a string describing the format of the output. GetFormatInstructions() (string, error) // Type returns the string type key uniquely identifying this class of parser Type() string }
OutputParser is an interface for parsing the output of an LLM call.
type PromptValue ¶
type PromptValue interface {
String() string
Messages() ChatMessages
}
type SystemChatMessage ¶
type SystemChatMessage struct {
// contains filtered or unexported fields
}
func NewSystemChatMessage ¶
func NewSystemChatMessage(text string) *SystemChatMessage
func (SystemChatMessage) AdditionalAttributes ¶ added in v0.0.27
func (m SystemChatMessage) AdditionalAttributes() AdditionalChatMessageAttributes
func (SystemChatMessage) Text ¶
func (m SystemChatMessage) Text() string
func (SystemChatMessage) Type ¶
func (m SystemChatMessage) Type() ChatMessageType
type TextInput ¶ added in v0.0.27
type TextInput struct {
*TextManagerInput
RunID string
}
type TextManagerInput ¶ added in v0.0.27
type TextManagerInput struct {
Text string
}
type TextSplitter ¶
type ToolEndInput ¶ added in v0.0.27
type ToolEndInput struct {
*ToolEndManagerInput
RunID string
}
type ToolEndManagerInput ¶ added in v0.0.27
type ToolEndManagerInput struct {
Output string
}
type ToolErrorInput ¶ added in v0.0.27
type ToolErrorInput struct {
*ToolErrorManagerInput
RunID string
}
type ToolErrorManagerInput ¶ added in v0.0.27
type ToolErrorManagerInput struct {
Error error
}
type ToolStartInput ¶ added in v0.0.27
type ToolStartInput struct {
*ToolStartManagerInput
RunID string
}
type ToolStartManagerInput ¶ added in v0.0.27
Click to show internal directories.
Click to hide internal directories.