Documentation
¶
Index ¶
- Constants
- func CountTokens(texts []string) int
- func TruncateTextOnTokenCount(text string) string
- type Digest
- type EmbeddingServerError
- type EmbeddingsDriver
- type HuggingfaceDriver
- type JsonOutputParser
- func (p JsonOutputParser[T]) GetFormatInstructions() string
- func (p JsonOutputParser[T]) Parse(text string) (any, error)
- func (p JsonOutputParser[T]) ParseT(text string) (T, error)
- func (p JsonOutputParser[T]) ParseWithPrompt(text string, _ llms.PromptValue) (any, error)
- func (p JsonOutputParser[T]) Type() string
- type JsonValueExtraction
- type KeyConcept
- type ParrotboxClient
- type ParseError
Constants ¶
const ( SEARCH_QUERY = "search_query" SEARCH_DOCUMENT = "search_document" CLASSIFICATION = "classification" SIMILARITY = "clustering" )
const ( SHORT_DELAY = 10 * time.Millisecond LONG_DELAY = 10 * time.Second RETRY_ATTEMPTS = 3 )
Variables ¶
This section is empty.
Functions ¶
func CountTokens ¶
Types ¶
type EmbeddingServerError ¶
type EmbeddingServerError string
func (EmbeddingServerError) Error ¶
func (err EmbeddingServerError) Error() string
type EmbeddingsDriver ¶
type EmbeddingsDriver struct {
// contains filtered or unexported fields
}
func NewEmbeddingsDriver ¶
func NewEmbeddingsDriver(url string, ctx int) *EmbeddingsDriver
func (*EmbeddingsDriver) CreateBatchTextEmbeddings ¶
func (driver *EmbeddingsDriver) CreateBatchTextEmbeddings(texts []string, task_type string) [][]float32
func (*EmbeddingsDriver) CreateTextEmbeddings ¶
func (driver *EmbeddingsDriver) CreateTextEmbeddings(text string, task_type string) []float32
type HuggingfaceDriver ¶
type HuggingfaceDriver struct {
// contains filtered or unexported fields
}
func NewHuggingfaceDriver ¶
func NewHuggingfaceDriver() *HuggingfaceDriver
func (*HuggingfaceDriver) CreateBatchTextEmbeddings ¶
func (driver *HuggingfaceDriver) CreateBatchTextEmbeddings(texts []string) ([][]float32, error)
func (*HuggingfaceDriver) CreateTextEmbeddings ¶
func (driver *HuggingfaceDriver) CreateTextEmbeddings(text string) ([]float32, error)
type JsonOutputParser ¶
type JsonOutputParser[T any] struct { // contains filtered or unexported fields }
This is an expansion of https://github.com/tmc/langchaingo/outputparsers/Structured This can take more generic structured types such as arrays and fields with nested json values
func NewJsonOutputParser ¶
func NewJsonOutputParser[T any](sample_val T) JsonOutputParser[T]
This takes an input value as a sample value It includes the json schema of the type T and the sample value itself as part of the format instruction to increase chances of accuracy
func (JsonOutputParser[T]) GetFormatInstructions ¶
func (p JsonOutputParser[T]) GetFormatInstructions() string
GetFormatInstructions returns a string explaining how the llm should format its response.
func (JsonOutputParser[T]) ParseT ¶
func (p JsonOutputParser[T]) ParseT(text string) (T, error)
Parse parses the output of an LLM into a map. If the content fails to serialize it will return an error or else it will return a value of type T
func (JsonOutputParser[T]) ParseWithPrompt ¶
func (p JsonOutputParser[T]) ParseWithPrompt(text string, _ llms.PromptValue) (any, error)
ParseWithPrompt does the same as Parse.
func (JsonOutputParser[T]) Type ¶
func (p JsonOutputParser[T]) Type() string
Type returns the type of the output parser.
type JsonValueExtraction ¶
type JsonValueExtraction struct {
// contains filtered or unexported fields
}
func NewJsonValueExtraction ¶
func NewJsonValueExtraction[T any](llm llms.Model, sample_input string, sample_output *T) *JsonValueExtraction
func (JsonValueExtraction) Call ¶
func (c JsonValueExtraction) Call(ctx context.Context, values map[string]any, options ...chains.ChainCallOption) (map[string]any, error)
func (JsonValueExtraction) GetInputKeys ¶
func (c JsonValueExtraction) GetInputKeys() []string
GetInputKeys returns the expected input keys.
func (JsonValueExtraction) GetMemory ¶
func (c JsonValueExtraction) GetMemory() schema.Memory
GetMemory returns the memory.
func (JsonValueExtraction) GetOutputKeys ¶
func (c JsonValueExtraction) GetOutputKeys() []string
GetOutputKeys returns the output keys the chain will return.
type KeyConcept ¶
type ParrotboxClient ¶
type ParrotboxClient struct {
// contains filtered or unexported fields
}
func NewParrotboxClient ¶
func NewParrotboxClient(api_key string) *ParrotboxClient
func (*ParrotboxClient) ExtractDigests ¶
func (client *ParrotboxClient) ExtractDigests(texts []string) []Digest
func (*ParrotboxClient) ExtractKeyConcepts ¶
func (client *ParrotboxClient) ExtractKeyConcepts(texts []string) []KeyConcept
type ParseError ¶
func (ParseError) Error ¶
func (err ParseError) Error() string