0% found this document useful (0 votes)
37 views5 pages

Lab 14 Cohere and LangChain - Create A Chatbot For PDF Files

The document outlines a project for creating a chatbot that interacts with PDF files using a Chroma Vector Database, NodeJS, and React. It provides step-by-step instructions for setting up the environment, including forking a GitHub repository, uploading PDF files, and configuring the server. The project is intended for educational purposes and may have incomplete functionalities, serving as a learning tool for using LLM and RAG in chatbot development.

Uploaded by

Sharmila Shetty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views5 pages

Lab 14 Cohere and LangChain - Create A Chatbot For PDF Files

The document outlines a project for creating a chatbot that interacts with PDF files using a Chroma Vector Database, NodeJS, and React. It provides step-by-step instructions for setting up the environment, including forking a GitHub repository, uploading PDF files, and configuring the server. The project is intended for educational purposes and may have incomplete functionalities, serving as a learning tool for using LLM and RAG in chatbot development.

Uploaded by

Sharmila Shetty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lab 14.

Cohere and LangChain - a Chatbot for PDF Files


Objective:

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.

1. Create an account on Github, if not already existing and login.


2. Visit the repository page

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

ssh -i ~/.ssh/genailabskey [email protected]

Replace IP with IP address of your instance

$ sudo su -

7. Installing Node and NPM on Linux

a. Download the setup script:

curl -fsSL https://rpm.nodesource.com/setup_23.x -o nodesource_setup.sh

b. Run the setup script as root:

bash nodesource_setup.sh
c. Install Node.js:

yum install -y nodejs

d. Verify the installation:

node -v

e. Open the port 3000 in to allow incoming connections

firewall-cmd --permanent --add-port=3000/tcp

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

git clone https://github.com/<Your User ID>/cohere-chatbot-pdf-chroma.git

For Example:

git clone https://github.com/Sangwan70/cohere-chatbot-pdf-chroma.git

9. Change to cloned repository and Install packages

cd cohere-chatbot-pdf-chroma

10. Install yarn globally with:

npm install yarn -g

11. Run the following command to install all packages from package.json file:

yarn install

After installation, you should see a node_modules folder.


12. Create the .env file and paste the contents of the DotEnv file (shared by instructor)
into this file.

# vi .env

# Copy the content from DotEnv File Provided.

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):

podman run -d -p 8000:8000 chromadb/chroma:0.4.15

Convert your PDF files to embeddings

1. Run the script from cohere-chatbot-pdf-chroma directory to 'ingest' and embed your
docs.
yarn run ingest

2. Run the app with

npm run dev

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.

3. Ask a Question. Type a question about Responsible AI at Oracle. For example

"Tell me something about Responsible AI Policies at Oracle."


4. Try a question not available in PDF Documents:

"Tell me something about Ram N Sangwan."

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.

You might also like