Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKProvidersAnthropicAWSGoogleMicrosoftOpenAIMoreComponentsLLMsChat modelsDocument loadersDocument transformersText embedding modelsVector storesRetrieversToolsAgents and toolkitsAINetworkAirbyte Question AnsweringAmadeusAzure Cognitive ServicesClickUp Langchain ToolkitCSVDocument ComparisonGithubGitlabGmailGoogle Drive toolJiraJSONMultiOnOffice365OpenAPINatural Language APIsPandas DataframePlayWright BrowserPowerBI DatasetPythonSpark DataframeSpark SQLSQL DatabaseVectorstoreXorbitsMemoryCallbacksChat loadersComponentsAgents and toolkitsDocument ComparisonOn this pageDocument ComparisonThis notebook shows how to use an agent to compare two documents.The high level idea is we will create a question-answering chain for each document, and then use that from pydantic import BaseModel, Fieldfrom langchain.chat_models import ChatOpenAIfrom langchain.agents import Toolfrom langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import FAISSfrom langchain.document_loaders import PyPDFLoaderfrom langchain.chains import RetrievalQAclass DocumentInput(BaseModel):    question: str = Field()llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-0613")tools = []files = [    # https://abc.xyz/investor/static/pdf/2023Q1_alphabet_earnings_release.pdf    {        "name": "alphabet-earnings",        "path": "/Users/harrisonchase/Downloads/2023Q1_alphabet_earnings_release.pdf",    },    # https://digitalassets.tesla.com/tesla-contents/image/upload/IR/TSLA-Q1-2023-Update    {        "name": "tesla-earnings",        "path": "/Users/harrisonchase/Downloads/TSLA-Q1-2023-Update.pdf",    },]for file in files:    loader = PyPDFLoader(file["path"])    pages = loader.load_and_split()    text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)    docs =
This notebook shows how to use an agent to compare two documents.
This notebook shows how to use an agent to compare two documents. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKProvidersAnthropicAWSGoogleMicrosoftOpenAIMoreComponentsLLMsChat modelsDocument loadersDocument transformersText embedding modelsVector storesRetrieversToolsAgents and toolkitsAINetworkAirbyte Question AnsweringAmadeusAzure Cognitive ServicesClickUp Langchain ToolkitCSVDocument ComparisonGithubGitlabGmailGoogle Drive toolJiraJSONMultiOnOffice365OpenAPINatural Language APIsPandas DataframePlayWright BrowserPowerBI DatasetPythonSpark DataframeSpark SQLSQL DatabaseVectorstoreXorbitsMemoryCallbacksChat loadersComponentsAgents and toolkitsDocument ComparisonOn this pageDocument ComparisonThis notebook shows how to use an agent to compare two documents.The high level idea is we will create a question-answering chain for each document, and then use that from pydantic import BaseModel, Fieldfrom langchain.chat_models import ChatOpenAIfrom langchain.agents import Toolfrom langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import FAISSfrom langchain.document_loaders import PyPDFLoaderfrom langchain.chains import RetrievalQAclass DocumentInput(BaseModel):    question: str = Field()llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-0613")tools = []files = [    # https://abc.xyz/investor/static/pdf/2023Q1_alphabet_earnings_release.pdf    {        "name": "alphabet-earnings",        "path": "/Users/harrisonchase/Downloads/2023Q1_alphabet_earnings_release.pdf",    },    # https://digitalassets.tesla.com/tesla-contents/image/upload/IR/TSLA-Q1-2023-Update    {        "name": "tesla-earnings",        "path": "/Users/harrisonchase/Downloads/TSLA-Q1-2023-Update.pdf",    },]for file in files:    loader = PyPDFLoader(file["path"])    pages = loader.load_and_split()    text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)    docs =