pub struct EmbeddingsBuilder<M: EmbeddingModel> { /* private fields */ }
Expand description
Builder for creating a collection of embeddings
Implementations§
source§impl<M: EmbeddingModel> EmbeddingsBuilder<M>
impl<M: EmbeddingModel> EmbeddingsBuilder<M>
sourcepub fn simple_document(self, id: &str, document: &str) -> Self
pub fn simple_document(self, id: &str, document: &str) -> Self
Add a simple document to the embedding collection. The provided document string will be used for the embedding.
sourcepub fn simple_documents(self, documents: Vec<(String, String)>) -> Self
pub fn simple_documents(self, documents: Vec<(String, String)>) -> Self
Add multiple documents to the embedding collection. Each element of the vector is a tuple of the form (id, document).
sourcepub fn tool(
self,
tool: impl ToolEmbedding + 'static,
) -> Result<Self, EmbeddingError>
pub fn tool( self, tool: impl ToolEmbedding + 'static, ) -> Result<Self, EmbeddingError>
Add a tool to the embedding collection.
The tool.context()
corresponds to the document being stored while
tool.embedding_docs()
corresponds to the documents that will be used to generate the embeddings.
sourcepub fn tools(self, toolset: &ToolSet) -> Result<Self, EmbeddingError>
pub fn tools(self, toolset: &ToolSet) -> Result<Self, EmbeddingError>
Add the tools from the given toolset to the embedding collection.
sourcepub fn document<T: Serialize>(
self,
id: &str,
document: T,
embed_documents: Vec<String>,
) -> Self
pub fn document<T: Serialize>( self, id: &str, document: T, embed_documents: Vec<String>, ) -> Self
Add a document to the embedding collection.
embed_documents
are the documents that will be used to generate the embeddings
for document
.
sourcepub fn documents<T: Serialize>(
self,
documents: Vec<(String, T, Vec<String>)>,
) -> Self
pub fn documents<T: Serialize>( self, documents: Vec<(String, T, Vec<String>)>, ) -> Self
Add multiple documents to the embedding collection. Each element of the vector is a tuple of the form (id, document, embed_documents).
sourcepub fn json_document(
self,
id: &str,
document: Value,
embed_documents: Vec<String>,
) -> Self
pub fn json_document( self, id: &str, document: Value, embed_documents: Vec<String>, ) -> Self
Add a json document to the embedding collection.
sourcepub fn json_documents(
self,
documents: Vec<(String, Value, Vec<String>)>,
) -> Self
pub fn json_documents( self, documents: Vec<(String, Value, Vec<String>)>, ) -> Self
Add multiple json documents to the embedding collection.
sourcepub async fn build(self) -> Result<Vec<DocumentEmbeddings>, EmbeddingError>
pub async fn build(self) -> Result<Vec<DocumentEmbeddings>, EmbeddingError>
Generate the embeddings for the given documents