Skip to main content
Table of contents

 

Set up your server

Begin by cleaning up your server environment.  Do this by updating Ubuntu’s package index:

sudo apt update && sudo apt upgrade -y

 

Check if Python3 is already installed

python --version

Response

Unknown option: -e
usage: python3 [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

Or

python3 --version

Response

Python 3.8.10

 

Update Python

If you want to update to the latest version

sudo apt-get install python3 python3-dev

Response

Reading package lists... Done
Building dependency tree
Reading state information... Done
python3 is already the newest version (3.8.2-0ubuntu2).
The following additional packages will be installed:
  libexpat1-dev libpython3-dev libpython3.8-dev python3.8-dev zlib1g-dev
The following NEW packages will be installed:
  libexpat1-dev libpython3-dev libpython3.8-dev python3-dev python3.8-dev
  zlib1g-dev
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 4744 kB of archives.
After this operation, 22.1 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 libexpat1-dev amd64 2.2.9-1ubuntu0.6 [116 kB]
Get:2 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-dev amd64 3.8.10-0ubuntu1~20.04.8 [3950 kB]
Get:3 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 libpython3-dev amd64 3.8.2-0ubuntu2 [7236 B]
Get:4 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2ubuntu1.5 [155 kB]
Get:5 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3.8-dev amd64 3.8.10-0ubuntu1~20.04.8 [514 kB]
Get:6 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 python3-dev amd64 3.8.2-0ubuntu2 [1212 B]
Fetched 4744 kB in 0s (12.4 MB/s)
Selecting previously unselected package libexpat1-dev:amd64.
(Reading database ... 146470 files and directories currently installed.)
Preparing to unpack .../0-libexpat1-dev_2.2.9-1ubuntu0.6_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.2.9-1ubuntu0.6) ...
Selecting previously unselected package libpython3.8-dev:amd64.
Preparing to unpack .../1-libpython3.8-dev_3.8.10-0ubuntu1~20.04.8_amd64.deb ...
Unpacking libpython3.8-dev:amd64 (3.8.10-0ubuntu1~20.04.8) ...
Selecting previously unselected package libpython3-dev:amd64.
Preparing to unpack .../2-libpython3-dev_3.8.2-0ubuntu2_amd64.deb ...
Unpacking libpython3-dev:amd64 (3.8.2-0ubuntu2) ...
Selecting previously unselected package zlib1g-dev:amd64.
Preparing to unpack .../3-zlib1g-dev_1%3a1.2.11.dfsg-2ubuntu1.5_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.11.dfsg-2ubuntu1.5) ...
Selecting previously unselected package python3.8-dev.
Preparing to unpack .../4-python3.8-dev_3.8.10-0ubuntu1~20.04.8_amd64.deb ...
Unpacking python3.8-dev (3.8.10-0ubuntu1~20.04.8) ...
Selecting previously unselected package python3-dev.
Preparing to unpack .../5-python3-dev_3.8.2-0ubuntu2_amd64.deb ...
Unpacking python3-dev (3.8.2-0ubuntu2) ...
Setting up libexpat1-dev:amd64 (2.2.9-1ubuntu0.6) ...
Setting up libpython3.8-dev:amd64 (3.8.10-0ubuntu1~20.04.8) ...
Setting up zlib1g-dev:amd64 (1:1.2.11.dfsg-2ubuntu1.5) ...
Setting up libpython3-dev:amd64 (3.8.2-0ubuntu2) ...
Setting up python3.8-dev (3.8.10-0ubuntu1~20.04.8) ...
Setting up python3-dev (3.8.2-0ubuntu2) ...
Processing triggers for man-db (2.9.1-1) ...

 

Install Python PIP

Python modules are managed through PIP. PIP is a package management system used to download and add libraries from the Python Package Index

sudo apt-get install python3-pip

Response

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  python-pip-whl python3-wheel
The following NEW packages will be installed:
  python-pip-whl python3-pip python3-wheel
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 2059 kB of archives.
After this operation, 3465 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe amd64 python-pip-whl all 20.0.2-5ubuntu1.9 [1805 kB]
Get:2 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe amd64 python3-wheel all 0.34.2-1ubuntu0.1 [23.9 kB]
Get:3 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe amd64 python3-pip all 20.0.2-5ubuntu1.9 [231 kB]
Fetched 2059 kB in 0s (6281 kB/s)
Selecting previously unselected package python-pip-whl.
(Reading database ... 146701 files and directories currently installed.)
Preparing to unpack .../python-pip-whl_20.0.2-5ubuntu1.9_all.deb ...
Unpacking python-pip-whl (20.0.2-5ubuntu1.9) ...
Selecting previously unselected package python3-wheel.
Preparing to unpack .../python3-wheel_0.34.2-1ubuntu0.1_all.deb ...
Unpacking python3-wheel (0.34.2-1ubuntu0.1) ...
Selecting previously unselected package python3-pip.
Preparing to unpack .../python3-pip_20.0.2-5ubuntu1.9_all.deb ...
Unpacking python3-pip (20.0.2-5ubuntu1.9) ...
Setting up python3-wheel (0.34.2-1ubuntu0.1) ...
Setting up python-pip-whl (20.0.2-5ubuntu1.9) ...
Setting up python3-pip (20.0.2-5ubuntu1.9) ...
Processing triggers for man-db (2.9.1-1) ...

 

Install the required packages

  • Open AI - what we are using for ChatGPT
  • PyPDF2 - a Python library for reading PDF files
  • LangChain - a robust library designed to streamline interaction with large language models (LLMs) providers - such as OpenAI
  • LlamaIndex - a data framework which provides a flexible and simple interface to connect LLMs with external data
  • Gradio - a Python UI library

Open AI

pip install openai
pip install PyPDF2
pip install langchain==0.0.148
pip install llama-index==0.5.6
pip install gradio

Working through each install

pip install openai

Response

Collecting openai
  Using cached openai-0.28.1-py3-none-any.whl (76 kB)
Collecting tqdm
  Using cached tqdm-4.66.1-py3-none-any.whl (78 kB)
Collecting aiohttp
  Using cached aiohttp-3.8.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
Requirement already satisfied: requests>=2.20 in /usr/lib/python3/dist-packages (from openai) (2.22.0)
Collecting yarl<2.0,>=1.0
  Using cached yarl-1.9.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (266 kB)
Requirement already satisfied: attrs>=17.3.0 in /usr/lib/python3/dist-packages (from aiohttp->openai) (19.3.0)
Collecting multidict<7.0,>=4.5
  Using cached multidict-6.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (121 kB)
Collecting frozenlist>=1.1.1
  Using cached frozenlist-1.4.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (220 kB)
Collecting charset-normalizer<4.0,>=2.0
  Using cached charset_normalizer-3.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (137 kB)
Collecting async-timeout<5.0,>=4.0.0a3
  Using cached async_timeout-4.0.3-py3-none-any.whl (5.7 kB)
Collecting aiosignal>=1.1.2
  Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
Requirement already satisfied: idna>=2.0 in /usr/lib/python3/dist-packages (from yarl<2.0,>=1.0->aiohttp->openai) (2.8)
Installing collected packages: tqdm, multidict, yarl, frozenlist, charset-normalizer, async-timeout, aiosignal, aiohttp, openai
Successfully installed aiohttp-3.8.5 aiosignal-1.3.1 async-timeout-4.0.3 charset-normalizer-3.3.0 frozenlist-1.4.0 multidict-6.0.4 openai-0.28.1 tqdm-4.66.1 yarl-1.9.2

 

PyPDF2

pip install PyPDF2

Response

Collecting PyPDF2
  Downloading pypdf2-3.0.1-py3-none-any.whl (232 kB)
     |████████████████████████████████| 232 kB 18.7 MB/s
Collecting typing_extensions>=3.10.0.0; python_version < "3.10"
  Downloading typing_extensions-4.8.0-py3-none-any.whl (31 kB)
Installing collected packages: typing-extensions, PyPDF2
Successfully installed PyPDF2-3.0.1 typing-extensions-4.8.0

 

LangChain

pip install langchain==0.0.148

Response

Collecting langchain==0.0.148
  Downloading langchain-0.0.148-py3-none-any.whl (636 kB)
     |████████████████████████████████| 636 kB 16.0 MB/s
Collecting PyYAML>=5.4.1
  Downloading PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (736 kB)
     |████████████████████████████████| 736 kB 51.9 MB/s
Collecting openapi-schema-pydantic<2.0,>=1.2
  Downloading openapi_schema_pydantic-1.2.4-py3-none-any.whl (90 kB)
     |████████████████████████████████| 90 kB 8.3 MB/s
Collecting pydantic<2,>=1
  Downloading pydantic-1.10.13-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB)
     |████████████████████████████████| 3.2 MB 54.5 MB/s
Collecting dataclasses-json<0.6.0,>=0.5.7
  Downloading dataclasses_json-0.5.14-py3-none-any.whl (26 kB)
Collecting tenacity<9.0.0,>=8.1.0
  Downloading tenacity-8.2.3-py3-none-any.whl (24 kB)
Requirement already satisfied: async-timeout<5.0.0,>=4.0.0; python_version < "3.11" in /home/{environment}/.local/lib/python3.8/site-packages (from langchain==0.0.148) (4.0.3)
Requirement already satisfied: tqdm>=4.48.0 in /home/{environment}/.local/lib/python3.8/site-packages (from langchain==0.0.148) (4.66.1)
Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /home/{environment}/.local/lib/python3.8/site-packages (from langchain==0.0.148) (3.8.5)
Collecting numpy<2,>=1
  Downloading numpy-1.24.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.3 MB)
     |████████████████████████████████| 17.3 MB 51.3 MB/s
Collecting SQLAlchemy<2,>=1
  Downloading SQLAlchemy-1.4.49-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB)
     |████████████████████████████████| 1.6 MB 27.8 MB/s
Requirement already satisfied: requests<3,>=2 in /usr/lib/python3/dist-packages (from langchain==0.0.148) (2.22.0)
Collecting numexpr<3.0.0,>=2.8.4
  Downloading numexpr-2.8.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (384 kB)
     |████████████████████████████████| 384 kB 53.7 MB/s
Requirement already satisfied: typing-extensions>=4.2.0 in /home/{environment}/.local/lib/python3.8/site-packages (from pydantic<2,>=1->langchain==0.0.148) (4.8.0)
Collecting typing-inspect<1,>=0.4.0
  Downloading typing_inspect-0.9.0-py3-none-any.whl (8.8 kB)
Collecting marshmallow<4.0.0,>=3.18.0
  Downloading marshmallow-3.20.1-py3-none-any.whl (49 kB)
     |████████████████████████████████| 49 kB 6.9 MB/s
Requirement already satisfied: yarl<2.0,>=1.0 in /home/{environment}/.local/lib/python3.8/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.0.148) (1.9.2)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /home/{environment}/.local/lib/python3.8/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.0.148) (3.3.0)
Requirement already satisfied: frozenlist>=1.1.1 in /home/{environment}/.local/lib/python3.8/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.0.148) (1.4.0)
Requirement already satisfied: aiosignal>=1.1.2 in /home/{environment}/.local/lib/python3.8/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.0.148) (1.3.1)
Requirement already satisfied: multidict<7.0,>=4.5 in /home/{environment}/.local/lib/python3.8/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.0.148) (6.0.4)
Requirement already satisfied: attrs>=17.3.0 in /usr/lib/python3/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain==0.0.148) (19.3.0)
Collecting greenlet!=0.4.17; python_version >= "3" and (platform_machine == "aarch64" or (platform_machine == "ppc64le" or (platform_machine == "x86_64" or (platform_machine == "amd64" or (platform_machine == "AMD64" or (platform_machine == "win32" or platform_machine == "WIN32"))))))
  Downloading greenlet-2.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (618 kB)
     |████████████████████████████████| 618 kB 48.1 MB/s
Collecting mypy-extensions>=0.3.0
  Downloading mypy_extensions-1.0.0-py3-none-any.whl (4.7 kB)
Collecting packaging>=17.0
  Downloading packaging-23.2-py3-none-any.whl (53 kB)
     |████████████████████████████████| 53 kB 2.2 MB/s
Requirement already satisfied: idna>=2.0 in /usr/lib/python3/dist-packages (from yarl<2.0,>=1.0->aiohttp<4.0.0,>=3.8.3->langchain==0.0.148) (2.8)
Installing collected packages: PyYAML, pydantic, openapi-schema-pydantic, mypy-extensions, typing-inspect, packaging, marshmallow, dataclasses-json, tenacity, numpy, greenlet, SQLAlchemy, numexpr, langchain
Successfully installed PyYAML-6.0.1 SQLAlchemy-1.4.49 dataclasses-json-0.5.14 greenlet-2.0.2 langchain-0.0.148 marshmallow-3.20.1 mypy-extensions-1.0.0 numexpr-2.8.6 numpy-1.24.4 openapi-schema-pydantic-1.2.4 packaging-23.2 pydantic-1.10.13 tenacity-8.2.3 typing-inspect-0.9.0

 

LlamaIndex

pip install llama-index==0.5.6

Response

Collecting llama-index==0.5.6
  Downloading llama_index-0.5.6.tar.gz (165 kB)
     |████████████████████████████████| 165 kB 17.2 MB/s
Requirement already satisfied: dataclasses_json in /home/{environment}/.local/lib/python3.8/site-packages (from llama-index==0.5.6) (0.5.14)
Requirement already satisfied: langchain in /home/{environment}/.local/lib/python3.8/site-packages (from llama-index==0.5.6) (0.0.148)
Requirement already satisfied: numpy in /home/{environment}/.local/lib/python3.8/site-packages (from llama-index==0.5.6) (1.24.4)
Requirement already satisfied: openai>=0.26.4 in /home/{environment}/.local/lib/python3.8/site-packages (from llama-index==0.5.6) (0.28.1)
Collecting pandas
  Downloading pandas-2.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB)
     |████████████████████████████████| 12.4 MB 49.6 MB/s
Requirement already satisfied: tenacity<9.0.0,>=8.2.0 in /home/{environment}/.local/lib/python3.8/site-packages (from llama-index==0.5.6) (8.2.3)
Collecting transformers
  Downloading transformers-4.33.3-py3-none-any.whl (7.6 MB)
     |████████████████████████████████| 7.6 MB 20.3 MB/s
Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /home/{environment}/.local/lib/python3.8/site-packages (from dataclasses_json->llama-index==0.5.6) (3.20.1)
Requirement already satisfied: typing-inspect<1,>=0.4.0 in /home/{environment}/.local/lib/python3.8/site-packages (from dataclasses_json->llama-index==0.5.6) (0.9.0)
Requirement already satisfied: async-timeout<5.0.0,>=4.0.0; python_version < "3.11" in /home/{environment}/.local/lib/python3.8/site-packages (from langchain->llama-index==0.5.6) (4.0.3)
Requirement already satisfied: SQLAlchemy<2,>=1 in /home/{environment}/.local/lib/python3.8/site-packages (from langchain->llama-index==0.5.6) (1.4.49)
Requirement already satisfied: numexpr<3.0.0,>=2.8.4 in /home/{environment}/.local/lib/python3.8/site-packages (from langchain->llama-index==0.5.6) (2.8.6)
Requirement already satisfied: openapi-schema-pydantic<2.0,>=1.2 in /home/{environment}/.local/lib/python3.8/site-packages (from langchain->llama-index==0.5.6) (1.2.4)
Requirement already satisfied: tqdm>=4.48.0 in /home/{environment}/.local/lib/python3.8/site-packages (from langchain->llama-index==0.5.6) (4.66.1)
Requirement already satisfied: pydantic<2,>=1 in /home/{environment}/.local/lib/python3.8/site-packages (from langchain->llama-index==0.5.6) (1.10.13)
Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /home/{environment}/.local/lib/python3.8/site-packages (from langchain->llama-index==0.5.6) (3.8.5)
Requirement already satisfied: PyYAML>=5.4.1 in /home/{environment}/.local/lib/python3.8/site-packages (from langchain->llama-index==0.5.6) (6.0.1)
Requirement already satisfied: requests<3,>=2 in /usr/lib/python3/dist-packages (from langchain->llama-index==0.5.6) (2.22.0)
Collecting pytz>=2020.1
  Downloading pytz-2023.3.post1-py2.py3-none-any.whl (502 kB)
     |████████████████████████████████| 502 kB 49.1 MB/s
Collecting tzdata>=2022.1
  Downloading tzdata-2023.3-py2.py3-none-any.whl (341 kB)
     |████████████████████████████████| 341 kB 55.4 MB/s
Collecting python-dateutil>=2.8.2
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |████████████████████████████████| 247 kB 51.3 MB/s
Collecting regex!=2019.12.17
  Downloading regex-2023.8.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (774 kB)
     |████████████████████████████████| 774 kB 49.4 MB/s
Collecting filelock
  Downloading filelock-3.12.4-py3-none-any.whl (11 kB)
Collecting safetensors>=0.3.1
  Downloading safetensors-0.3.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)
     |████████████████████████████████| 1.3 MB 41.8 MB/s
Collecting huggingface-hub<1.0,>=0.15.1
  Downloading huggingface_hub-0.17.3-py3-none-any.whl (295 kB)
     |████████████████████████████████| 295 kB 50.9 MB/s
Requirement already satisfied: packaging>=20.0 in /home/{environment}/.local/lib/python3.8/site-packages (from transformers->llama-index==0.5.6) (23.2)
Collecting tokenizers!=0.11.3,<0.14,>=0.11.1
  Downloading tokenizers-0.13.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.8 MB)
     |████████████████████████████████| 7.8 MB 47.5 MB/s
Requirement already satisfied: mypy-extensions>=0.3.0 in /home/{environment}/.local/lib/python3.8/site-packages (from typing-inspect<1,>=0.4.0->dataclasses_json->llama-index==0.5.6) (1.0.0)
Requirement already satisfied: typing-extensions>=3.7.4 in /home/{environment}/.local/lib/python3.8/site-packages (from typing-inspect<1,>=0.4.0->dataclasses_json->llama-index==0.5.6) (4.8.0)
Requirement already satisfied: greenlet!=0.4.17; python_version >= "3" and (platform_machine == "aarch64" or (platform_machine == "ppc64le" or (platform_machine == "x86_64" or (platform_machine == "amd64" or (platform_machine == "AMD64" or (platform_machine == "win32" or platform_machine == "WIN32")))))) in /home/{environment}/.local/lib/python3.8/site-packages (from SQLAlchemy<2,>=1->langchain->llama-index==0.5.6) (2.0.2)
Requirement already satisfied: multidict<7.0,>=4.5 in /home/{environment}/.local/lib/python3.8/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain->llama-index==0.5.6) (6.0.4)
Requirement already satisfied: frozenlist>=1.1.1 in /home/{environment}/.local/lib/python3.8/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain->llama-index==0.5.6) (1.4.0)
Requirement already satisfied: attrs>=17.3.0 in /usr/lib/python3/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain->llama-index==0.5.6) (19.3.0)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /home/{environment}/.local/lib/python3.8/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain->llama-index==0.5.6) (3.3.0)
Requirement already satisfied: yarl<2.0,>=1.0 in /home/{environment}/.local/lib/python3.8/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain->llama-index==0.5.6) (1.9.2)
Requirement already satisfied: aiosignal>=1.1.2 in /home/{environment}/.local/lib/python3.8/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain->llama-index==0.5.6) (1.3.1)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas->llama-index==0.5.6) (1.14.0)
Collecting fsspec
  Downloading fsspec-2023.9.2-py3-none-any.whl (173 kB)
     |████████████████████████████████| 173 kB 50.6 MB/s
Requirement already satisfied: idna>=2.0 in /usr/lib/python3/dist-packages (from yarl<2.0,>=1.0->aiohttp<4.0.0,>=3.8.3->langchain->llama-index==0.5.6) (2.8)
Building wheels for collected packages: llama-index
  Building wheel for llama-index (setup.py) ... done
  Created wheel for llama-index: filename=llama_index-0.5.6-py3-none-any.whl size=248143 sha256=e61c3164b9e5844e35f47a5ecffd6b6e8c7cbea5f1dbf624709ab60457c4b51b
  Stored in directory: /home/{environment}/.cache/pip/wheels/36/0a/ab/00effed5ac4ae8fff62dd9efe408a96c53d84fadc7950c9d60
Successfully built llama-index
Installing collected packages: pytz, tzdata, python-dateutil, pandas, regex, filelock, safetensors, fsspec, huggingface-hub, tokenizers, transformers, llama-index
Successfully installed filelock-3.12.4 fsspec-2023.9.2 huggingface-hub-0.17.3 llama-index-0.5.6 pandas-2.0.3 python-dateutil-2.8.2 pytz-2023.3.post1 regex-2023.8.8 safetensors-0.3.3 tokenizers-0.13.3 transformers-4.33.3 tzdata-2023.3

 

Gradio

pip install gradio

Response

Collecting gradio
  Downloading gradio-3.45.2-py3-none-any.whl (20.2 MB)
     |████████████████████████████████| 20.2 MB 18.2 MB/s
Collecting pillow<11.0,>=8.0
  Downloading Pillow-10.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB)
     |████████████████████████████████| 3.5 MB 42.1 MB/s
Collecting uvicorn>=0.14.0
  Downloading uvicorn-0.23.2-py3-none-any.whl (59 kB)
     |████████████████████████████████| 59 kB 4.6 MB/s
Requirement already satisfied: pandas<3.0,>=1.0 in /home/{environment}/.local/lib/python3.8/site-packages (from gradio) (2.0.3)
Requirement already satisfied: requests~=2.0 in /usr/lib/python3/dist-packages (from gradio) (2.22.0)
Collecting importlib-resources<7.0,>=1.3
  Downloading importlib_resources-6.1.0-py3-none-any.whl (33 kB)
Requirement already satisfied: typing-extensions~=4.0 in /home/{environment}/.local/lib/python3.8/site-packages (from gradio) (4.8.0)
Requirement already satisfied: pyyaml<7.0,>=5.0 in /home/{environment}/.local/lib/python3.8/site-packages (from gradio) (6.0.1)
Collecting fastapi
  Downloading fastapi-0.103.2-py3-none-any.whl (66 kB)
     |████████████████████████████████| 66 kB 5.7 MB/s
Collecting orjson~=3.0
  Downloading orjson-3.9.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (138 kB)
     |████████████████████████████████| 138 kB 52.3 MB/s
Requirement already satisfied: jinja2<4.0 in /usr/lib/python3/dist-packages (from gradio) (2.10.1)
Collecting semantic-version~=2.0
  Downloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)
Requirement already satisfied: pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,<3.0.0,>=1.7.4 in /home/{environment}/.local/lib/python3.8/site-packages (from gradio) (1.10.13)
Requirement already satisfied: numpy~=1.0 in /home/{environment}/.local/lib/python3.8/site-packages (from gradio) (1.24.4)
Collecting markupsafe~=2.0
  Downloading MarkupSafe-2.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Collecting aiofiles<24.0,>=22.0
  Downloading aiofiles-23.2.1-py3-none-any.whl (15 kB)
Collecting altair<6.0,>=4.2.0
  Downloading altair-5.1.1-py3-none-any.whl (520 kB)
     |████████████████████████████████| 520 kB 45.0 MB/s
Collecting gradio-client==0.5.3
  Downloading gradio_client-0.5.3-py3-none-any.whl (298 kB)
     |████████████████████████████████| 298 kB 52.7 MB/s
Collecting pydub
  Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)
Collecting matplotlib~=3.0
  Downloading matplotlib-3.7.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (9.2 MB)
     |████████████████████████████████| 9.2 MB 39.9 MB/s
Collecting python-multipart
  Downloading python_multipart-0.0.6-py3-none-any.whl (45 kB)
     |████████████████████████████████| 45 kB 3.8 MB/s
Collecting websockets<12.0,>=10.0
  Downloading websockets-11.0.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (130 kB)
     |████████████████████████████████| 130 kB 54.6 MB/s
Collecting httpx
  Downloading httpx-0.25.0-py3-none-any.whl (75 kB)
     |████████████████████████████████| 75 kB 2.9 MB/s
Requirement already satisfied: huggingface-hub>=0.14.0 in /home/{environment}/.local/lib/python3.8/site-packages (from gradio) (0.17.3)
Requirement already satisfied: packaging in /home/{environment}/.local/lib/python3.8/site-packages (from gradio) (23.2)
Collecting ffmpy
  Downloading ffmpy-0.3.1.tar.gz (5.5 kB)
Requirement already satisfied: click>=7.0 in /usr/lib/python3/dist-packages (from uvicorn>=0.14.0->gradio) (7.0)
Collecting h11>=0.8
  Downloading h11-0.14.0-py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 5.8 MB/s
Requirement already satisfied: python-dateutil>=2.8.2 in /home/{environment}/.local/lib/python3.8/site-packages (from pandas<3.0,>=1.0->gradio) (2.8.2)
Requirement already satisfied: tzdata>=2022.1 in /home/{environment}/.local/lib/python3.8/site-packages (from pandas<3.0,>=1.0->gradio) (2023.3)
Requirement already satisfied: pytz>=2020.1 in /home/{environment}/.local/lib/python3.8/site-packages (from pandas<3.0,>=1.0->gradio) (2023.3.post1)
Collecting zipp>=3.1.0; python_version < "3.10"
  Downloading zipp-3.17.0-py3-none-any.whl (7.4 kB)
Collecting starlette<0.28.0,>=0.27.0
  Downloading starlette-0.27.0-py3-none-any.whl (66 kB)
     |████████████████████████████████| 66 kB 7.3 MB/s
Collecting anyio<4.0.0,>=3.7.1
  Downloading anyio-3.7.1-py3-none-any.whl (80 kB)
     |████████████████████████████████| 80 kB 10.5 MB/s
Requirement already satisfied: jsonschema>=3.0 in /usr/lib/python3/dist-packages (from altair<6.0,>=4.2.0->gradio) (3.2.0)
Collecting toolz
  Downloading toolz-0.12.0-py3-none-any.whl (55 kB)
     |████████████████████████████████| 55 kB 4.2 MB/s
Requirement already satisfied: fsspec in /home/{environment}/.local/lib/python3.8/site-packages (from gradio-client==0.5.3->gradio) (2023.9.2)
Collecting pyparsing>=2.3.1
  Downloading pyparsing-3.1.1-py3-none-any.whl (103 kB)
     |████████████████████████████████| 103 kB 55.7 MB/s
Collecting contourpy>=1.0.1
  Downloading contourpy-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (301 kB)
     |████████████████████████████████| 301 kB 55.6 MB/s
Collecting kiwisolver>=1.0.1
  Downloading kiwisolver-1.4.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.2 MB)
     |████████████████████████████████| 1.2 MB 48.7 MB/s
Collecting cycler>=0.10
  Downloading cycler-0.12.0-py3-none-any.whl (8.2 kB)
Collecting fonttools>=4.22.0
  Downloading fonttools-4.43.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.6 MB)
     |████████████████████████████████| 4.6 MB 36.8 MB/s
Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from httpx->gradio) (2019.11.28)
Requirement already satisfied: idna in /usr/lib/python3/dist-packages (from httpx->gradio) (2.8)
Collecting sniffio
  Downloading sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting httpcore<0.19.0,>=0.18.0
  Downloading httpcore-0.18.0-py3-none-any.whl (76 kB)
     |████████████████████████████████| 76 kB 6.0 MB/s
Requirement already satisfied: tqdm>=4.42.1 in /home/{environment}/.local/lib/python3.8/site-packages (from huggingface-hub>=0.14.0->gradio) (4.66.1)
Requirement already satisfied: filelock in /home/{environment}/.local/lib/python3.8/site-packages (from huggingface-hub>=0.14.0->gradio) (3.12.4)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas<3.0,>=1.0->gradio) (1.14.0)
Collecting exceptiongroup; python_version < "3.11"
  Downloading exceptiongroup-1.1.3-py3-none-any.whl (14 kB)
Building wheels for collected packages: ffmpy
  Building wheel for ffmpy (setup.py) ... done
  Created wheel for ffmpy: filename=ffmpy-0.3.1-py3-none-any.whl size=5580 sha256=588d681dcc97f8818e1b4e8fb515a54807e92552fece7fcf7a5be9c48d5c566c
  Stored in directory: /home/{environment}/.cache/pip/wheels/75/a3/1a/2f3f90b9a4eb0408109ae1b5bae01efbdf8ab4ef98797433e4
Successfully built ffmpy
Installing collected packages: pillow, h11, uvicorn, zipp, importlib-resources, sniffio, exceptiongroup, anyio, starlette, fastapi, orjson, semantic-version, markupsafe, aiofiles, toolz, altair, websockets, httpcore, httpx, gradio-client, pydub, pyparsing, contourpy, kiwisolver, cycler, fonttools, matplotlib, python-multipart, ffmpy, gradio
Successfully installed aiofiles-23.2.1 altair-5.1.1 anyio-3.7.1 contourpy-1.1.1 cycler-0.12.0 exceptiongroup-1.1.3 fastapi-0.103.2 ffmpy-0.3.1 fonttools-4.43.0 gradio-3.45.2 gradio-client-0.5.3 h11-0.14.0 httpcore-0.18.0 httpx-0.25.0 importlib-resources-6.1.0 kiwisolver-1.4.5 markupsafe-2.1.3 matplotlib-3.7.3 orjson-3.9.7 pillow-10.0.1 pydub-0.25.1 pyparsing-3.1.1 python-multipart-0.0.6 semantic-version-2.10.0 sniffio-1.3.0 starlette-0.27.0 toolz-0.12.0 uvicorn-0.23.2 websockets-11.0.3 zipp-3.17.0

 

List of PIP packages installed

To get the current list of PIP packages installed on the server, run the following command

pip list

Response for the environment I'm working on was

Package                 Version
----------------------- --------------------
aiofiles                23.2.1
aiohttp                 3.8.5
aiosignal               1.3.1
altair                  5.1.1
anyio                   3.7.1
async-timeout           4.0.3
attrs                   19.3.0
Automat                 0.8.0
blinker                 1.4
certifi                 2019.11.28
chardet                 3.0.4
charset-normalizer      3.3.0
Click                   7.0
cloud-init              23.2.2
colorama                0.4.3
command-not-found       0.3
configobj               5.0.6
constantly              15.1.0
contourpy               1.1.1
cryptography            2.8
cycler                  0.12.0
dataclasses-json        0.5.14
dbus-python             1.2.16
distro                  1.4.0
distro-info             0.23+ubuntu1.1
entrypoints             0.3
exceptiongroup          1.1.3
fastapi                 0.103.2
ffmpy                   0.3.1
filelock                3.12.4
fonttools               4.43.0
frozenlist              1.4.0
fsspec                  2023.9.2
gradio                  3.45.2
gradio-client           0.5.3
greenlet                2.0.2
h11                     0.14.0
httpcore                0.18.0
httplib2                0.14.0
httpx                   0.25.0
huggingface-hub         0.17.3
hyperlink               19.0.0
idna                    2.8
importlib-metadata      1.5.0
importlib-resources     6.1.0
incremental             16.10.1
Jinja2                  2.10.1
jsonpatch               1.22
jsonpointer             2.0
jsonschema              3.2.0
keyring                 18.0.1
kiwisolver              1.4.5
langchain               0.0.148
language-selector       0.1
launchpadlib            1.10.13
lazr.restfulclient      0.14.2
lazr.uri                1.0.3
llama-index             0.5.6
MarkupSafe              2.1.3
marshmallow             3.20.1
matplotlib              3.7.3
more-itertools          4.2.0
multidict               6.0.4
mypy-extensions         1.0.0
netifaces               0.10.4
numexpr                 2.8.6
numpy                   1.24.4
oauthlib                3.1.0
openai                  0.28.1
openapi-schema-pydantic 1.2.4
orjson                  3.9.7
packaging               23.2
pandas                  2.0.3
pexpect                 4.6.0
Pillow                  10.0.1
pip                     20.0.2
pyasn1                  0.4.2
pyasn1-modules          0.2.1
pydantic                1.10.13
pydub                   0.25.1
PyGObject               3.36.0
PyHamcrest              1.9.0
PyJWT                   1.7.1
pymacaroons             0.13.0
PyNaCl                  1.3.0
pyOpenSSL               19.0.0
pyparsing               3.1.1
pyparted                3.11.2
pypdf2                  3.0.1
pyrsistent              0.15.5
pyserial                3.4
python-apt              2.0.1+ubuntu0.20.4.1
python-dateutil         2.8.2
python-debian           0.1.36+ubuntu1.1
python-multipart        0.0.6
pytz                    2023.3.post1
PyYAML                  6.0.1
regex                   2023.8.8
requests                2.22.0
requests-unixsocket     0.2.0
safetensors             0.3.3
SecretStorage           2.3.1
semantic-version        2.10.0
service-identity        18.1.0
setuptools              45.2.0
simplejson              3.16.0
six                     1.14.0
sniffio                 1.3.0
sos                     4.5.6
SQLAlchemy              1.4.49
ssh-import-id           5.10
starlette               0.27.0
systemd-python          234
tenacity                8.2.3
tokenizers              0.13.3
toolz                   0.12.0
tqdm                    4.66.1
transformers            4.33.3
Twisted                 18.9.0
typing-extensions       4.8.0
typing-inspect          0.9.0
tzdata                  2023.3
ubuntu-advantage-tools  8001
ufw                     0.36
unattended-upgrades     0.1
urllib3                 1.25.8
uvicorn                 0.23.2
wadllib                 1.3.3
WALinuxAgent            2.2.46
websockets              11.0.3
wheel                   0.34.2
yarl                    1.9.2
zipp                    3.17.0
zope.interface          4.7.1

 

List up-to-date packages: -u, --uptodate

pip list -u or --uptodate

 

List outdated packages: -o, --outdated

pip list -o or --outdated

 

List packages not required by other packages: --not-required

pip list --not-required

 

Creating a file to manage 

OpenAI API Key

The generated API key should be set as the environment variable OPENAI_API_KEY within the program.

import os
os.environ["OPENAI_API_KEY"] = '{your-openai-key}'

 

Running the file

python3 model-ai.py

The initial run of this command produced the following error

ImportError: cannot import name 'soft_unicode' from 'markupsafe'

For further details about how to resolve this error - go to ImportError: cannot import name 'soft_unicode' from 'markupsafe' 

Post fixing the issue noted above, the second run produced the following

/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.25.8) or chardet (5.2.0) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
INFO:matplotlib.font_manager:generated new fontManager
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
Downloading (…)olve/main/vocab.json: 100%|██████████████████| 1.04M/1.04M [00:00<00:00, 5.27MB/s]
Downloading (…)olve/main/merges.txt: 100%|████████████████████| 456k/456k [00:00<00:00, 45.2MB/s]
Downloading (…)/main/tokenizer.json: 100%|██████████████████| 1.36M/1.36M [00:00<00:00, 65.1MB/s]
Downloading (…)lve/main/config.json: 100%|███████████████████████| 665/665 [00:00<00:00, 386kB/s]
Token indices sequence length is longer than the specified maximum sequence length for this model (3582 > 1024). Running this sequence through the model will result in indexing errors
INFO:llama_index.token_counter.token_counter:> [build_index_from_nodes] Total LLM token usage: 0 tokens
INFO:llama_index.token_counter.token_counter:> [build_index_from_nodes] Total embedding token usage: 80552 tokens
model-ai.py:52: GradioDeprecationWarning: `allow_screenshot` parameter is deprecated, and it has no effect
  iface = gr.Interface(fn=chatbot,
Running on local URL:  http://127.0.0.1:7860
huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
To disable this warning, you can either:
	- Avoid using `tokenizers` before the fork if possible
	- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
Running on public URL: {link-to-live-version)

This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)

 

Related articles