Documentation
¶
Overview ¶
Package reranker provides the Reranker agent that uses tool calls to select the most relevant topics from vector search candidates.
Index ¶
Constants ¶
const ( // ParamCandidates is the key for reranker candidates ([]Candidate). ParamCandidates = "candidates" // ParamPersonCandidates is the key for person candidates ([]PersonCandidate) (v0.5.1). ParamPersonCandidates = "person_candidates" // ParamArtifactCandidates is the key for artifact candidates ([]ArtifactCandidate) (v0.6.0). ParamArtifactCandidates = "artifact_candidates" // ParamContextualizedQuery is the key for enriched query (string). ParamContextualizedQuery = "contextualized_query" // ParamOriginalQuery is the key for original user query (string). ParamOriginalQuery = "original_query" // ParamCurrentMessages is the key for recent conversation (string). ParamCurrentMessages = "current_messages" // ParamMediaParts is the key for multimodal content ([]interface{}). ParamMediaParts = "media_parts" )
Request parameters for Reranker agent.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArtifactCandidate ¶ added in v0.6.0
type ArtifactCandidate struct {
ArtifactID int64
Score float32
FileType string
OriginalName string
Summary string
Keywords []string
Entities []string // Named entities (people, companies, code mentioned)
RAGHints []string // Questions this artifact might answer
}
ArtifactCandidate is an artifact candidate for reranking (v0.6.0).
type ArtifactSelection ¶ added in v0.6.0
type ArtifactSelection struct {
Reason string `json:"reason"`
ID string `json:"id"` // Format: "Artifact:N"
}
ArtifactSelection represents a selected artifact with explanation (v0.6.0). ID is stored as string with prefix "Artifact:N" for unified ID format.
func (*ArtifactSelection) GetNumericID ¶ added in v0.6.0
func (a *ArtifactSelection) GetNumericID() (int64, error)
GetNumericID extracts numeric ID from "Artifact:N" format.
type Candidate ¶
type Candidate struct {
TopicID int64
Score float32
Topic storage.Topic
MessageCount int
SizeChars int // Estimated: MessageCount * avgCharsPerMessage
}
Candidate is a topic candidate for reranking.
type MessageRepository ¶
type MessageRepository interface {
GetMessagesByTopicID(ctx context.Context, topicID int64) ([]storage.Message, error)
}
MessageRepository is the interface for loading topic messages.
type PersonCandidate ¶ added in v0.5.1
PersonCandidate is a person candidate for reranking (v0.5.1).
type PersonSelection ¶ added in v0.5.1
type PersonSelection struct {
Reason string `json:"reason"`
ID string `json:"id"` // Format: "Person:N"
}
PersonSelection represents a selected person with explanation (v0.5.1). ID is stored as string with prefix "Person:N" for unified ID format.
func (*PersonSelection) GetNumericID ¶ added in v0.5.4
func (p *PersonSelection) GetNumericID() (int64, error)
GetNumericID extracts numeric ID from "Person:N" format.
type ReasoningEntry ¶
ReasoningEntry holds reasoning text for one iteration.
type Reranker ¶
type Reranker struct {
// contains filtered or unexported fields
}
Reranker uses tool calls to select the most relevant topics from vector search candidates.
func New ¶
func New( client openrouter.Client, cfg *config.Config, logger *slog.Logger, translator *i18n.Translator, msgRepo MessageRepository, agentLogger *agentlog.Logger, ) *Reranker
New creates a new Reranker agent.
func (*Reranker) Capabilities ¶
func (r *Reranker) Capabilities() agent.Capabilities
Capabilities returns the agent's capabilities.
func (*Reranker) Description ¶
Description returns a human-readable description.
func (*Reranker) Execute ¶
Execute runs the reranker with the given request. Required params: candidates, contextualized_query, original_query, current_messages Optional params: media_parts, person_candidates (v0.5.1), artifact_candidates (v0.6.0) Uses SharedContext for user_profile and recent_topics if available.
type Result ¶
type Result struct {
Topics []TopicSelection // Final selected topics with reasons
People []PersonSelection // Final selected people with reasons (v0.5.1)
Artifacts []ArtifactSelection // Final selected artifacts with reasons (v0.6.0)
}
Result contains the output of the reranker.
func (*Result) ArtifactIDs ¶ added in v0.6.0
ArtifactIDs returns just the artifact IDs (v0.6.0).
type TopicSelection ¶
type TopicSelection struct {
Reason string `json:"reason"`
ID string `json:"id"` // Format: "Topic:N"
}
TopicSelection represents a selected topic with explanation. ID is stored as string with prefix "Topic:N" for unified ID format.
func (*TopicSelection) GetNumericID ¶ added in v0.5.4
func (t *TopicSelection) GetNumericID() (int64, error)
GetNumericID extracts numeric ID from "Topic:N" format.