運算子

將資料攝取到 Pinecone 索引

使用 PineconeIngestOperator 與 Pinecone API 互動以攝取向量。

使用運算子

PineconeIngestOperator 需要 vectors 作為輸入,以攝取到 Pinecone 中。使用 conn_id 參數指定要用於連線到您帳戶的 Pinecone 連線。向量也可能包含參考原始文字的中繼資料,這些中繼資料可以攝取到資料庫中。

以這種方式使用運算子的範例

tests/system/pinecone/example_dag_pinecone.py[原始碼]

PineconeIngestOperator(
    task_id="pinecone_vector_ingest",
    index_name=index_name,
    input_vectors=[
        ("id1", [1.0, 2.0, 3.0], {"key": "value"}),
        ("id2", [1.0, 2.0, 3.0]),
    ],
    namespace=namespace,
    batch_size=1,
)

建立基於 Pod 的索引

使用 CreatePodIndexOperator 與 Pinecone API 互動以建立基於 Pod 的索引。

使用運算子

CreatePodIndexOperator 需要索引詳細資訊以及 Pod 組態詳細資訊。api_keyenvironment 可以透過參數傳遞給運算子,也可以透過連線傳遞。

以這種方式使用運算子的範例

tests/system/pinecone/example_create_pod_index.py[原始碼]

# reference: https://docs.pinecone.io/reference/api/control-plane/create_index
create_index = CreatePodIndexOperator(
    task_id="pinecone_create_pod_index",
    index_name=index_name,
    dimension=3,
    replicas=1,
    shards=1,
    pods=1,
    pod_type="p1.x1",
)

建立無伺服器索引

使用 CreateServerlessIndexOperator 與 Pinecone API 互動以建立基於 Pod 的索引。

使用運算子

CreateServerlessIndexOperator 需要索引詳細資訊以及無伺服器組態詳細資訊。api_keyenvironment 可以透過參數傳遞給運算子,也可以透過連線傳遞。

以這種方式使用運算子的範例

tests/system/pinecone/example_create_serverless_index.py[原始碼]

# reference: https://docs.pinecone.io/reference/api/control-plane/create_index
create_index = CreateServerlessIndexOperator(
    task_id="pinecone_create_serverless_index",
    index_name=index_name,
    dimension=128,
    cloud="aws",
    region="us-west-2",
    metric="cosine",
)

這個條目是否有幫助?