{"id":13454428,"url":"https://github.com/mayooear/gpt4-pdf-chatbot-langchain","last_synced_at":"2025-11-05T12:30:38.443Z","repository":{"id":143386375,"uuid":"615113749","full_name":"mayooear/gpt4-pdf-chatbot-langchain","owner":"mayooear","description":"GPT4 \u0026 LangChain Chatbot for large PDF docs","archived":false,"fork":false,"pushed_at":"2025-01-31T18:18:31.000Z","size":6517,"stargazers_count":15056,"open_issues_count":31,"forks_count":3024,"subscribers_count":149,"default_branch":"main","last_synced_at":"2025-02-11T10:17:31.991Z","etag":null,"topics":["gpt4","langchain","nextjs","openai","pdf","typescript"],"latest_commit_sha":null,"homepage":"https://www.youtube.com/watch?v=ih9PBGVVOO4","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mayooear.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-17T01:23:26.000Z","updated_at":"2025-02-10T17:14:39.000Z","dependencies_parsed_at":"2024-01-12T04:56:38.776Z","dependency_job_id":"378b86d6-b6e2-4a02-9e4b-91601f3a6280","html_url":"https://github.com/mayooear/gpt4-pdf-chatbot-langchain","commit_stats":{"total_commits":21,"total_committers":4,"mean_commits":5.25,"dds":0.4285714285714286,"last_synced_commit":"138bba4f0782e5667f75df104743b11fc1308541"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayooear%2Fgpt4-pdf-chatbot-langchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayooear%2Fgpt4-pdf-chatbot-langchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayooear%2Fgpt4-pdf-chatbot-langchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayooear%2Fgpt4-pdf-chatbot-langchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mayooear","download_url":"https://codeload.github.com/mayooear/gpt4-pdf-chatbot-langchain/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239458949,"owners_count":19642100,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpt4","langchain","nextjs","openai","pdf","typescript"],"created_at":"2024-07-31T08:00:53.998Z","updated_at":"2025-02-18T11:16:03.286Z","avatar_url":"https://github.com/mayooear.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Bots","Uncategorized","Chatbots","Tools","工具","A01_文本生成_文本对话","Meta","Chat bots","精选开源项目合集","开源项目","Repos","twitter","Agent Categories","Applications and Demos"],"sub_categories":["Examples","Uncategorized","Open-source projects","开源项目","大语言对话模型及数据","Other","GPT工具","\u003ca name=\"LangGraph\"\u003e\u003c/a\u003eLangGraph","LLM (Large Language Model)"],"readme":"# GPT-4 \u0026 LangChain - Create a ChatGPT Chatbot for Your PDF Files\n\nUse the new GPT-4 api to build a chatGPT chatbot for multiple Large PDF files.\n\nTech stack used includes LangChain, Pinecone, Typescript, Openai, and Next.js. LangChain is a framework that makes it easier to build scalable AI/LLM apps and chatbots. Pinecone is a vectorstore for storing embeddings and your PDF in text to later retrieve similar docs.\n\n[Tutorial video](https://www.youtube.com/watch?v=ih9PBGVVOO4)\n\nThe visual guide of this repo and tutorial is in the `visual guide` folder.\n\n**If you run into errors, please review the troubleshooting section further down this page.**\n\nPrelude: Please make sure you have already downloaded node on your system and the version is 18 or greater.\n\n## Development\n\n1. Clone the repo or download the ZIP\n\n```\ngit clone [github https url]\n```\n\n2. Install packages\n\nFirst run `npm install yarn -g` to install yarn globally (if you haven't already).\n\nThen run:\n\n```\nyarn install\n```\n\nAfter installation, you should now see a `node_modules` folder.\n\n3. Set up your `.env` file\n\n- Copy `.env.example` into `.env`\n  Your `.env` file should look like this:\n\n```\nOPENAI_API_KEY=\n\nPINECONE_API_KEY=\nPINECONE_ENVIRONMENT=\n\nPINECONE_INDEX_NAME=\n\n```\n\n- Visit [openai](https://help.openai.com/en/articles/4936850-where-do-i-find-my-secret-api-key) to retrieve API keys and insert into your `.env` file.\n- Visit [pinecone](https://pinecone.io/) to create and retrieve your API keys, and also retrieve your environment and index name from the dashboard.\n\n4. In the `config` folder, replace the `PINECONE_NAME_SPACE` with a `namespace` where you'd like to store your embeddings on Pinecone when you run `npm run ingest`. This namespace will later be used for queries and retrieval.\n\n5. In `utils/makechain.ts` chain change the `QA_PROMPT` for your own usecase. Change `modelName` in `new OpenAI` to `gpt-4`, if you have access to `gpt-4` api. Please verify outside this repo that you have access to `gpt-4` api, otherwise the application will not work.\n\n## Convert your PDF files to embeddings\n\n**This repo can load multiple PDF files**\n\n1. Inside `docs` folder, add your pdf files or folders that contain pdf files.\n\n2. Run the script `yarn run ingest` to 'ingest' and embed your docs. If you run into errors troubleshoot below.\n\n3. Check Pinecone dashboard to verify your namespace and vectors have been added.\n\n## Run the app\n\nOnce you've verified that the embeddings and content have been successfully added to your Pinecone, you can run the app `npm run dev` to launch the local dev environment, and then type a question in the chat interface.\n\n## Troubleshooting\n\nIn general, keep an eye out in the `issues` and `discussions` section of this repo for solutions.\n\n**General errors**\n\n- Make sure you're running the latest Node version. Run `node -v`\n- Try a different PDF or convert your PDF to text first. It's possible your PDF is corrupted, scanned, or requires OCR to convert to text.\n- `Console.log` the `env` variables and make sure they are exposed.\n- Make sure you're using the same versions of LangChain and Pinecone as this repo.\n- Check that you've created an `.env` file that contains your valid (and working) API keys, environment and index name.\n- If you change `modelName` in `OpenAI`, make sure you have access to the api for the appropriate model.\n- Make sure you have enough OpenAI credits and a valid card on your billings account.\n- Check that you don't have multiple OPENAPI keys in your global environment. If you do, the local `env` file from the project will be overwritten by systems `env` variable.\n- Try to hard code your API keys into the `process.env` variables if there are still issues.\n\n**Pinecone errors**\n\n- Make sure your pinecone dashboard `environment` and `index` matches the one in the `pinecone.ts` and `.env` files.\n- Check that you've set the vector dimensions to `1536`.\n- Make sure your pinecone namespace is in lowercase.\n- Pinecone indexes of users on the Starter(free) plan are deleted after 7 days of inactivity. To prevent this, send an API request to Pinecone to reset the counter before 7 days.\n- Retry from scratch with a new Pinecone project, index, and cloned repo.\n\n## Credit\n\nFrontend of this repo is inspired by [langchain-chat-nextjs](https://github.com/zahidkhawaja/langchain-chat-nextjs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayooear%2Fgpt4-pdf-chatbot-langchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayooear%2Fgpt4-pdf-chatbot-langchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayooear%2Fgpt4-pdf-chatbot-langchain/lists"}