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

# similarity • Rust AI Agent SDK

> similarity: Calculate cosine similarity between two texts. # Arguments * `text1` - First text * `text2` - Second text # Returns Cosine similarity score (0.0 to...

# similarity

<div className="flex items-center gap-2">
  <Badge color="blue">Async</Badge>
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**EmbeddingAgent**](../classes/EmbeddingAgent) class in the [**embedding**](../modules/embedding) module.

Calculate cosine similarity between two texts. # Arguments \* `text1` - First text \* `text2` - Second text # Returns Cosine similarity score (0.0 to 1.0)

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async def similarity(&self, text1: &str, text2: &str) -> Result<f32>
```

## Parameters

<ParamField query="text1" type="&str" required={true}>
  No description available.
</ParamField>

<ParamField query="text2" type="&str" required={true}>
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="Result<f32>">
  The result of the operation.
</ResponseField>
