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")

此条目有帮助吗?