Documentation
¶
Index ¶
- type Agent
- func (agent *Agent) GenerateEmbedding(content string) ([]float64, error)
- func (agent *Agent) GetEmbeddingDimension() int
- func (agent *Agent) GetLastEmbeddingRequestJSON() (string, error)
- func (agent *Agent) GetLastEmbeddingRequestMetadata() EmbeddingRequestMetadata
- func (agent *Agent) GetLastEmbeddingResponseJSON() (string, error)
- func (agent *Agent) GetLastEmbeddingResponseMetadata() EmbeddingResponseMetadata
- func (agent *Agent) GetModelID() string
- func (agent *Agent) GetName() string
- func (agent *Agent) Kind() agents.Kind
- func (agent *Agent) LoadStore(storeFilePath string) error
- func (agent *Agent) PersistStore(storeFilePath string) error
- func (agent *Agent) SaveEmbedding(content string) error
- func (agent *Agent) SearchSimilar(content string, limit float64) ([]VectorRecord, error)
- func (agent *Agent) SearchTopN(content string, limit float64, n int) ([]VectorRecord, error)
- func (agent *Agent) StoreFileExists(storeFilePath string) bool
- type AgentOption
- type BaseAgent
- func (agent *BaseAgent) GenerateEmbeddingVector(content string) (embeddingVector []float64, err error)
- func (agent *BaseAgent) GenerateThenSaveEmbeddingVector(content string) (err error)
- func (agent *BaseAgent) GetEmbeddingDimension() int
- func (agent *BaseAgent) GetLastEmbeddingRequestJSON() (string, error)
- func (agent *BaseAgent) GetLastEmbeddingRequestMetadata() EmbeddingRequestMetadata
- func (agent *BaseAgent) GetLastEmbeddingResponseJSON() (string, error)
- func (agent *BaseAgent) GetLastEmbeddingResponseMetadata() EmbeddingResponseMetadata
- func (agent *BaseAgent) SearchSimilarities(content string, limit float64) (results []stores.VectorRecord, err error)
- func (agent *BaseAgent) SearchTopNSimilarities(content string, limit float64, n int) (results []stores.VectorRecord, err error)
- type EmbeddingRequestMetadata
- type EmbeddingResponseMetadata
- type Metrics
- func (m *Metrics) AvgCharsPerDocument() int
- func (m *Metrics) AvgDimensions() int
- func (m *Metrics) AvgEmbeddingTime() time.Duration
- func (m *Metrics) AvgOperationTime() time.Duration
- func (m *Metrics) AvgSearchTime() time.Duration
- func (m *Metrics) CostPerDocument(costPerThousandChars float64) float64
- func (m *Metrics) EstimateCost(costPerThousandChars float64) float64
- func (m *Metrics) RecordEmbedding(content string, dimensions int, duration time.Duration)
- func (m *Metrics) RecordSearch(duration time.Duration)
- func (m *Metrics) Reset()
- func (m *Metrics) Throughput() float64
- func (m *Metrics) TotalOperations() int
- func (m *Metrics) TotalTime() time.Duration
- type SearchSettings
- type VectorRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent represents a simplified RAG agent that hides OpenAI SDK details
func NewAgent ¶
func NewAgent( ctx context.Context, agentConfig agents.Config, modelConfig models.Config, ) (*Agent, error)
NewAgent creates a new simplified RAG agent
func (*Agent) GenerateEmbedding ¶
GenerateEmbedding creates a vector embedding for the given text content
func (*Agent) GetEmbeddingDimension ¶ added in v0.0.8
GetEmbeddingDimension returns the dimension of the embedding vectors generated by the agent's model
func (*Agent) GetLastEmbeddingRequestJSON ¶ added in v1.0.2
GetLastEmbeddingRequestJSON returns the last embedding request as JSON string
func (*Agent) GetLastEmbeddingRequestMetadata ¶ added in v1.0.2
func (agent *Agent) GetLastEmbeddingRequestMetadata() EmbeddingRequestMetadata
GetLastEmbeddingRequestMetadata returns metadata about the last embedding request
func (*Agent) GetLastEmbeddingResponseJSON ¶ added in v1.0.2
GetLastEmbeddingResponseJSON returns the last embedding response as JSON string
func (*Agent) GetLastEmbeddingResponseMetadata ¶ added in v1.0.2
func (agent *Agent) GetLastEmbeddingResponseMetadata() EmbeddingResponseMetadata
GetLastEmbeddingResponseMetadata returns metadata about the last embedding response
func (*Agent) GetModelID ¶ added in v0.0.7
func (*Agent) PersistStore ¶ added in v0.0.5
func (*Agent) SaveEmbedding ¶
SaveEmbedding generates and saves an embedding for the given content
func (*Agent) SearchSimilar ¶
func (agent *Agent) SearchSimilar(content string, limit float64) ([]VectorRecord, error)
SearchSimilar searches for similar records based on content limit is the minimum cosine similarity threshold (1.0 = exact match, 0.0 = no similarity)
func (*Agent) SearchTopN ¶
SearchTopN searches for top N similar records based on content limit is the minimum cosine similarity threshold (1.0 = exact match, 0.0 = no similarity) n is the maximum number of results to return
func (*Agent) StoreFileExists ¶ added in v0.0.5
type AgentOption ¶
type AgentOption func(*BaseAgent)
type BaseAgent ¶
type BaseAgent struct {
EmbeddingParams openai.EmbeddingNewParams
// contains filtered or unexported fields
}
func NewBaseAgent ¶
func NewBaseAgent( ctx context.Context, agentConfig agents.Config, modelConfig openai.EmbeddingNewParams, options ...AgentOption, ) (ragAgent *BaseAgent, err error)
NewBaseAgent creates a new RAG agent with OpenAI SDK integration
func (*BaseAgent) GenerateEmbeddingVector ¶
func (agent *BaseAgent) GenerateEmbeddingVector(content string) (embeddingVector []float64, err error)
GenerateEmbeddingVector creates a vector embedding for the given text content using the agent's embedding model
func (*BaseAgent) GenerateThenSaveEmbeddingVector ¶
GenerateThenSaveEmbeddingVector creates a vector embedding for the given text content
func (*BaseAgent) GetEmbeddingDimension ¶ added in v0.0.8
GetEmbeddingDimension returns the dimension of the embedding vectors generated by the agent's model
func (*BaseAgent) GetLastEmbeddingRequestJSON ¶ added in v1.0.2
GetLastEmbeddingRequestJSON returns the last embedding request as JSON string
func (*BaseAgent) GetLastEmbeddingRequestMetadata ¶ added in v1.0.2
func (agent *BaseAgent) GetLastEmbeddingRequestMetadata() EmbeddingRequestMetadata
GetLastEmbeddingRequestMetadata returns metadata about the last embedding request
func (*BaseAgent) GetLastEmbeddingResponseJSON ¶ added in v1.0.2
GetLastEmbeddingResponseJSON returns the last embedding response as JSON string
func (*BaseAgent) GetLastEmbeddingResponseMetadata ¶ added in v1.0.2
func (agent *BaseAgent) GetLastEmbeddingResponseMetadata() EmbeddingResponseMetadata
GetLastEmbeddingResponseMetadata returns metadata about the last embedding response
func (*BaseAgent) SearchSimilarities ¶
func (agent *BaseAgent) SearchSimilarities(content string, limit float64) (results []stores.VectorRecord, err error)
SearchSimilarities searches the vector store for similar records based on the embedding of the provided content and returns the top results up to the specified limit Parameters:
- content: the text content to generate an embedding for searching.
- limit: the minimum cosine distance similarity threshold. 1.0 means exact match, 0.0 means no similarity.
func (*BaseAgent) SearchTopNSimilarities ¶
func (agent *BaseAgent) SearchTopNSimilarities(content string, limit float64, n int) (results []stores.VectorRecord, err error)
SearchTopNSimilarities searches the vector store for similar records based on the embedding of the provided content and returns the top N results above the specified similarity limit Parameters:
- content: the text content to generate an embedding for searching.
- limit: the minimum cosine distance similarity threshold. 1.0 means exact match, 0.0 means no similarity.
- n: the maximum number of top similar records to return.
type EmbeddingRequestMetadata ¶ added in v1.0.2
type EmbeddingRequestMetadata struct {
Model string
InputLength int
EncodingFormat string
Dimensions int
Timestamp time.Time
}
EmbeddingRequestMetadata contains metadata about an embedding request
type EmbeddingResponseMetadata ¶ added in v1.0.2
type EmbeddingResponseMetadata struct {
Model string
EmbeddingIndex int
VectorDimension int
PromptTokens int
TotalTokens int
ResponseTime int64 // in milliseconds
Timestamp time.Time
}
EmbeddingResponseMetadata contains metadata about an embedding response
type Metrics ¶ added in v1.0.2
type Metrics struct {
TotalEmbeddings int
TotalDimensions int
TotalProcessTime time.Duration
TotalCharacters int
SearchOperations int
TotalSearchTime time.Duration
}
Metrics tracks performance and usage metrics for RAG embedding operations
func NewMetrics ¶ added in v1.0.2
func NewMetrics() *Metrics
NewMetrics creates a new Metrics instance
func (*Metrics) AvgCharsPerDocument ¶ added in v1.0.2
AvgCharsPerDocument returns the average number of characters per document
func (*Metrics) AvgDimensions ¶ added in v1.0.2
AvgDimensions returns the average number of dimensions per embedding
func (*Metrics) AvgEmbeddingTime ¶ added in v1.0.2
AvgEmbeddingTime returns the average time per embedding operation
func (*Metrics) AvgOperationTime ¶ added in v1.0.2
AvgOperationTime returns the average time per operation (embedding or search)
func (*Metrics) AvgSearchTime ¶ added in v1.0.2
AvgSearchTime returns the average time per search operation
func (*Metrics) CostPerDocument ¶ added in v1.0.2
CostPerDocument returns the estimated cost per document costPerThousandChars is the cost per 1000 characters (e.g., 0.0001 USD)
func (*Metrics) EstimateCost ¶ added in v1.0.2
EstimateCost estimates the cost of embeddings based on character count costPerThousandChars is the cost per 1000 characters (e.g., 0.0001 USD)
func (*Metrics) RecordEmbedding ¶ added in v1.0.2
RecordEmbedding records metrics for a single embedding operation
func (*Metrics) RecordSearch ¶ added in v1.0.2
RecordSearch records metrics for a search operation
func (*Metrics) Throughput ¶ added in v1.0.2
Throughput returns operations per second
func (*Metrics) TotalOperations ¶ added in v1.0.2
TotalOperations returns the total number of operations (embeddings + searches)