llamaindexgo

package module
v0.0.0-...-46fcbdf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 3 Imported by: 1

README ¶

llama-index-go

GitHub contributors Discord

LlamaIndex is a data framework for your LLM application.

This is a golang implementation of the LlamaIndex.

💡 Contributing

This is very early prototype. All sorts of contributions are welcome.

Bugs? Questions?

Feel free to open an issue or ask in our Discord.

Documentation ¶

Index ¶

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 CallbackTraceHandler interface {
	// StartTrace starts tracing events
	StartTrace(id string)
	// EndTrace ends tracing events
	EndTrace(id string)
}

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 MultiModelTextImageEmbedder ¶

type MultiModelTextImageEmbedder interface {
	Generator
	// EmbedTextAndImage generates an embedding for the given text and image (base64 encoded)
	EmbedTextAndImage(ctx context.Context, text string, image string) ([]float, error)
}

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 ¶

type TextSplitter interface {
	SplitText(ctx context.Context, text string) ([]string, error)
	SplitTexts(ctx context.Context, texts []string) ([]string, error)
}

type Tokenizer ¶

type Tokenizer func(ctx context.Context, text string) ([]string, error)

Directories ¶

Path Synopsis
integrations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL