search

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package search provides shared search types and logic for semantic search over stored LLM sessions. It is used by both the REST API endpoint and the MCP server tool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	Query string `json:"query"`
	TopK  int    `json:"top_k,omitempty"`
}

Input represents the input arguments for a search request.

type Output

type Output struct {
	Query   string   `json:"query"`
	Results []Result `json:"results"`
	Count   int      `json:"count"`
}

Output represents the output of a search operation.

type Result

type Result struct {
	Hash    string  `json:"hash"`
	Score   float32 `json:"score"`
	Role    string  `json:"role"`
	Preview string  `json:"preview"`
	Turns   int     `json:"turns"`
	Branch  []Turn  `json:"branch"`
}

Result represents a single search result.

type Searcher

type Searcher struct {
	// contains filtered or unexported fields
}

func NewSearcher

func NewSearcher(
	ctx context.Context,
	embedder embeddings.Embedder,
	vectorDriver vector.Driver,
	dagLoader merkle.DagLoader,
	log *slog.Logger,
) *Searcher

func (*Searcher) BuildResult

func (s *Searcher) BuildResult(result vector.QueryResult, dag *merkle.Dag) Result

BuildResult converts a vector query result and DAG into a Result.

func (*Searcher) Search

func (s *Searcher) Search(
	query string,
	topK int,
) (*Output, error)

Search performs a semantic search over stored LLM sessions. It embeds the query text, queries the vector store for similar documents, then loads the full conversation branch from the Merkle DAG for each result.

type Turn

type Turn struct {
	Hash    string `json:"hash"`
	Role    string `json:"role"`
	Text    string `json:"text"`
	Matched bool   `json:"matched,omitempty"`
}

Turn represents a single turn in a conversation.

Jump to

Keyboard shortcuts

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