Changesets · Branches · Tags · Compare
| Changeset | a7ea54e1c0d986e8b3f4db5aaa41932b34e95badda9b9bf814c3eae711c337af |
|---|---|
| Author | Will Jones <willjones127@gmail.com> · 2024-10-17 11:58 -07:00 |
| Committer | GitHub <noreply@github.com> · 2024-10-17 11:58 -07:00 |
| Parents | 29678251014b |
1 file changed
modified rust/lancedb/src/connection.rs +20 −16
| @@ -196,22 +196,6 @@ | ||
| 196 | 196 | }; |
| 197 | 197 | Ok((data, builder)) |
| 198 | 198 | } |
| 199 | - | |
| 200 | - pub fn add_embedding(mut self, definition: EmbeddingDefinition) -> Result<Self> { | |
| 201 | - // Early verification of the embedding name | |
| 202 | - let embedding_func = self | |
| 203 | - .parent | |
| 204 | - .embedding_registry() | |
| 205 | - .get(&definition.embedding_name) | |
| 206 | - .ok_or_else(|| Error::EmbeddingFunctionNotFound { | |
| 207 | - name: definition.embedding_name.clone(), | |
| 208 | - reason: "No embedding function found in the connection's embedding_registry" | |
| 209 | - .to_string(), | |
| 210 | - })?; | |
| 211 | - | |
| 212 | - self.embeddings.push((definition, embedding_func)); | |
| 213 | - Ok(self) | |
| 214 | - } | |
| 215 | 199 | } |
| 216 | 200 | |
| 217 | 201 | // Builder methods that only apply when we do not have initial data |
| @@ -329,6 +313,26 @@ | ||
| 329 | 313 | }; |
| 330 | 314 | self |
| 331 | 315 | } |
| 316 | + | |
| 317 | + /// Add an embedding definition to the table. | |
| 318 | + /// | |
| 319 | + /// The `embedding_name` must match the name of an embedding function that | |
| 320 | + /// was previously registered with the connection's [`EmbeddingRegistry`]. | |
| 321 | + pub fn add_embedding(mut self, definition: EmbeddingDefinition) -> Result<Self> { | |
| 322 | + // Early verification of the embedding name | |
| 323 | + let embedding_func = self | |
| 324 | + .parent | |
| 325 | + .embedding_registry() | |
| 326 | + .get(&definition.embedding_name) | |
| 327 | + .ok_or_else(|| Error::EmbeddingFunctionNotFound { | |
| 328 | + name: definition.embedding_name.clone(), | |
| 329 | + reason: "No embedding function found in the connection's embedding_registry" | |
| 330 | + .to_string(), | |
| 331 | + })?; | |
| 332 | + | |
| 333 | + self.embeddings.push((definition, embedding_func)); | |
| 334 | + Ok(self) | |
| 335 | + } | |
| 332 | 336 | } |
| 333 | 337 | |
| 334 | 338 | #[derive(Clone, Debug)] |