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
supabase vectorstore - first cut #3100
supabase vectorstore - first cut #3100
Conversation
I'm overriding |
langchain/vectorstores/supabase.py
Outdated
cls: Type["SupabaseVectorStore"], | ||
texts: List[str], | ||
embedding: Embeddings, | ||
metadatas: Optional[List[dict[Any, Any]]], |
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 think adding new explicit kwargs shouldn't be issue for linter, but changing kwarg to arg might. so metadatas
should have default val None
langchain/vectorstores/supabase.py
Outdated
|
||
def __init__( | ||
self, | ||
client: Any, |
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.
we can support type checking on optional dependencies with optional imports. langchain/vectostors/chroma.py
is one example. basically do something like
if TYPE_CHECKING:
import supabase
class SupabaseVectorStore:
def __init__(self, client: supabase.client.Client, ...):
@dev2049 Modified per your suggestions. mypy is still unhappy with the method signature overrides:
Note that the signature for |
guessing you have to include @classmethod
def from_documents(
cls: Type[VST],
documents: List[Document],
embedding: Embeddings,
**kwargs: Any,
) -> VST:
"""Return VectorStore initialized from documents and embeddings."""
texts = [d.page_content for d in documents]
metadatas = [d.metadata for d in documents]
return cls.from_texts(texts, embedding, metadatas=metadatas, **kwargs) |
@danielchalef excited to see this! has been in typescript for a while, excited to getting python to feature parity ;) thanks for adding |
Good catch. Thanks! mypy doesn't like my previous use of a keyword-only argument marker. Have made the additional arguments |
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 is great! one last small ask - is it possible to get an example notebook showing how to use this?
@hwchase17 Done! |
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.
perfect! thanks!
I've followed this: https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/supabase.html but when i do |
Create a table called "docstore" or modify the Postgres function to use the table name reflecting your schema. I'll cut a PR later to correct the example function. |
Ohhh my bad! Thank you so much apologies for me being silly |
ref #3100 (comment) Co-authored-by: Daniel Chalef <daniel.chalef@private.org>
ref #3100 (comment) Co-authored-by: Daniel Chalef <daniel.chalef@private.org>
ref langchain-ai/langchain#3100 (comment) Co-authored-by: Daniel Chalef <daniel.chalef@private.org>
ref #3100 (comment) Co-authored-by: Daniel Chalef <daniel.chalef@private.org>
ref #3100 (comment) Co-authored-by: Daniel Chalef <daniel.chalef@private.org>
Any way to query |
Sounds like a great feature, though assumptions would need to be made around embedding model. I don't have bandwidth to work on this, but am sure the langchain team would appreciate the contribution. |
First cut of a supabase vectorstore loosely patterned on the langchainjs equivalent. Doesn't support async operations which is a limitation of the supabase python client. --------- Co-authored-by: Daniel Chalef <daniel.chalef@private.org>
ref langchain-ai#3100 (comment) Co-authored-by: Daniel Chalef <daniel.chalef@private.org>
ref langchain-ai#3100 (comment) Co-authored-by: Daniel Chalef <daniel.chalef@private.org>
did you found any way? |
Nope. Went back to Pinecone. |
@kasem-sm @rapcal I believe it's just this?
That said the supabase integration is lacking functionality such as filtering, but I think this should work for just loading it as an index. Maybe I'll push a pr for the docs. |
@rapcal @kasem-sm If you have a few set fields you want to filter with, and not too much dynamic filtering, I got it working quite nicely by implementing my own Vector Store class. I explained a bit more here #5379 (comment), and if needed I can share some minimal reproducible code if someone wants it. |
First cut of a supabase vectorstore loosely patterned on the langchainjs equivalent. Doesn't support async operations which is a limitation of the supabase python client.