Replies: 1 comment
-
🤖 Hi, Yes, it is possible to retrieve metadata such as a URL from Pinecone along with the result. This can be done by passing metadata along with the texts to the metadatas = [{"page": i} for i in range(len(texts))]
docsearch = Pinecone.from_texts(
texts,
embedding_openai,
index_name=index_name,
metadatas=metadatas,
namespace=namespace_name,
)
output = docsearch.similarity_search(needs, k=1, namespace=namespace_name)
assert output == [Document(page_content=needs, metadata={"page": 0.0})] You can find this in the As for passing a UNIX timestamp as metadata through the agent in the search_kwargs for a filtered query, the To modify the def _get_docs(
self, inputs: Dict[str, Any], *, run_manager: CallbackManagerForChainRun
) -> Tuple[List[Document], List[Dict[str, Any]]]:
question = inputs[self.question_key]
docs = self.retriever.get_relevant_documents(
question, callbacks=run_manager.get_child()
)
metadata = [doc.metadata for doc in docs]
return self._reduce_tokens_below_limit(docs), metadata
async def _aget_docs(
self, inputs: Dict[str, Any], *, run_manager: AsyncCallbackManagerForChainRun
) -> Tuple[List[Document], List[Dict[str, Any]]]:
question = inputs[self.question_key]
docs = await self.retriever.aget_relevant_documents(
question, callbacks=run_manager.get_child()
)
metadata = [doc.metadata for doc in docs]
return self._reduce_tokens_below_limit(docs), metadata This assumes that the I hope this helps! Let me know if you have any other questions. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
I have a chatbot which uses gpt-3.5-turbo as an LLM and Pinecone as the vector store.
I have some documents against which I have metadata (let's say it is the article URL of the document)
I want my agent to tell me the URL as well from the metadata, along with the result.
Is this possible?
This is how I have set up my retriever:
This returns me the retrieval chain which then gets passed as a tool.
Moreover, if I have my metadata as a UNIX timestamp, is it possible to pass the UNIX timestamp through the agent in the search_kwargs? I can do that manually, but what if the user asks "Give me the latest data"? Then is there a way for the agent to use the LLM and automatically fill up the metadata field for a filtered query?
Beta Was this translation helpful? Give feedback.
All reactions