mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-05 09:25:14 +03:00
Updates docs and cookbooks to import ChatOpenAI, OpenAI, and OpenAI Embeddings from `langchain_openai` There are likely more --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
2.6 KiB
2.6 KiB
In [3]:
with open("../docs/docs/modules/state_of_the_union.txt") as f:
state_of_the_union = f.read()In [7]:
from langchain.chains import AnalyzeDocumentChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)In [8]:
from langchain.chains.question_answering import load_qa_chain
qa_chain = load_qa_chain(llm, chain_type="map_reduce")In [9]:
qa_document_chain = AnalyzeDocumentChain(combine_docs_chain=qa_chain)In [10]:
qa_document_chain.run(
input_document=state_of_the_union,
question="what did the president say about justice breyer?",
)Out [10]:
'The President said, "Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service."'