CohereEmbeddingOperator

使用 CohereEmbeddingOperator 與 Cohere API 互動,為給定文字建立 embedding(嵌入向量)。

使用 Operator

CohereEmbeddingOperator 需要 input_text 作為 embedding API 的輸入。使用 conn_id 引數指定用於連線到你的賬戶的 Cohere 連線。

示例程式碼:

tests/system/cohere/example_cohere_embedding_operator.py

texts = [
    "On Kernel-Target Alignment. We describe a family of global optimization procedures",
    " that automatically decompose optimization problems into smaller loosely coupled",
    " problems, then combine the solutions of these with message passing algorithms.",
]

CohereEmbeddingOperator(input_text=texts, task_id="embedding_via_text")
CohereEmbeddingOperator(input_text=texts[0], task_id="embedding_via_task")

此條目有幫助嗎?