OpenAIEmbeddingOperator

Use the OpenAIEmbeddingOperator to interact with Open APIs to create embeddings for given text.

Using the Operator

The OpenAIEmbeddingOperator requires the input_text as an input to embedding API. Use the conn_id parameter to specify the OpenAI connection to use to connect to your account.

An example using the operator is in way:

tests/system/providers/openai/example_openai.py[source]

    OpenAIEmbeddingOperator(
        task_id="embedding_using_xcom_data",
        conn_id="openai_default",
        input_text=task_to_store_input_text_in_xcom(),
        model="text-embedding-ada-002",
    )

    OpenAIEmbeddingOperator(
        task_id="embedding_using_callable",
        conn_id="openai_default",
        input_text=input_text_callable(
            "input_arg1_value",
            "input2_value",
            input_kwarg1="input_kwarg1_value",
            input_kwarg2="input_kwarg2_value",
        ),
        model="text-embedding-ada-002",
    )
    OpenAIEmbeddingOperator(
        task_id="embedding_using_text",
        conn_id="openai_default",
        input_text=texts,
        model="text-embedding-ada-002",
    )

Was this entry helpful?