> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aurelio.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# semantic_router.schema

## EncoderType Objects

```python theme={null}
class EncoderType(Enum)
```

The type of encoder.

## EncoderInfo Objects

```python theme={null}
class EncoderInfo(BaseModel)
```

Information about an encoder.

## RouteChoice Objects

```python theme={null}
class RouteChoice(BaseModel)
```

A route choice typically output by the routers.

## Message Objects

```python theme={null}
class Message(BaseModel)
```

A message in a conversation, includes the role and content fields.

#### to\_openai

```python theme={null}
def to_openai()
```

Convert the message to an OpenAI-compatible format.

#### to\_cohere

```python theme={null}
def to_cohere()
```

Convert the message to a Cohere-compatible format.

#### to\_llamacpp

```python theme={null}
def to_llamacpp()
```

Convert the message to a LlamaCPP-compatible format.

#### to\_mistral

```python theme={null}
def to_mistral()
```

Convert the message to a Mistral-compatible format.

#### to\_voyage

```python theme={null}
def to_voyage()
```

Convert the message to a Voyage-compatible format.

#### to\_jina

```python theme={null}
def to_jina()
```

Convert the message to a Jina-compatible format.

#### \_\_str\_\_

```python theme={null}
def __str__()
```

Convert the message to a string.

## ConfigParameter Objects

```python theme={null}
class ConfigParameter(BaseModel)
```

A configuration parameter for a route. Used for remote router metadata such as
router hashes, sync locks, etc.

#### to\_pinecone

```python theme={null}
def to_pinecone(dimensions: int)
```

Convert the configuration parameter to a Pinecone-compatible format. Should

be used when upserting configuration parameters to a separate config namespace
within your Pinecone index.

**Arguments**:

* `dimensions` (`int`): The dimensions of the Pinecone index.

**Returns**:

`dict`: A Pinecone-compatible configuration parameter.

## Utterance Objects

```python theme={null}
class Utterance(BaseModel)
```

An utterance in a conversation, includes the route, utterance, function
schemas, metadata, and diff tag.

#### from\_tuple

```python theme={null}
@classmethod
def from_tuple(cls, tuple_obj: Tuple)
```

Create an Utterance object from a tuple. The tuple must contain

route and utterance as the first two elements. Then optionally
function schemas and metadata as the third and fourth elements
respectively. If this order is not followed an invalid Utterance
object will be returned.

**Arguments**:

* `tuple_obj` (`Tuple`): A tuple containing route, utterance, function schemas and metadata.

**Returns**:

`Utterance`: An Utterance object.

#### to\_tuple

```python theme={null}
def to_tuple()
```

Convert an Utterance object to a tuple.

**Returns**:

`Tuple`: A tuple containing (route, utterance, function schemas, metadata).

#### to\_str

```python theme={null}
def to_str(include_metadata: bool = False)
```

Convert an Utterance object to a string. Used for comparisons during sync

check operations.

**Arguments**:

* `include_metadata` (`bool`): Whether to include metadata in the string.

**Returns**:

`str`: A string representation of the Utterance object.

## SyncMode Objects

```python theme={null}
class SyncMode(Enum)
```

Synchronization modes for local (route layer) and remote (index) instances.

## UtteranceDiff Objects

```python theme={null}
class UtteranceDiff(BaseModel)
```

A list of Utterance objects that represent the differences between local and
remote utterances.

#### from\_utterances

```python theme={null}
@classmethod
def from_utterances(cls, local_utterances: List[Utterance],
                    remote_utterances: List[Utterance])
```

Create a UtteranceDiff object from two lists of Utterance objects.

**Arguments**:

* `local_utterances` (`List[Utterance]`): A list of Utterance objects.
* `remote_utterances` (`List[Utterance]`): A list of Utterance objects.

#### to\_utterance\_str

```python theme={null}
def to_utterance_str(include_metadata: bool = False) -> List[str]
```

Outputs the utterance diff as a list of diff strings. Returns a list

of strings showing what is different in the remote when compared to the
local. For example:

\["  route1: utterance1",
"  route1: utterance2",
"- route2: utterance3",
"- route2: utterance4"]

Tells us that the remote is missing "route2: utterance3" and "route2:
utterance4", which do exist locally. If we see:

\["  route1: utterance1",
"  route1: utterance2",
"+ route2: utterance3",
"+ route2: utterance4"]

This diff tells us that the remote has "route2: utterance3" and
"route2: utterance4", which do not exist locally.

**Arguments**:

* `include_metadata` (`bool`): Whether to include metadata in the string.

**Returns**:

`List[str]`: A list of diff strings.

#### get\_tag

```python theme={null}
def get_tag(diff_tag: str) -> List[Utterance]
```

Get all utterances with a given diff tag.

**Arguments**:

* `diff_tag` (`str`): The diff tag to filter by. Must be one of "+", "-", or " ".

**Returns**:

`List[Utterance]`: A list of Utterance objects.

#### get\_sync\_strategy

```python theme={null}
def get_sync_strategy(sync_mode: str) -> dict
```

Generates the optimal synchronization plan for local and remote instances.

**Arguments**:

* `sync_mode` (`str`): The mode to sync the routes with the remote index.

**Returns**:

`dict`: A dictionary describing the synchronization strategy.

## Metric Objects

```python theme={null}
class Metric(Enum)
```

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

## SparseEmbedding Objects

```python theme={null}
class SparseEmbedding(BaseModel)
```

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

#### from\_compact\_array

```python theme={null}
@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

```python theme={null}
@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

```python theme={null}
@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

```python theme={null}
@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

```python theme={null}
@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

```python theme={null}
def to_dict()
```

Convert a SparseEmbedding object to a dictionary.

**Returns**:

`dict`: A dictionary of sparse values.

#### to\_pinecone

```python theme={null}
def to_pinecone()
```

Convert a SparseEmbedding object to a Pinecone dictionary.

**Returns**:

`dict`: A Pinecone dictionary.

#### items

```python theme={null}
def items()
```

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

**Returns**:

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