2

Trying to have the agent use 2 vector stores as tools during its run. The files are in different folders out of necessity and they are different formats one is text and one is pdf. Thus why I need to somehow combine or tell the agent to use both.

I tried different things but none work.Im looking for ideas. Below most logical failed attempt.

Create vectorstore info object - metadata repo?
vectorstore_info = VectorStoreInfo(
    name="Guidelines",
    description="QA Analysis Guidelines",
    vectorstore=store
    )

vectorstore_info2 = VectorStoreInfo(
    name="Transcript",
    description="Transcript of Call Center Agent Call",
    vectorstore=call
    )

Convert the document store into a langchain toolkit
toolkit = VectorStoreToolkit(vectorstore_info=[VectorStoreInfo,vectorstore_info2])

Add the toolkit to an end-to-end LC
agent_executor = create_vectorstore_agent(
    llm=llm,
    toolkit=toolkit,
    verbose=True
    )
D.L
  • 4,339
  • 5
  • 22
  • 45
  • You need data from several sources combined in vector stores? If you are looking to route between multiple stores, this might be for you: https://python.langchain.com/en/latest/modules/agents/toolkits/examples/vectorstore.html?highlight=VectorStoreRouterToolkit#multiple-vectorstores – TomTom101 Jun 08 '23 at 09:18
  • Does the last example do what you need? https://python.langchain.com/docs/modules/agents/toolkits/vectorstore – Andrew Anderson Jul 15 '23 at 12:42
  • btw, did you mean: `vectorstore_info=[VectorStoreInfo...` > `vectorstore_info=[vectorestoreinfo1...` ? – Andrew Anderson Jul 15 '23 at 12:43

1 Answers1

0

If you want to combine the two vectorstores you can use FAISS which supports merging. The limitation to being able to merge depends on which Vectorstore you're using to handle your embeddings. Not all vectorstores have a method for merging databases.

I recommend using FAISS -

db1 = FAISS.from_texts(<txt>, embeddings)
db2 = FAISS.from_texts(<pdf>, embeddings)

vectorstore_info = VectorStoreInfo(
    name="Guidelines",
    description="QA Analysis Guidelines",
    vectorstore=db1
    )

vectorstore_info2 = VectorStoreInfo(
    name="Transcript",
    description="Transcript of Call Center Agent Call",
    vectorstore=db2
    )

db1.merge_from(db2)  # This will combine db2 INTO db1

See: https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/faiss#merging


If instead you're looking to build an agent which uses each vectorstore separately as a tool, you should reference this doc: https://python.langchain.com/docs/modules/agents/how_to/agent_vectorstore

ASM
  • 1
  • 2