Skip to content

Commit 74d0468

Browse files
authored
pgml chatbot readme update to reflect pypi (#900)
1 parent 846377d commit 74d0468

File tree

4 files changed

+196
-21
lines changed

4 files changed

+196
-21
lines changed

pgml-apps/pgml-chat/.gitignore

Lines changed: 160 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,160 @@
1-
.env
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
#.idea/

pgml-apps/pgml-chat/README.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ Before you begin, make sure you have the following:
1414
- Python version >=3.8
1515
- OpenAI API key
1616
- Python 3.8+
17-
- Poetry
17+
1818

1919
# Getting started
20-
1. Clone this repository, start a poetry shell and install dependencies
20+
1. Create a virtual environment and install `pgml-chat` using `pip`:
2121
```bash
22-
git clone https://github.com/postgresml/postgresml
23-
cd postgresml/pgml-apps/pgml-chat
24-
poetry shell
25-
poetry install
26-
pip install .
22+
pip install pgml-chat
2723
```
2824

29-
2. Update environment variables in `.env` file
25+
`pgml-chat` will be installed in your PATH.
26+
27+
2. Download `.env.template` file from PostgresML Github repository.
28+
3029
```bash
31-
cp .env.template .env
30+
wget https://github.com/postgresml/postgresml/blob/master/pgml-apps/pgml-chat/.env.template
3231
```
32+
3. Copy the template file to `.env`
3333

34-
Update environment variables with your OpenAI API key and PostgresML database credentials.
34+
4. Update environment variables with your OpenAI API key and PostgresML database credentials.
3535
```bash
3636
OPENAI_API_KEY=<OPENAI_API_KEY>
3737
DATABASE_URL=<POSTGRES_DATABASE_URL starts with postgres://>
@@ -157,13 +157,32 @@ Once the discord app is running, you can interact with the chatbot on Discord as
157157
158158
![Discord Chatbot](./images/discord_screenshot.png)
159159
160-
## Options
160+
# Developer Guide
161+
162+
1. Clone this repository, start a poetry shell and install dependencies
163+
164+
```bash
165+
git clone https://github.com/postgresml/postgresml
166+
cd postgresml/pgml-apps/pgml-chat
167+
poetry shell
168+
poetry install
169+
pip install .
170+
```
171+
172+
2. Create a .env file in the root directory of the project and add all the environment variables discussed in [Getting Started](#getting-started) section.
173+
3. All the logic is in `pgml_chat/main.py`
174+
4. Check the [roadmap](#roadmap) for features that you would like to work on.
175+
5. If you are looking for features that are not included here, please open an issue and we will add it to the roadmap.
176+
177+
178+
179+
# Options
161180
You can control the behavior of the chatbot by setting the following environment variables:
162181
- `SYSTEM_PROMPT`: This is the prompt that is used to initialize the chatbot. You can customize this prompt to change the behavior of the chatbot. For example, you can change the name of the chatbot or the location of the chatbot.
163182
- `BASE_PROMPT`: This is the prompt that is used to generate responses to user queries. You can customize this prompt to change the behavior of the chatbot.
164183
- `MODEL`: This is the open source embedding model used to generate embeddings for the documents. You can change this to use a different model.
165184
166-
## Roadmap
185+
# Roadmap
167186
- ~~`hyerbot --chat_interface {cli, slack, discord}` that supports Slack, and Discord.~~
168187
- Support for file formats like rst, html, pdf, docx, etc.
169188
- Support for open source models in addition to OpenAI for chat completion.

pgml-apps/pgml-chat/pgml_chat/main.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,11 @@ async def get_prompt(user_input: str = ""):
258258
)
259259
log.info(vector_results)
260260
context = ""
261+
261262
for result in vector_results:
262-
if result[0] > 0.7:
263-
context += result[1] + "\n"
264-
if context:
265-
print("Found relevant documentation.... ")
266-
query = base_prompt.format(context=context, question=user_input)
267-
else:
268-
query = user_input
263+
context += result[1] + "\n"
264+
265+
query = base_prompt.format(context=context, question=user_input)
269266

270267
return query
271268

pgml-apps/pgml-chat/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pgml-chat"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "PostgresML bot builder for all your documentation"
55
authors = ["PostgresML <team@postgresml.org>"]
66
license = "MIT"

0 commit comments

Comments
 (0)