Documentation
¶
Index ¶
- Variables
- type CSVSource
- type Config
- type Event
- type EventBus
- type EventHandler
- type EventType
- type IngestionEngine
- func (ie *IngestionEngine) IngestCSV(ctx context.Context, filePath string) error
- func (ie *IngestionEngine) IngestDirectory(ctx context.Context, dirPath string) error
- func (ie *IngestionEngine) IngestDocx(ctx context.Context, filePath string) error
- func (ie *IngestionEngine) IngestFile(ctx context.Context, filePath string) error
- func (ie *IngestionEngine) IngestJSON(ctx context.Context, filePath string) error
- func (ie *IngestionEngine) IngestJSONL(ctx context.Context, filePath string) error
- func (ie *IngestionEngine) IngestPDF(ctx context.Context, filePath string) error
- func (ie *IngestionEngine) IngestRawText(ctx context.Context, source, text string) error
- func (ie *IngestionEngine) IngestText(ctx context.Context, filePath string) error
- func (ie *IngestionEngine) IngestURL(ctx context.Context, url string) error
- type JSONSource
- type KnowledgeSearchTool
- type PDFSource
- type Source
- type StringSource
- type TextFileSource
- type TokenSplitter
- type URLSource
Constants ¶
This section is empty.
Variables ¶
var GlobalKnowledgeBus = &EventBus{}
GlobalKnowledgeBus is the default event bus for knowledge events.
Functions ¶
This section is empty.
Types ¶
type CSVSource ¶
type CSVSource struct {
FilePaths []string
}
CSVSource provides knowledge from .csv files.
func (*CSVSource) Identifier ¶
type Config ¶
type Config struct {
ResultsLimit int `yaml:"results_limit" json:"results_limit"` // Default: 3
ScoreThreshold float64 `yaml:"score_threshold" json:"score_threshold"` // Default: 0.35
CollectionName string `yaml:"collection_name" json:"collection_name"` // Default: "knowledge"
}
Config controls knowledge retrieval behavior.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default knowledge configuration.
type Event ¶
type Event struct {
Type EventType `json:"type"`
Timestamp time.Time `json:"timestamp"`
Query string `json:"query,omitempty"`
Source string `json:"source,omitempty"`
Results int `json:"results,omitempty"`
Error string `json:"error,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Event represents a knowledge lifecycle event.
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus distributes knowledge events to registered handlers.
func (*EventBus) Subscribe ¶
func (b *EventBus) Subscribe(handler EventHandler)
Subscribe registers a handler to receive knowledge events.
type EventHandler ¶
type EventHandler func(Event)
EventHandler is a callback function for knowledge events.
type EventType ¶
type EventType string
EventType identifies the kind of knowledge event.
const ( EventRetrievalStarted EventType = "knowledge.retrieval.started" EventRetrievalCompleted EventType = "knowledge.retrieval.completed" EventQueryStarted EventType = "knowledge.query.started" EventQueryCompleted EventType = "knowledge.query.completed" EventQueryFailed EventType = "knowledge.query.failed" EventSearchFailed EventType = "knowledge.search.failed" EventIngestionStarted EventType = "knowledge.ingestion.started" EventIngestionCompleted EventType = "knowledge.ingestion.completed" )
type IngestionEngine ¶
type IngestionEngine struct {
Store memory.Store
LLM llm.Client // Used purely for the vector Translation
Splitter *TokenSplitter
ThroughputDelay time.Duration // Mandatory delay between chunks
}
IngestionEngine takes physical files, chunks them, and saves them into the Agent's Vector Memory.
func (*IngestionEngine) IngestCSV ¶
func (ie *IngestionEngine) IngestCSV(ctx context.Context, filePath string) error
IngestCSV reads a CSV file and converts each row to a text chunk. First row is treated as headers; each subsequent row becomes "header1: value1, header2: value2, ..." for semantic embedding.
func (*IngestionEngine) IngestDirectory ¶
func (ie *IngestionEngine) IngestDirectory(ctx context.Context, dirPath string) error
IngestDirectory reads all supported files in a directory and loads them. Supported: .md, .txt, .csv, .json, .jsonl
func (*IngestionEngine) IngestDocx ¶
func (ie *IngestionEngine) IngestDocx(ctx context.Context, filePath string) error
IngestDocx extracts plain text natively from a Word Document's zipped XML structure.
func (*IngestionEngine) IngestFile ¶
func (ie *IngestionEngine) IngestFile(ctx context.Context, filePath string) error
IngestFile detects format by extension and ingests accordingly.
func (*IngestionEngine) IngestJSON ¶
func (ie *IngestionEngine) IngestJSON(ctx context.Context, filePath string) error
IngestJSON reads a JSON file. If the root is an array, each element becomes a chunk. If it's an object, the entire document is chunked as text.
func (*IngestionEngine) IngestJSONL ¶
func (ie *IngestionEngine) IngestJSONL(ctx context.Context, filePath string) error
IngestJSONL reads a JSON Lines file (one JSON object per line).
func (*IngestionEngine) IngestPDF ¶
func (ie *IngestionEngine) IngestPDF(ctx context.Context, filePath string) error
IngestPDF extracts plain text from a PDF document using ledongthuc/pdf.
func (*IngestionEngine) IngestRawText ¶
func (ie *IngestionEngine) IngestRawText(ctx context.Context, source, text string) error
IngestRawText ingests a raw text string directly (no file needed). Useful for programmatic ingestion of API responses, database dumps, etc.
func (*IngestionEngine) IngestText ¶
func (ie *IngestionEngine) IngestText(ctx context.Context, filePath string) error
IngestText reads a plain text file, chunks it, embeds, and stores.
type JSONSource ¶
type JSONSource struct {
FilePaths []string
}
JSONSource provides knowledge from .json files.
func (*JSONSource) Identifier ¶
func (s *JSONSource) Identifier() string
func (*JSONSource) Type ¶
func (s *JSONSource) Type() string
type KnowledgeSearchTool ¶
KnowledgeSearchTool allows agents to search specifically within the ingested knowledge base.
func NewKnowledgeSearchTool ¶
func NewKnowledgeSearchTool(store memory.Store, llm llm.Client) *KnowledgeSearchTool
func (*KnowledgeSearchTool) Description ¶
func (t *KnowledgeSearchTool) Description() string
func (*KnowledgeSearchTool) Name ¶
func (t *KnowledgeSearchTool) Name() string
func (*KnowledgeSearchTool) RequiresReview ¶
func (t *KnowledgeSearchTool) RequiresReview() bool
type PDFSource ¶
type PDFSource struct {
FilePaths []string
}
PDFSource provides knowledge from .pdf files.
func (*PDFSource) Identifier ¶
type Source ¶
type Source interface {
// Type returns the source type identifier.
Type() string
// Load returns the raw content to be ingested.
Load(ctx context.Context) (string, error)
// Identifier returns a unique key for this source (for dedup).
Identifier() string
}
Source is the interface that all knowledge sources must implement.
type StringSource ¶
StringSource provides knowledge from raw string content.
func (*StringSource) Identifier ¶
func (s *StringSource) Identifier() string
func (*StringSource) Type ¶
func (s *StringSource) Type() string
type TextFileSource ¶
type TextFileSource struct {
FilePaths []string
}
TextFileSource provides knowledge from .txt files.
func (*TextFileSource) Identifier ¶
func (s *TextFileSource) Identifier() string
func (*TextFileSource) Type ¶
func (s *TextFileSource) Type() string
type TokenSplitter ¶
TokenSplitter breaks massive document strings into manageable chunks so they can be securely embedded and loaded into Vector context windows.
func NewTokenSplitter ¶
func NewTokenSplitter(chunkSize, chunkOverlap int) *TokenSplitter
func (*TokenSplitter) SplitText ¶
func (ts *TokenSplitter) SplitText(text string) []string
SplitText assumes 1 word ≈ 1 token for basic Go architectural extraction.
type URLSource ¶
type URLSource struct {
URLs []string
}
URLSource provides knowledge from web pages.