reranker

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 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"
	// 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 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 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
	PeopleIDs []int64          // For future Social Graph (v0.5)
}

Result contains the output of the reranker.

func (*Result) TopicIDs

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

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

type TopicSelection

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

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