Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

pyrit.embedding

Embedding module for PyRIT to provide OpenAI text embedding class.

OpenAITextEmbedding

Bases: EmbeddingSupport

Text embedding class that works with both Azure OpenAI and platform OpenAI endpoints. Uses the AsyncOpenAI client under the hood for both providers since they share the same API.

Constructor Parameters:

ParameterTypeDescription
api_key`strCallable[[], str
endpoint`strNone`
model_name`strNone`

Methods:

generate_text_embedding

generate_text_embedding(text: str, kwargs: Any = {}) → EmbeddingResponse

Generate text embedding synchronously by calling the async method.

ParameterTypeDescription
textstrThe text to generate the embedding for
**kwargsAnyAdditional arguments to pass to the embeddings API Defaults to {}.

Returns:

generate_text_embedding_async

generate_text_embedding_async(text: str, kwargs: Any = {}) → EmbeddingResponse

Generate text embedding asynchronously.

ParameterTypeDescription
textstrThe text to generate the embedding for
**kwargsAnyAdditional arguments to pass to the embeddings API Defaults to {}.

Returns: