xtrace_sdk.retrievers package

Submodules

xtrace_sdk.retrievers.base module

class xtrace_sdk.retrievers.base.RetrieverBase(embedding_model: Embedding, aes_client: AESClient, homomorphic_client: Type[HammingClientBase], compute_integration: Type[ComputeIntegrationBase], **kwargs)

Bases: ABC

This class is interface for all retrievers.

Parameters:

ABC (class) – abstract base class

static format_context(contexts)

Helper method for formatting contexts

Parameters:

contexts (list[str]) – list of contexts

Returns:

formatted contexts

Return type:

str

abstractmethod nn_search_for_ids(prompt, k=3, **kwargs)

Given an encrypted prompt, return the k most similar encrypted contexts.

Parameters:
  • prompt (ciphertext) – encrypted prompt

  • k (int, optional) – the number of most similar context data to return, defaults to 3

abstractmethod retrieve_and_decrypt(chunk_ids, **kwargs)

Given a list of chunk ids, return the decrypted contexts.

Parameters:

chunk_ids (list[str]) – list of chunk ids

xtrace_sdk.retrievers.simple_retriever module

class xtrace_sdk.retrievers.simple_retriever.SimpleRetriever(embedding_model: Embedding, aes_client: AESClient, homomorphic_client: Type[HammingClientBase], compute_integration: Type[ComputeIntegrationBase])

Bases: RetrieverBase

This class is a simple retriever that uses hamming distance to find the most similar context data.

Parameters:

RetrieverBase (class) – abstract base class for retrievers

async nn_search_for_ids(query, k=3, include_scores=False, **kwargs)

Given an encrypted prompt, return the k most similar encrypted contexts.

Parameters:
  • prompt (ciphertext) – encrypted prompt

  • k (int, optional) – the number of most similar context data to return, defaults to 3

async nn_search_for_ids_bench(query, k=3, **kwargs)
async retrieve_and_decrypt(chunk_ids, **kwargs)

Given a list of chunk ids, return the decrypted contexts.

Parameters:

chunk_ids (list[str]) – list of chunk ids

Module contents