Embed a single text.
(&self, text: &str)
| 150 | |
| 151 | /// Embed a single text. |
| 152 | pub async fn embed_one(&self, text: &str) -> Result<Vec<f32>, AiError> { |
| 153 | let results = self.embed(&[text.to_string()]).await?; |
| 154 | results.into_iter().next().ok_or(AiError::EmptyResponse) |
| 155 | } |
| 156 | |
| 157 | /// Synchronous embed using a throwaway tokio runtime (for use in non-async contexts). |
| 158 | /// |