-
Notifications
You must be signed in to change notification settings - Fork 1.2k
chore!: Refactor embeddings out of VectorStoreWithIndex and into OpenAIVectorStoreMixin and make ChunkMetadata required. #4413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✱ Stainless preview buildsThis PR will update the Edit this comment to update it. It will appear in the SDK's changelogs. ✅ llama-stack-client-node studio · code · diff
✅ llama-stack-client-go studio · code · diff
⏳ These are partial results; builds are still running. This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push. |
cd40891 to
d34448b
Compare
cdoern
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one question, otherwise lgtm!
|
|
||
| # Get embedding model info from vector store metadata | ||
| store_info = self.openai_vector_stores[vector_store_id] | ||
| embedding_model = store_info["metadata"].get("embedding_model") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will store_info["metadata"] always be set? just want to check because we are calling .get on it unconditionally. I guess its ok because we are in a try except, but double checking :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In release v0.2.13 (https://github.com/llamastack/llama-stack/releases/tag/v0.2.13) I added the metadata object but now I'm forcing it to be required so the edge case is for users that are migrating data from <0.2.13 and upgrading to 0.4.0.
I think it's okay for those users to reingest the data. Now that the metadata and child fields are required, we won't have that concern going forward.
src/llama_stack/providers/utils/memory/openai_vector_store_mixin.py
Outdated
Show resolved
Hide resolved
src/llama_stack/providers/utils/memory/openai_vector_store_mixin.py
Outdated
Show resolved
Hide resolved
| if isinstance(data.embedding, list): | ||
| c.embedding = data.embedding | ||
| else: | ||
| raise ValueError(f"Expected embedding to be a list, got {type(data.embedding)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a 500 instead of a 400
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you see a non-list here? that'd be an api violation. remove the isinstance check and let it fail, which will result in a 500.
src/llama_stack_api/vector_io.py
Outdated
| embedding: list[float] | ||
| chunk_metadata: ChunkMetadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this api need to be changed as part of the refactor?
| chunk_embedding_model=embedding_model, | ||
| chunk_embedding_dimension=embedding_dimension, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are these used?
mattf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking better!
for later -
- turn OpenAIVectorStoreMixin into a BaseModel
| if isinstance(data.embedding, list): | ||
| c.embedding = data.embedding | ||
| else: | ||
| raise ValueError(f"Expected embedding to be a list, got {type(data.embedding)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you see a non-list here? that'd be an api violation. remove the isinstance check and let it fail, which will result in a 500.
61faef4 to
7dd3abd
Compare
|
This pull request has merge conflicts that must be resolved before it can be merged. @franciscojavierarceo please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork |
…VectorStoreMixin Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
9597d7c to
2611343
Compare
|
@mattf you mind reviewing? I'd like to get this into the 0.4 and backport it into the 0.3.x releases. |
we won't backport in 0.3.x if it's a breaking change / feature. |
|
@leseb oh yeah that makes sense. |
leseb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like to land this so we can cut 0.4.0 today. I believe all @mattf comments have been addressed. Also, any small miss can be addressed in a 0.4.x release quickly. Thanks!
| chunk_id="c1", | ||
| created_timestamp=1234567890, | ||
| updated_timestamp=1234567890, | ||
| chunk_embedding_model="test-model", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ChunkMetadata no longer has embedding info?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, moving it to the EmbeddedChunk as Chunks will no longer have embeddings.
It's an annoying change but it makes things much cleaner and explicit about when Chunks have embeddings and don't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should you then instantiate ChunkMetadata with these params? or am i missing the fact that this is a failure test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed cleaning these up 🤦. Removing them in this PR: #4454
raghotham
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
Thanks for the feedback Matt, I think I incorporated the changes. Given you're OOO and we have enough approvals, we want to land this for 0.4. Let me know if you have other followups, happy to make them in subsequent PRs.
What does this PR do?
Move embedding generation responsibility from
VectorStoreWithIndex.insert_chunks()toOpenAIVectorStoreMixin.openai_attach_file_to_vector_store()and makeChunkMetadatarequired.Important call outs:
EmbeddedChunkclass that inherits fromChunkwith embedding fieldsChunkandChunkMetadataclassesChunkMetadatarequired inChunkclassEmbeddedChunkfor vector operationsTest Plan
Updated tests
Resolves #2981