mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-07 10:25:17 +03:00
2.6 KiB
2.6 KiB
In [1]:
from langchain.document_loaders import TextLoaderIn [2]:
loader = TextLoader("../../modules/state_of_the_union.txt")In [3]:
doc = loader.load()[0]In [4]:
from langchain.chat_models import ChatOpenAI
from langchain.chains import QAGenerationChain
chain = QAGenerationChain.from_llm(ChatOpenAI(temperature = 0))In [8]:
qa = chain.run(doc.page_content)In [10]:
qa[1]Out [10]:
{'question': 'What is the U.S. Department of Justice doing to combat the crimes of Russian oligarchs?',
'answer': 'The U.S. Department of Justice is assembling a dedicated task force to go after the crimes of Russian oligarchs.'}In [ ]: