Skip to content

How to build a table schema with dynamic embedding model #5930

Answered by legendy4141
RubyDemon3131 asked this question in Q&A
Discussion options

You must be logged in to vote

The error occurs because you're trying to use a function call (embeddings.ndims()) in a class field declaration, which is not allowed in Python's type hinting. To resolve this, you can compute the embedding dimensions outside of the class definition and pass them as a constant value. Instead of calling embeddings.ndims() inside the class, you could calculate it beforehand and then define the Vector field with that value. For example, define the dimension once like embedding_dim = embeddings.ndims() and use Vector(embedding_dim) in the class. This approach will avoid the Pylance error and still allow you to dynamically define the vector field based on the embedding model.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RubyDemon3131
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants