66from typing import TYPE_CHECKING , Any
77
88import cocoindex as coco
9- import cocoindex .asyncio as coco_aio
109import numpy as np
1110from cocoindex .resources import schema as _schema
1211from numpy .typing import NDArray
@@ -74,7 +73,7 @@ def _get_model(self) -> SentenceTransformer:
7473 )
7574 return self ._model
7675
77- @coco_aio . function (batching = True , runner = coco .GPU , memo = True , max_batch_size = _config .batch_size )
76+ @coco . fn . as_async (batching = True , runner = coco .GPU , memo = True , max_batch_size = _config .batch_size )
7877 def embed (self , texts : list [str ]) -> list [NDArray [np .float32 ]]:
7978 """Embed a batch of texts into float32 vectors."""
8079 model = self ._get_model ()
@@ -85,7 +84,7 @@ def embed(self, texts: list[str]) -> list[NDArray[np.float32]]:
8584 ) # type: ignore[assignment]
8685 return list (embeddings )
8786
88- @coco_aio . function (batching = True , runner = coco .GPU , memo = True , max_batch_size = _config .batch_size )
87+ @coco . fn . as_async (batching = True , runner = coco .GPU , memo = True , max_batch_size = _config .batch_size )
8988 def embed_query (self , texts : list [str ]) -> list [NDArray [np .float32 ]]:
9089 """Embed query texts, applying query_prompt_name if configured."""
9190 model = self ._get_model ()
@@ -97,7 +96,7 @@ def embed_query(self, texts: list[str]) -> list[NDArray[np.float32]]:
9796 ) # type: ignore[assignment]
9897 return list (embeddings )
9998
100- @coco_aio . function (runner = coco .GPU , memo = True )
99+ @coco . fn . as_async (runner = coco .GPU , memo = True )
101100 def __coco_vector_schema__ (self ) -> _schema .VectorSchema :
102101 """Return the vector schema (dimension + dtype) for this model."""
103102 model = self ._get_model ()
0 commit comments