nlp

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SEARCH_QUERY    = "search_query"
	SEARCH_DOCUMENT = "search_document"
	CLASSIFICATION  = "classification"
	SIMILARITY      = "clustering"
)
View Source
const (
	SHORT_DELAY    = 10 * time.Millisecond
	LONG_DELAY     = 10 * time.Second
	RETRY_ATTEMPTS = 3
)

Variables

This section is empty.

Functions

func CountTokens

func CountTokens(texts []string) int

func TruncateTextOnTokenCount

func TruncateTextOnTokenCount(text string) string

Types

type Digest

type Digest struct {
	Summary string `json:"summary,omitempty" bson:"summary,omitempty" jsonschema_description:"A concise summary of the document"`
	Topic   string `` /* 253-byte string literal not displayed */
}

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]) Parse

func (p JsonOutputParser[T]) Parse(text string) (any, error)

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 KeyConcept struct {
	KeyPhrase   string `` /* 267-byte string literal not displayed */
	Event       string `` /* 226-byte string literal not displayed */
	Description string `json:"description"  jsonschema_description:"A concise summary of the 'event' associated to the 'keyphrase'"`
}

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

type ParseError struct {
	Text   string
	Reason string
}

func (ParseError) Error

func (err ParseError) Error() string

Jump to

Keyboard shortcuts

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