Struct txtai::embeddings::Embeddings
source · pub struct Embeddings { /* private fields */ }
Expand description
Embeddings definition
Implementations§
source§impl Embeddings
impl Embeddings
Embeddings implementation
sourcepub fn new() -> Embeddings
pub fn new() -> Embeddings
Creates an Embeddings instance.
sourcepub fn with_url(url: &str) -> Embeddings
pub fn with_url(url: &str) -> Embeddings
sourcepub fn with_url_token(url: &str, token: &str) -> Embeddings
pub fn with_url_token(url: &str, token: &str) -> Embeddings
sourcepub async fn query(
&self,
query: &str,
limit: i32,
weights: Option<f32>,
index: Option<&str>
) -> APIResponse
pub async fn query( &self, query: &str, limit: i32, weights: Option<f32>, index: Option<&str> ) -> APIResponse
Runs an Embeddings search. Returns Response. This method allows callers to customize the serialization of the response.
§Arguments
query
- query textlimit
- maximum resultsweights
- hybrid score weights, if applicableindex
- index name, if applicable
sourcepub async fn search(
&self,
query: &str,
limit: i32,
weights: Option<f32>,
index: Option<&str>
) -> SearchResults
pub async fn search( &self, query: &str, limit: i32, weights: Option<f32>, index: Option<&str> ) -> SearchResults
Finds documents in the embeddings model most similar to the input query. Returns a list of {id: value, score: value} sorted by highest score, where id is the document id in the embeddings model.
§Arguments
query
- query textlimit
- maximum resultsweights
- hybrid score weights, if applicableindex
- index name, if applicable
sourcepub async fn batchsearch(
&self,
queries: &Vec<&str>,
limit: i32,
weights: Option<f32>,
index: Option<&str>
) -> SearchResultsBatch
pub async fn batchsearch( &self, queries: &Vec<&str>, limit: i32, weights: Option<f32>, index: Option<&str> ) -> SearchResultsBatch
Finds documents in the embeddings model most similar to the input queries. Returns a list of {id: value, score: value} sorted by highest score per query, where id is the document id in the embeddings model.
§Arguments
queries
- queries textlimit
- maximum resultsweights
- hybrid score weights, if applicableindex
- index name, if applicable
sourcepub async fn add<T: Serialize>(&self, documents: &Vec<T>) -> APIResponse
pub async fn add<T: Serialize>(&self, documents: &Vec<T>) -> APIResponse
sourcepub async fn index(&self) -> APIResponse
pub async fn index(&self) -> APIResponse
Builds an embeddings index for previously batched documents.
sourcepub async fn upsert(&self) -> APIResponse
pub async fn upsert(&self) -> APIResponse
Runs an embeddings upsert operation for previously batched documents.
sourcepub async fn delete(&self, ids: &Vec<&str>) -> Ids
pub async fn delete(&self, ids: &Vec<&str>) -> Ids
Deletes from an embeddings index. Returns list of ids deleted.
§Arguments
ids
- list of ids to delete
sourcepub async fn reindex(
&self,
config: HashMap<&str, &str>,
function: Option<&str>
) -> APIResponse
pub async fn reindex( &self, config: HashMap<&str, &str>, function: Option<&str> ) -> APIResponse
Recreates this embeddings index using config. This method only works if document content storage is enabled.
sourcepub async fn similarity(&self, query: &str, texts: &Vec<&str>) -> IndexResults
pub async fn similarity(&self, query: &str, texts: &Vec<&str>) -> IndexResults
Computes the similarity between query and list of text. Returns a list of {id: value, score: value} sorted by highest score, where id is the index in texts.
§Arguments
query
- query texttexts
- list of text
sourcepub async fn batchsimilarity(
&self,
queries: &Vec<&str>,
texts: &Vec<&str>
) -> IndexResultsBatch
pub async fn batchsimilarity( &self, queries: &Vec<&str>, texts: &Vec<&str> ) -> IndexResultsBatch
Computes the similarity between list of queries and list of text. Returns a list of {id: value, score: value} sorted by highest score per query, where id is the index in texts.
§Arguments
queries
- queries texttexts
- list of text