Lab 14 Cohere and LangChain - Create A Chatbot For PDF Files
Lab 14 Cohere and LangChain - Create A Chatbot For PDF Files
The project uses Chroma Vector Database running as container, NodeJS Typescript
as backend and react as frontend for the ChatBot on existing set PDF Files.
Disclaimer: The Project is for study only. The code may not work as expected. For example
the number of reference may not be exactly the same as the number of PDF Files. Also, there
might be missing functionalities. You may use the project to understand the possibility of using
LLM and RAG to build a custom chatbot.
https://github.com/Sangwan70/cohere-chatbot-pdf-chroma.git
3. Click on Fork button to fork the repo to your Github account, so that you can change the
code, upload your PDFs and add/finetune features.
4. Inside docs folder (in your Github account), upload your pdf files or folders that contain
pdf files. You will be ingesting these files as your knowledge base. Commit the changes.
Ensure that the PDF files are not password protected and file names are not space
separated.
5. Login to your Oracle Cloud Account and Launch the Cloud Shell.
6. Connect to the instance with command similar to
$ sudo su -
bash nodesource_setup.sh
c. Install Node.js:
node -v
firewall-cmd --reload
f. Repeat the same on the Instance page in the security list of the Subnet in which you
have your instance.
8. Now clone the forked repo or download the ZIP to your OCI Instance
For Example:
cd cohere-chatbot-pdf-chroma
11. Run the following command to install all packages from package.json file:
yarn install
# vi .env
COHERE_API_KEY=
COLLECTION_NAME=skillpedia
13. In utils/makechain.ts chain, change the QA_TEMPLATE in line no. 18 (All Details
from Line No 5 to Line No 19) for your own use case. This will be the "Preamble" or
"System Message" and will affect the response from chat bot.
# vi utils/makechain.ts
14. Run Chroma in the container with docker or podman (Podman is already installed on the
Instance):
1. Run the script from cohere-chatbot-pdf-chroma directory to 'ingest' and embed your
docs.
yarn run ingest
To launch the local dev environment, and then type a question in the chat interface.
Launch the browser and open http://localhost:3000, Or visit your browser with
http://<Public IP>:3000.
The Chatbot has politely refused to answer since we have configured the system
prompt to respond only if the question is related to the context provided.