mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-22 10:25:23 -04:00
22 lines
765 B
Python
22 lines
765 B
Python
from dify_plugin.core.entities.invocation import InvokeType
|
|
from dify_plugin.core.runtime import BackwardsInvocation
|
|
from dify_plugin.entities.model.text_embedding import TextEmbeddingResult, TextEmbeddingModelConfig
|
|
|
|
|
|
class TextEmbeddingInvocation(BackwardsInvocation[TextEmbeddingResult]):
|
|
def invoke(self, model_config: TextEmbeddingModelConfig, texts: list[str]) -> TextEmbeddingResult:
|
|
"""
|
|
Invoke text embedding
|
|
"""
|
|
for data in self._backwards_invoke(
|
|
InvokeType.TextEmbedding,
|
|
TextEmbeddingResult,
|
|
{
|
|
**model_config.model_dump(),
|
|
"texts": texts,
|
|
},
|
|
):
|
|
return data
|
|
|
|
raise Exception("No response from text embedding")
|