types

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 4 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompletionMessage added in v0.9.0

type CompletionMessage struct {
	Content      string
	FunctionCall *FunctionCall `json:"function_call,omitempty"`
	FinishReason FinishReason  `json:"finish_reason,omitempty"`
}

type DBCollectionInterface added in v0.8.4

type DBCollectionInterface[T any] interface {
	BatchSet(pairs []KeyValue[T]) (int, error)
	Get(key string) (T, bool)
	GetAll() []KeyValue[T]
	ScanGet(key string) (KeyValue[T], bool)
	Set(key string, value T) error
	StartInit()
}

type Embeddings added in v0.7.12

type Embeddings struct {
	Vectors []*Vector `json:"vectors"`
}

type FileReader added in v0.8.0

type FileReader interface {
	// Open opens the file and returns a ReadCloser for accessing its contents.
	Open() (io.ReadCloser, error)
	// Name returns the name of the file.
	FilePath() string
	Stat() (fs.FileInfo, error)
}

FileReader is an interface that wraps file reading operations.

type FileWalker added in v0.8.4

type FileWalker interface {
	GetFiles() ([]FileReader, error)
}

type FinishReason added in v0.9.0

type FinishReason string
const (
	FinishReasonStop          FinishReason = "stop"
	FinishReasonLength        FinishReason = "length"
	FinishReasonFunctionCall  FinishReason = "function_call"
	FinishReasonContentFilter FinishReason = "content_filter"
	FinishReasonNull          FinishReason = "null"
)

type FunctionCall added in v0.9.0

type FunctionCall struct {
	Name      string `json:"name,omitempty"`
	Arguments string `json:"arguments,omitempty"`
}

type ITzap

type ITzap[T any, Z any] interface {
	AddUserMessage(contents ...string) T
	AddAssistantMessage(contents ...string) T
	AddSystemMessage(contents ...string) T
	SetInitialSystemContent(content string) T

	LoadFileDir(dir string) T
	LoadFiles(filepaths []string) T
	ChangeFilepath(filepath string) T

	LoadCompletion(filepath string) T
	LoadCompletionOrRequestCompletionMD5(filePath string) T
	LoadCompletionOrRequestCompletion(filepath string) T

	RequestChatCompletion() T
	StoreCompletion(filePath string) T
	RequestTextToSpeech(language, voice string) T

	//Tzap Primitives
	New() T
	AddTzap(tc T) T
	HijackTzap(tc T) T
	CloneTzap(tc T) T

	//ControlFlow
	WorkTzap(fn func(t T)) T
	IsolatedTzap(fn func(t T)) T
	MutationTzap(fn func(t T) T) T
	Map(func(t T) T) T
	Accumulate(func(t T) T) T
	Exit() T

	ApplyWorkflow(nt NamedWorkflow[T, Z]) T
	ApplyErrorWorkflow(nt NamedWorkflow[T, Z], fn func(t Z) error) T
	ApplyWorkflowFN(nt func(t T) T) T
	ApplyWorkflowP(T) T

	Recursive(func(tzapThatCreatesNewChildren T) T) T
	CheckAndHandleGlobalOccurrences(references int, filename string, noOccurrence, handleOccurrence func(T) T) T
	CheckAndHandleRecurrences(references int, filename string, noReccurance, handleRecurrence func(T) T) T
	FileMustContainHandleGlobalOccurrences(references int, filename string, noOccurrence, handleOccurrence func(T) T) T

	CountTokens(content string) (int, error)
	OffsetTokens(content string, from int, to int) (string, error)
}

type KeyValue added in v0.7.12

type KeyValue[T any] struct {
	Key   string `json:"key"`
	Value T      `json:"value"`
}

type MappedInterface

type MappedInterface map[string]interface{}

type Message

type Message struct {
	Role    string
	Content string
}

type Metadata added in v0.8.1

type Metadata struct {
	ID            string `json:"id"`
	Filename      string `json:"filename"`
	Start         int    `json:"start"`
	End           int    `json:"end"`
	LineStart     int    `json:"lineStart"`
	TruncatedEnd  int    `json:"truncatedEnd"`
	SplitPart     string `json:"splitPart"`
	RealSplitPart string `json:"realSplitPart"`
}

type NamedWorkflow added in v0.7.14

type NamedWorkflow[T any, Z any] struct {
	Name     string
	Workflow func(t T) Z // Assuming the function takes no arguments and returns no values
}

type Query added in v0.7.12

type Query struct {
	Values [1536]float32 `json:"values"`
}

type QueryFilter added in v0.7.12

type QueryFilter struct {
	Filter map[string]string `json:"filter"`
	Values [1536]float32     `json:"values"`
}

type QueryJson added in v0.7.12

type QueryJson struct {
	Queries []Query `json:"queries"`
}

type QueryRequest added in v0.7.12

type QueryRequest struct {
	TopK            int           `json:"topK"`
	IncludeMetadata bool          `json:"includeMetadata"`
	Namespace       string        `json:"namespace"`
	Queries         []QueryFilter `json:"queries"`
}

type SearchResult added in v0.8.1

type SearchResult struct {
	Vector     Vector    `json:"vector"`
	PCA        []float32 `json:"pca"`
	Similarity float32   `json:"score"`
}

type SearchResults added in v0.7.12

type SearchResults struct {
	Results []SearchResult
}

type TGenerator

type TGenerator interface {
	TextToSpeech(ctx context.Context, content, language, voice string) (*[]byte, error)
	SpeechToText(ctx context.Context, audioContent *[]byte, language string) (string, error)
	FetchEmbedding(ctx context.Context, content ...string) ([][1536]float32, error)
	AddEmbeddingDocument(ctx context.Context, id string, embedding [1536]float32, metadata Metadata) error
	GetEmbeddingDocument(ctx context.Context, id string) (Vector, bool, error)
	DeleteEmbeddingDocument(ctx context.Context, id string) error
	DeleteEmbeddingDocuments(ctx context.Context, ids []string) error
	SearchWithEmbedding(ctx context.Context, embedding QueryFilter, k int) (SearchResults, error)
	ListAllEmbeddingsIds(ctx context.Context) (SearchResults, error)
	GenerateChat(ctx context.Context, messages []Message, stream bool, functions string) (CompletionMessage, error)
	CountTokens(ctx context.Context, content string) (int, error)
	OffsetTokens(ctx context.Context, content string, from int, to int) (string, int, error)
	RawTokens(ctx context.Context, content string) ([]string, error)
}

type TzapConnector

type TzapConnector func() (TGenerator, config.Configuration)

type UnimplementedTGenerator

type UnimplementedTGenerator struct {
	TGenerator
}

type Vector added in v0.7.12

type Vector struct {
	ID        string        `json:"id"`
	TimeStamp int           `json:"timestamp"`
	Metadata  Metadata      `json:"metadata"`
	Values    [1536]float32 `json:"values"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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