-
Notifications
You must be signed in to change notification settings - Fork 17
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
New examples added to docs #166
base: release
Are you sure you want to change the base?
Conversation
hari0205
commented
Apr 5, 2024
- Added a new example on how to RAG using metadata on retrievers
- Some linting done.
@hsm207 is this good enough for a PR? I noticed that |
The # Use a filter to only retrieve documents from a specific paper
docsearch.as_retriever(
search_kwargs={'filter': {'paper_title':'GPT-4 Technical Report'}}
) So, I tried an example import weaviate as wev
from langchain_weaviate import WeaviateVectorStore
client = wev.connect_to_local(port=8030)
db = WeaviateVectorStore(
client, "myindex", "mytext", embedding=OpenAIEmbeddings(), by_text=False
)
retriver = db.as_retriever(search_kwargs={"filters":{"userid":userid}})
llm = ChatOpenAI(model="gpt-4-turbo-preview",temperature=0)
qa_chain = RetrievalQA.from_chain_type(llm,retriever=retriver)
res=qa_chain.invoke({"query":query})
print(res) I got a type error:
Upon closer inspection on I changed the code to
Now, I am greeted with another error
The only way I was able to get it working was to modify the code to search_filter=wev.classes.query.Filter.by_property("userid").equal(userid)
retriver = db.as_retriever(search_kwargs={"filters":search_filter})
llm = ChatOpenAI(model="gpt-4-turbo-preview",temperature=0)
qa_chain = RetrievalQA.from_chain_type(llm,retriever=retriver)
res=qa_chain.invoke({"query":query})
print(res) My assumption is that the implementation of metadata filter is different for different vector stores. Since the keyword arguments are passed as they are, we encounter this error. So, I opened this PR to provide some examples and avoid confusion. PS: package versions
|