schema

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 2 Imported by: 8

Documentation

Overview

Package schema implements a shared core set of data types for use in langchaingo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentAction

type AgentAction struct {
	Tool      string
	ToolInput string
	Log       string
	ToolID    string
}

AgentAction is the agent's action to take.

type AgentFinish

type AgentFinish struct {
	ReturnValues map[string]any
	Log          string
}

AgentFinish is the agent's return value.

type AgentStep

type AgentStep struct {
	Action      AgentAction
	Observation string
}

AgentStep is a step of the agent.

type ChatMessageHistory

type ChatMessageHistory interface {
	// AddMessage adds a message to the store.
	AddMessage(ctx context.Context, message llms.ChatMessage) error

	// AddUserMessage is a convenience method for adding a human message string
	// to the store.
	AddUserMessage(ctx context.Context, message string) error

	// AddAIMessage is a convenience method for adding an AI message string to
	// the store.
	AddAIMessage(ctx context.Context, message string) error

	// Clear removes all messages from the store.
	Clear(ctx context.Context) error

	// Messages retrieves all messages from the store
	Messages(ctx context.Context) ([]llms.ChatMessage, error)

	// SetMessages replaces existing messages in the store
	SetMessages(ctx context.Context, messages []llms.ChatMessage) error
}

ChatMessageHistory is the interface for chat history in memory/store.

type Document

type Document struct {
	PageContent string
	Metadata    map[string]any
	Score       float32
}

Document is the interface for interacting with a document.

type Memory

type Memory interface {
	// GetMemoryKey getter for memory key.
	GetMemoryKey(ctx context.Context) string
	// MemoryVariables Input keys this memory class will load dynamically.
	MemoryVariables(ctx context.Context) []string
	// LoadMemoryVariables 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)
	// SaveContext 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
}

Memory is the interface for memory in chains.

type OutputParser

type OutputParser[T any] interface {
	// 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 llms.PromptValue) (T, error)
	// GetFormatInstructions returns a string describing the format of the output.
	GetFormatInstructions() string
	// 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 Retriever

type Retriever interface {
	GetRelevantDocuments(ctx context.Context, query string) ([]Document, error)
}

Retriever is an interface that defines the behavior of a retriever.

Jump to

Keyboard shortcuts

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