Aurelio Docs
Client Reference

semantic_router.schema

EncoderType Objects

class EncoderType(Enum)

The type of encoder.

EncoderInfo Objects

class EncoderInfo(BaseModel)

Information about an encoder.

MatchedUtterance Objects

class MatchedUtterance(BaseModel)

One stored utterance that matched a query, with its raw similarity score.

Populated by index-backed routers so downstream code can see which training examples pulled the route and tune thresholds or debug misrouting.

Arguments:

  • text (str): The stored utterance text.
  • score (float): The raw similarity score between the query embedding and this utterance. Higher is more similar; the scale depends on the index metric (cosine, dotproduct, etc.) and the aggregation method.
  • route (str): The route this utterance belongs to.

RouteChoice Objects

class RouteChoice(BaseModel)

A route choice output by the routers.

Arguments:

  • name: the chosen route name, or None when every route missed the confidence threshold.
  • confidence: the route's calibrated confidence (probability) when a calibrator is fitted, otherwise the raw score.
  • calibrated: whether confidence is a calibrated probability.
  • matched_utterances: utterance-level match details when the caller opts in via router(..., return_utterances=True). Populated by IndexedRouter, and forwarded by Chain and Merge from their index-backed sub-routers. DecisionRouter leaves this as None because it never runs an index query itself.

Utterance Objects

class Utterance(BaseModel)

One record in an index: a route name, one of its utterances, and the record's metadata (the route's own metadata plus the reserved sr_ keys).

Metric Objects

class Metric(Enum)

The metric to use in vector-based similarity search indexes.

SparseEmbedding Objects

class SparseEmbedding(BaseModel)

Sparse embedding interface. Primarily uses numpy operations for faster operations.

from_compact_array

@classmethod
def from_compact_array(cls, array: np.ndarray)

Create a SparseEmbedding object from a compact array.

Arguments:

  • array (np.ndarray): A compact array.

Returns:

SparseEmbedding: A SparseEmbedding object.

from_vector

@classmethod
def from_vector(cls, vector: np.ndarray)

Consumes an array of sparse vectors containing zero-values.

Arguments:

  • vector (np.ndarray): A sparse vector.

Returns:

SparseEmbedding: A SparseEmbedding object.

from_aurelio

@classmethod
def from_aurelio(cls, embedding: "BM25SparseEmbedding")

Create a SparseEmbedding object from an AurelioSparseEmbedding object.

Arguments:

  • embedding (BM25SparseEmbedding): An AurelioSparseEmbedding object.

Returns:

SparseEmbedding: A SparseEmbedding object.

from_dict

@classmethod
def from_dict(cls, sparse_dict: dict)

Create a SparseEmbedding object from a dictionary.

Arguments:

  • sparse_dict (dict): A dictionary of sparse values.

Returns:

SparseEmbedding: A SparseEmbedding object.

from_pinecone_dict

@classmethod
def from_pinecone_dict(cls, sparse_dict: dict)

Create a SparseEmbedding object from a Pinecone dictionary.

Arguments:

  • sparse_dict (dict): A Pinecone dictionary.

Returns:

SparseEmbedding: A SparseEmbedding object.

to_dict

def to_dict()

Convert a SparseEmbedding object to a dictionary.

Returns:

dict: A dictionary of sparse values.

to_pinecone

def to_pinecone()

Convert a SparseEmbedding object to a Pinecone dictionary.

Returns:

dict: A Pinecone dictionary.

items

def items()

Return a list of (index, value) tuples from the SparseEmbedding object.

Returns:

list: A list of (index, value) tuples.

On this page