reranker

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package reranker provides the Reranker agent that uses tool calls to select the most relevant topics from vector search candidates.

Index

Constants

View Source
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"
	// 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 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

type PersonCandidate struct {
	PersonID int64
	Score    float32
	Person   storage.Person
}

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     int64  `json:"id"`
}

PersonSelection represents a selected person with explanation (v0.5.1).

type ReasoningEntry

type ReasoningEntry struct {
	Iteration int    `json:"iteration"`
	Text      string `json:"text"`
}

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

func (r *Reranker) Description() string

Description returns a human-readable description.

func (*Reranker) Execute

func (r *Reranker) Execute(ctx context.Context, req *agent.Request) (*agent.Response, error)

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) Uses SharedContext for user_profile and recent_topics if available.

func (*Reranker) Type

func (r *Reranker) Type() agent.AgentType

Type returns the agent type.

type Result

type Result struct {
	Topics []TopicSelection  // Final selected topics with reasons
	People []PersonSelection // Final selected people with reasons (v0.5.1)
}

Result contains the output of the reranker.

func (*Result) PeopleIDs

func (r *Result) PeopleIDs() []int64

PeopleIDs returns just the person IDs (v0.5.1).

func (*Result) TopicIDs

func (r *Result) TopicIDs() []int64

TopicIDs returns just the topic IDs (for backward compatibility).

type TopicSelection

type TopicSelection struct {
	Reason string `json:"reason"`
	ID     int64  `json:"id"`
}

TopicSelection represents a selected topic with explanation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL