CohereEmbeddingOperator

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

使用運算子

CohereEmbeddingOperator 需要 input_text 作為嵌入 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")

這個條目有幫助嗎?