Documentation
¶
Index ¶
- type AppState
- type DocumentCollection
- type DocumentEmbeddings
- type EmbeddingModel
- type Entity
- type EntityMatch
- type EntityRequest
- type EntityRequestRecord
- type EntityResponse
- type EntityResponseRecord
- type Extractor
- type Intent
- type IntentCollection
- type IntentPromptTemplateData
- type IntentResponse
- type Memory
- type MemorySearchPayload
- type MemorySearchResult
- type MemoryStore
- type Message
- type MessageEvent
- type MessageMetadata
- type Session
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppState ¶
type AppState struct { OpenAIClient *openairetryclient.OpenAIRetryClient MemoryStore MemoryStore[any] Config *config.Config }
AppState is a struct that holds the state of the application Use cmd.NewAppState to create a new instance
type DocumentCollection ¶ added in v0.6.5
type DocumentCollection struct { UUID uuid.UUID `json:"uuid,omitempty"` Name string `json:"name,omitempty"` Documents []DocumentEmbeddings `json:"documents"` }
type DocumentEmbeddings ¶ added in v0.6.5
type EmbeddingModel ¶ added in v0.6.5
type Entity ¶ added in v0.5.0
type Entity struct { Name string `json:"name"` Label string `json:"label"` Matches []EntityMatch `json:"matches"` }
type EntityMatch ¶ added in v0.5.0
type EntityRequest ¶ added in v0.5.0
type EntityRequest struct {
Texts []EntityRequestRecord `json:"texts"`
}
type EntityRequestRecord ¶ added in v0.5.0
type EntityResponse ¶ added in v0.5.0
type EntityResponse struct {
Texts []EntityResponseRecord `json:"texts"`
}
type EntityResponseRecord ¶ added in v0.5.0
type Extractor ¶
type Extractor interface { Extract( ctx context.Context, appState *AppState, messageEvents *MessageEvent, ) error Notify(ctx context.Context, appState *AppState, messageEvents *MessageEvent) error }
Extractor is an interface that defines the methods that must be implemented by an Extractor
type IntentCollection ¶ added in v0.7.0
type IntentPromptTemplateData ¶ added in v0.7.0
type IntentPromptTemplateData struct {
Input string
}
type IntentResponse ¶ added in v0.7.0
type IntentResponse struct {
Intent string `json:"intent"`
}
type MemorySearchPayload ¶ added in v0.6.0
type MemorySearchResult ¶ added in v0.6.0
type MemoryStore ¶
type MemoryStore[T any] interface { // GetMemory returns the most recent Summary and a list of messages for a given sessionID. // GetMemory returns: // - the most recent Summary, if one exists // - the lastNMessages messages, if lastNMessages > 0 // - all messages since the last SummaryPoint, if lastNMessages == 0 // - if no Summary (and no SummaryPoint) exists and lastNMessages == 0, returns // all undeleted messages GetMemory(ctx context.Context, appState *AppState, sessionID string, lastNMessages int) (*Memory, error) // GetSummary retrieves the most recent Summary for a given sessionID. The Summary return includes the UUID of the // SummaryPoint, which the most recent Message in the collection of messages that was used to generate the Summary. GetSummary(ctx context.Context, appState *AppState, sessionID string) (*Summary, error) // PutMemory stores a Memory for a given sessionID. If the SessionID doesn't exist, a new one is created. PutMemory(ctx context.Context, appState *AppState, sessionID string, memoryMessages *Memory, skipNotify bool) error // skipNotify is used to prevent loops when calling NotifyExtractors. // PutSummary stores a new Summary for a given sessionID. PutSummary(ctx context.Context, appState *AppState, sessionID string, summary *Summary) error // PutMessageMetadata creates, updates, or deletes metadata for a given message, and does not // update the message itself. // isPrivileged indicates whether the caller is privileged to add or update system metadata. PutMessageMetadata(ctx context.Context, appState *AppState, sessionID string, messageMetaSet []MessageMetadata, isPrivileged bool) error // PutMessageVectors stores a collection of DocumentEmbeddings for a given sessionID. PutMessageVectors(ctx context.Context, appState *AppState, sessionID string, embeddings []DocumentEmbeddings) error // GetMessageVectors retrieves a collection of DocumentEmbeddings for a given sessionID. GetMessageVectors(ctx context.Context, appState *AppState, sessionID string) ([]DocumentEmbeddings, error) // SearchMemory retrieves a collection of SearchResults for a given sessionID and query. Currently, The // MemorySearchResult structure can include both Messages and Summaries. Currently, we only search Messages. SearchMemory( ctx context.Context, appState *AppState, sessionID string, query *MemorySearchPayload, limit int) ([]MemorySearchResult, error) // DeleteSession deletes all records for a given sessionID. This is a soft delete. Hard deletes will be handled // by a separate process or left to the implementation. DeleteSession(ctx context.Context, sessionID string) error // OnStart is called when the application starts. This is a good place to initialize any resources or configs that // are required by the MemoryStore implementation. OnStart(ctx context.Context, appState *AppState) error // Attach is used by Extractors to register themselves with the MemoryStore. This allows the MemoryStore to notify // the Extractors when new occur. Attach(observer Extractor) // NotifyExtractors notifies all registered Extractors of a new MessageEvent. NotifyExtractors( ctx context.Context, appState *AppState, eventData *MessageEvent, ) // PurgeDeleted hard deletes all deleted data in the MemoryStore. PurgeDeleted(ctx context.Context) error // Close is called when the application is shutting down. This is a good place to clean up any resources used by // the MemoryStore implementation. Close() error }
MemoryStore interface
type MessageEvent ¶
type MessageMetadata ¶ added in v0.5.0
type MessageMetadata struct { UUID uuid.UUID `json:"uuid"` Key string `json:"key"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
MessageMetadata is used internally to marshal metadata updates for a given message. Key is the metadata key to update. If the key doesn't exist, it will be created. If the key exists, the value will be updated. Metadata is a map of key/value pairs to create or update at the given Key. An empty Metadata map will delete the given Key.
type Summary ¶
type Summary struct { UUID uuid.UUID `json:"uuid"` CreatedAt time.Time `json:"created_at"` Content string `json:"content"` SummaryPointUUID uuid.UUID `json:"recent_message_uuid"` // The most recent message UUID that was used to generate this summary Metadata map[string]interface{} `json:"metadata,omitempty"` TokenCount int `json:"token_count"` }
Click to show internal directories.
Click to hide internal directories.