Documentation
¶
Index ¶
- func Similarity(ctx context.Context, mode SimilarityMode, e1 []float, e2 []float) (float, error)
- type CallbackEventHandler
- type CallbackHandler
- type CallbackManager
- type CallbackTraceHandler
- type ChatMessage
- type ChatMessages
- type ChatResponse
- type MessageRole
- type MultiModelTextImageEmbedder
- type Node
- type NodeParser
- type SimilarityMode
- type TextEmbedder
- type TextSplitter
- type Tokenizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Similarity ¶
func Similarity(ctx context.Context, mode SimilarityMode, e1 []float, e2 []float) (float, error)
Similarity returns the similarity between two embeddings
Types ¶
type CallbackEventHandler ¶
type CallbackEventHandler interface { // OnEventStart runs when an event starts OnEventStart(event CBEvent) string // OnEventEnd runs when an event ends OnEventEnd(event CBEvent) string // IgnoredStartEvents returns a list of events that should be ignored when calling OnEventStart IgnoredStartEvents() []Event // IgnoredEndEvents returns a list of events that should be ignored when calling OnEventEnd IgnoredEndEvents() []Event }
type CallbackHandler ¶
type CallbackHandler interface { CallbackEventHandler CallbackTraceHandler }
type CallbackManager ¶
type CallbackManager struct { // Handlers is a list of callback handlers that will be called when an event starts or ends Handlers []CallbackHandler // contains filtered or unexported fields }
type CallbackTraceHandler ¶
type ChatMessage ¶
type ChatMessage struct { // Role of the message Role MessageRole // Content of the message Content string // Metadata contains any additional information about the message such as token counts, metrics, etc. Metadata map[string]interface{} }
ChatMessage is a message in a chat
func (*ChatMessage) String ¶
func (c *ChatMessage) String() string
String returns the string representation of the chat message
type ChatMessages ¶
type ChatMessages struct { // Messages is a list of chat messages Messages []ChatMessage }
ChatMessages is a list of chat messages
func (ChatMessages) String ¶
func (c ChatMessages) String() string
String returns the string representation of the chat messages
type ChatResponse ¶
type ChatResponse = ChatMessage
type MessageRole ¶
type MessageRole string
MessageRole is the role associated with a chat message
const ( SYSTEM MessageRole = "system" USER MessageRole = "user" ASSISTANT MessageRole = "assistant" FUNCTION MessageRole = "function" TOOL MessageRole = "tool" CHATBOT MessageRole = "chatbot" )
type Node ¶
type Node interface { // ID returns the unique identifier of the node ID() string // Content returns the raw content of the node Content() []byte // Metadata returns the associated metadata of the node Metadata() map[string]any // Text returns the text value of the node // If the node does not have a text value, it returns an error Text() (string, error) // Embedding returns the embedding value of the node // If the node does not have an embedding, it returns an error Embedding() ([]float, error) // ParentID returns the unique identifier of the parent node // return an empty string if the node does not have a parent ParentID() (string, error) // ChildrenIDs returns the unique identifiers of the children nodes // return an empty slice if the node does not have children ChildrenIDs() ([]string, error) }
Node represents a node in the graph
type NodeParser ¶
type NodeParser interface { // GetNodesFromDocuments returns a list of Nodes from the given list of Documents GetNodesFromDocuments(ctx context.Context, docs []Node) ([]Node, error) }
NodeParser generates Nodes from Documents
type SimilarityMode ¶
type SimilarityMode = int
const ( COSINE SimilarityMode = iota DOT EUCLIDEAN )
type TextEmbedder ¶
type TextEmbedder interface { Generator // EmbedQuery generates an embedding for the given query EmbedQuery(ctx context.Context, query string) ([]float, error) // EmbedQueries generates embeddings for the given queries EmbedQueries(ctx context.Context, queries []string) ([][]float, error) // EmbedText generates an embedding for the given text EmbedText(ctx context.Context, text string) ([]float, error) // EmbedTexts generates embeddings for the given texts EmbedTexts(ctx context.Context, texts []string) ([][]float, error) }
type TextSplitter ¶
Click to show internal directories.
Click to hide internal directories.