Skip to content
Discussion options

You must be logged in to vote

So the tricky part is that the RetrievalQAwithSourcesChain chain does not receive and return a single input and output. But on the other hand, Tools require a single string input and single string output.

We can work around this by wrapping the RetrievalQAwithSourcesChain in a function that takes a single string input and single string output. For example, we can return the answer and source as a string.

from langchain.agents import (
    AgentType,
    initialize_agent,
    Tool,
)
from langchain.chains import RetrievalQAWithSourcesChain
from langchain.chat_models import ChatOpenAI
from langchain.document_loaders import TextLoader
from langchain.embeddings import OpenAIEmbeddings
from la…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@courtney-wright
Comment options

@meet1919
Comment options

@cryptocoinserver
Comment options

Answer selected by courtney-wright
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants