Replies: 1 comment 1 reply
-
Computed fields are just properties, and async properties aren't supported in Python. You may want to try using https://pypi.org/project/async-property/, although I don't know if it will work with Pydantic computed fields: from pydantic import BaseModel, computed_field
class Data(BaseModel):
texts: list[str]
@computed_field
@async_property
def vectors(self)-> list[list[float]]:
# Async Ops to get embeddings
return await ... |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How do we go about async for a computed field?
I get list of text as a field in a pydantic BaseModel class say
Data
then I would need get embeddings for those text and insert them to a vector store. But I need to do async operation on getting the embedding from external api.Is async supported for computed field and that I'm not aware of how to do it, any guide or reference, please?
If not supported then would async be supported for computed fields in next updates as feature request?
Beta Was this translation helpful? Give feedback.
All reactions