英文:
How can I retrieve the list of input documents used by ChatGPT in LangChain?
问题
I'm utilizing OpenAI's ChatGPT model within the LangChain framework, where I pass input_documents to provide context for generating responses. However, I would like to know if there is a way to extract the specific list of input documents that were utilized by ChatGPT during the response generation process in LangChain. Either by a specific prompt to ChatGPT or using some attribute in load_qa_chain
I'm not aware of. Meaning, if I passed 4 input documents and ChatGPT only used 2 of them to generate a result - which 2 did ChatGPT use?
Thank you for your assistance and any insights you can provide!
英文:
I'm utilizing OpenAI's ChatGPT model within the LangChain framework, where I pass input_documents to provide context for generating responses. However, I would like to know if there is a way to extract the specific list of input documents that were utilized by ChatGPT during the response generation process in LangChain.
Either by a specific prompt to ChatGPT or using some attribute in load_qa_chain
I'm not aware of.
Meaning, if I passed 4 input documents and ChatGPT only used 2 of them to generate a result - which 2 did ChatGPT used?
Thank you for your assistance and any insights you can provide!
答案1
得分: 1
你是否查看了链条 RetrievalQAWithSourcesChain
(https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa_with_sources.html),或者 Question Answering with Sources
(https://python.langchain.com/en/latest/modules/chains/index_examples/qa_with_sources.html),或者通过使用 load_qa_with_sources_chain
(https://python.langchain.com/en/latest/use_cases/question_answering.html)?
如果你想获得更多反馈,还可以添加 StdOutCallbackHandler
(https://python.langchain.com/en/latest/modules/callbacks/getting_started.html)
handler = StdOutCallbackHandler()
chain.run(input_documents=docs, question=query, callbacks=[handler])
或者设置 verbose=True
(https://python.langchain.com/en/latest/modules/memory/getting_started.html)
英文:
Have you looked at the chain RetrievalQAWithSourcesChain
(https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa_with_sources.html), or the Question Answering with Sources
(https://python.langchain.com/en/latest/modules/chains/index_examples/qa_with_sources.html), or by using the load_qa_with_sources_chain
(https://python.langchain.com/en/latest/use_cases/question_answering.html)
If you want to more feedback you can also add the StdOutCallbackHandler
(https://python.langchain.com/en/latest/modules/callbacks/getting_started.html)
handler = StdOutCallbackHandler()
chain.run((input_documents=docs, question=query, callbacks=[handler])
or set verbose=True
(https://python.langchain.com/en/latest/modules/memory/getting_started.html)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论