Documentation ¶
Index ¶
- func FunctionInputToTool(fi FunctionInput) openai.Tool
- type ChatCompleter
- type Completer
- type Dispatcher
- type DocStore
- type Document
- type DummyDispatcher
- type Embedder
- type FunctionInput
- type JSONParserGeneric
- type MemoryDocStore
- func (m *MemoryDocStore) Insert(ctx context.Context, d Document) error
- func (m *MemoryDocStore) Load(ctx context.Context, bucket *blob.Bucket, path string) error
- func (m *MemoryDocStore) Persist(ctx context.Context, bucket *blob.Bucket, path string) error
- func (m *MemoryDocStore) Retrieve(ctx context.Context, id string) (Document, error)
- type Moderator
- type OAITool
- type OpenAIDispatcher
- type OpenAIDispatcherConfig
- type Parser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FunctionInputToTool ¶
func FunctionInputToTool(fi FunctionInput) openai.Tool
Types ¶
type ChatCompleter ¶
type Dispatcher ¶
type Dispatcher[T any] interface { // Prompt generates an object of type T from the given prompt. Prompt(ctx context.Context, prompt string) (T, error) // PromptTemplate generates an object of type T from a given template. // The prompt is then a template string that is rendered with the given values. PromptTemplate(ctx context.Context, template *template.Template, values interface{}) (T, error) }
type Document ¶
type Document struct { ID string `json:"id"` Content string `json:"content,omitempty"` Embedding []float32 `json:"embedding,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
func NewDocumentFromString ¶
type DummyDispatcher ¶
type DummyDispatcher[T any] struct{}
func NewDummyDispatcher ¶
func NewDummyDispatcher[T any]() *DummyDispatcher[T]
func (*DummyDispatcher[T]) Prompt ¶
func (d *DummyDispatcher[T]) Prompt(ctx context.Context, prompt string) (T, error)
func (*DummyDispatcher[T]) PromptTemplate ¶
type FunctionInput ¶
type FunctionInput struct { Name string `json:"name"` Description string `json:"description,omitempty"` Parameters any `json:"parameters"` }
func StructToJsonSchema ¶
func StructToJsonSchema(functionName string, functionDescription string, inputStruct interface{}) FunctionInput
func StructToJsonSchemaGeneric ¶
func StructToJsonSchemaGeneric[T any](functionName string, functionDescription string) FunctionInput
type JSONParserGeneric ¶
type JSONParserGeneric[T any] struct { // contains filtered or unexported fields }
JSONParser is a parser that parses arbitrary JSON structs It is threadsafe and can be used concurrently. The underlying validator is threadsafe as well.
func NewJSONParserGeneric ¶
func NewJSONParserGeneric[T any](validate bool) *JSONParserGeneric[T]
NewJSONParser returns a new JSONParser validation is done via jsonschema
type MemoryDocStore ¶
MemoryDocStore is a simple in-memory document store. It's functionally a hashmap / inverted-index.
func NewMemoryDocStore ¶
func NewMemoryDocStore() *MemoryDocStore
func (*MemoryDocStore) Insert ¶
func (m *MemoryDocStore) Insert(ctx context.Context, d Document) error
Insert adds a node to the document store. It overwrites duplicates.
type OAITool ¶
type OAITool struct { // Type is always "function" for now. Type string `json:"type"` Function FunctionInput `json:"function"` }
type OpenAIDispatcher ¶
type OpenAIDispatcher[T any] struct { *OpenAIDispatcherConfig // contains filtered or unexported fields }
OpenAIDispatcher dispatches to any OpenAI compatible model. For any type T and prompt, it will generate and parse the response into T.
func NewOpenAIDispatcher ¶
func NewOpenAIDispatcher[T any](name, description, systemPrompt string, completer ChatCompleter, cfg *OpenAIDispatcherConfig) *OpenAIDispatcher[T]
func (*OpenAIDispatcher[T]) Prompt ¶
func (d *OpenAIDispatcher[T]) Prompt(ctx context.Context, prompt string) (T, error)
func (*OpenAIDispatcher[T]) PromptTemplate ¶
func (d *OpenAIDispatcher[T]) PromptTemplate(ctx context.Context, template *template.Template, values interface{}) (T, error)
PromptTemplate generates an object of type T from a given template. This is mostly a convenience wrapper around Prompt.
type OpenAIDispatcherConfig ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
Package syncpool provides a generic wrapper around sync.Pool Copied from https://github.com/mkmik/syncpool
|
Package syncpool provides a generic wrapper around sync.Pool Copied from https://github.com/mkmik/syncpool |
Click to show internal directories.
Click to hide internal directories.