airflow.providers.openai.operators.openai

Module Contents

Classes

OpenAIEmbeddingOperator

Operator that accepts input text to generate OpenAI embeddings using the specified model.

class airflow.providers.openai.operators.openai.OpenAIEmbeddingOperator(conn_id, input_text, model='text-embedding-ada-002', embedding_kwargs=None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Operator that accepts input text to generate OpenAI embeddings using the specified model.

Parameters
  • conn_id (str) – The OpenAI connection ID to use.

  • input_text (str | list[str] | list[int] | list[list[int]]) – The text to generate OpenAI embeddings for. This can be a string, a list of strings, a list of integers, or a list of lists of integers.

  • model (str) – The OpenAI model to be used for generating the embeddings.

  • embedding_kwargs (dict | None) – Additional keyword arguments to pass to the OpenAI create_embeddings method.

See also

For more information on how to use this operator, take a look at the guide: OpenAIEmbeddingOperator For possible options for embedding_kwargs, see: https://platform.openai.com/docs/api-reference/embeddings/create

template_fields: Sequence[str] = ('input_text',)[source]
hook()[source]

Return an instance of the OpenAIHook.

execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?