vm setup for chatbot oracle

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Setup PyCharm IDE

Unauthorized reproduction or distribution prohibited. Copyright© 2024, Oracle University and/or its affiliates.

The chatbot code is developed using the PyCharm IDE community edition. PyCharm allows
creating Projects. Each project is a virtual environment in which required libraries can be
installed. It also has a PythonTerminal from where the server can be run.

Steps Purpose
Install libraries using Python Packages tab. Install following libraries,

a
pip install oci

as
pip install oracle-ads

)h
pip install langchain
pip install chromadb

. om
pip install faiss-cpu

ide a.c
pip install streamlit
pip install python-multipart

Gu indr
pip install pydantic
pip install pypdf

us ch ed
his ah
Setup the Generative AI service access Download the private key and config files
to te ay
et m
from IAM , User section and copy these to
se d@ il S
.oci folder in your local home directory.
Create Chroma server Open demo-chroma-create.py and run it.
en ye m

Running Chroma Server To run the chroma server use the following
lic sa am

command from a terminal.


le ak. uz

chroma run --path ./<<path to the


chromadb>>
ab ar M

Running Streamlit application To run the files that use Streamlit use the
fer ub ed

following command from the terminal,


ns ilm m

streamlit run <<name of the file>>


tra m m
n- m ha
no uza Mo

Github URL for code


https://github.com/ou-developers/ou-generativeai-pro/tree/main/demos
m
ed
mm
oha
(m
VM Setup for deploying the Chatbot and test it.
Unauthorized reproduction or distribution prohibited. Copyright© 2024, Oracle University and/or its affiliates.

The OU Chatbot can be deployed on the Ubuntu server with 1 OCPUs and 64 GB RAM.

Following steps are followed to setup the environment .

Create VM Create a VM with Canonical Ubuntu 22.04 image ,


VM.Standard.E4.Flex

a
Virtual machine, 1 core OCPU, 64 GB memory, 2 Gbps

as
network bandwidth.

)h
Download the ssh key for the VM and save it as ubuntu-

. om
vm-priv.key
Download IAM user private Download the IAM user private key and config from OCI

ide a.c
key and config file to account to local machine.
<<local-path>>/.oci directory

Gu indr
scp to .oci folder using scp. scp -r -I <<local-path>>/ubuntu-vm-priv.key <local-

us ch ed
his ah
path>/.oci/* ubuntu@<ip of your
to te ay
vm>:/home/ubuntu/.oci/

et m
ssh -i ubuntu-vm-priv.key ubuntu@<ip of your vm>
se d@ il S
login into the server
Create a src folder into the mkdir src
en ye m

home directory exit


lic sa am

(/home/ubuntu)
Copy code and data files – scp -r -i /<local-path>/ubuntu-vm-priv.key
le ak. uz

/<local-path>/demo-ou-chatbot-chroma-final.py
ab ar M

ubuntu@<ip of your vm>:/home/ubuntu/src/


fer ub ed
ns ilm m

scp -r -i /<local-path>/ubuntu-vm-priv.key
tra m m

<local-path> /demo-chroma-create.py
n- m ha

ubuntu@<ip of your vm>:/home/ubuntu/src/


no uza Mo

scp -r -i /<local-path>/ubuntu-vm-priv.key
<local-path>/pdf-docs/*
ubuntu@<ip of your vm>:/home/ubuntu/src/pdf-
m
ed

docs/
Upgrade Ubuntu packages sudo apt update && sudo apt upgrade
mm

Install Python sudo apt install python3


ha

Install Virtual Environment sudo apt install python3-virtualenv


Create a Virtual Environment virtualenv <name of the environment> (ouenv in this case)
o
(m

Activate virtual env source ouenv/bin/activate


Install necessary python pip install oci
libraries pip install oracle-ads
pip install langchain
pip install chromadb
pip install faiss-cpu
pip install streamlit
pip install python-multipart
pip install pydantic
pip install pypdf
Setup the firewall to open sudo iptables -I INPUT 6 -m state --state NEW -p tcp --
Unauthorized reproduction or distribution prohibited. Copyright© 2024, Oracle University and/or its affiliates.

ports dport 8501 -j ACCEPT


Setup subnet security list to From Compute select your instance ,
open port 8501. Select subnet for your instance
Select the default security list and add port 8501 for TCP
traffic.
Index documents python3 demo-chroma-create.py

a
Run Chroma server nohup chroma run --path ./chromadb >> chroma.log &

as
)h
Run server that will accept cd src
user input and return response

. om
nohup streamlit run demo-ou-chatbot-chroma-final.py &

ide a.c
Test the server http://<ip addr of the server>:8501

Gu indr
us ch ed
his ah
to te ay
et m
se d@ il S
en ye m
lic sa am
le ak. uz
ab ar M
fer ub ed
ns ilm m
tra m m
n- m ha
no uza Mo
m
ed
mm
o ha
(m

You might also like