Spaces:
Running
Running
Fahad Mattoo
commited on
Commit
•
d4a7025
1
Parent(s):
ec2081f
Simple app (#5) (#6)
Browse files* title app
* updating the req, readme, and the app
* update
* updating pylint
* adding complete application
* linting update
* addding pytest
* updating tonl
* adad
* upda
* updating yml file
* test
- .github/workflows/github-ci.yml +56 -0
- .github/workflows/pylint.yml +0 -23
- .gitignore +160 -160
- .streamlit/config.toml +2 -0
- LICENSE +24 -24
- README.md +33 -2
- pyproject.toml +188 -190
- requirements.txt +2 -0
- src/app.py +103 -5
- tests/test_return_true.py +6 -0
.github/workflows/github-ci.yml
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: lint-and-test
|
2 |
+
|
3 |
+
on: [push]
|
4 |
+
|
5 |
+
jobs:
|
6 |
+
lint:
|
7 |
+
runs-on: ubuntu-latest
|
8 |
+
|
9 |
+
strategy:
|
10 |
+
matrix:
|
11 |
+
python-version: ["3.10"]
|
12 |
+
|
13 |
+
steps:
|
14 |
+
- name: Checkout code
|
15 |
+
uses: actions/checkout@v4
|
16 |
+
|
17 |
+
- name: Set up Python ${{ matrix.python-version }}
|
18 |
+
uses: actions/setup-python@v4
|
19 |
+
with:
|
20 |
+
python-version: ${{ matrix.python-version }}
|
21 |
+
|
22 |
+
- name: Install dependencies
|
23 |
+
run: |
|
24 |
+
python -m pip install --upgrade pip
|
25 |
+
pip install pylint
|
26 |
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
27 |
+
|
28 |
+
- name: Run pylint
|
29 |
+
run: |
|
30 |
+
pylint $(git ls-files '*.py')
|
31 |
+
|
32 |
+
test:
|
33 |
+
runs-on: ubuntu-latest
|
34 |
+
|
35 |
+
strategy:
|
36 |
+
matrix:
|
37 |
+
python-version: ["3.10"]
|
38 |
+
|
39 |
+
steps:
|
40 |
+
- name: Checkout code
|
41 |
+
uses: actions/checkout@v4
|
42 |
+
|
43 |
+
- name: Set up Python ${{ matrix.python-version }}
|
44 |
+
uses: actions/setup-python@v4
|
45 |
+
with:
|
46 |
+
python-version: ${{ matrix.python-version }}
|
47 |
+
|
48 |
+
- name: Install dependencies
|
49 |
+
run: |
|
50 |
+
python -m pip install --upgrade pip
|
51 |
+
pip install pytest-cov
|
52 |
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
53 |
+
|
54 |
+
- name: Run pytest with coverage
|
55 |
+
run: |
|
56 |
+
pytest --cov=src --cov-report=term-missing --cov-branch
|
.github/workflows/pylint.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
name: Pylint
|
2 |
-
|
3 |
-
on: [push]
|
4 |
-
|
5 |
-
jobs:
|
6 |
-
build:
|
7 |
-
runs-on: ubuntu-latest
|
8 |
-
strategy:
|
9 |
-
matrix:
|
10 |
-
python-version: ["3.10", "3.11"]
|
11 |
-
steps:
|
12 |
-
- uses: actions/checkout@v4
|
13 |
-
- name: Set up Python ${{ matrix.python-version }}
|
14 |
-
uses: actions/setup-python@v4
|
15 |
-
with:
|
16 |
-
python-version: ${{ matrix.python-version }}
|
17 |
-
- name: Install dependencies
|
18 |
-
run: |
|
19 |
-
python -m pip install --upgrade pip
|
20 |
-
pip install pylint
|
21 |
-
- name: Analysing the code with pylint
|
22 |
-
run: |
|
23 |
-
pylint $(git ls-files '*.py')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
CHANGED
@@ -1,160 +1,160 @@
|
|
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/
|
|
|
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/
|
.streamlit/config.toml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
[client]
|
2 |
+
showErrorDetails = false
|
LICENSE
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
-
This is free and unencumbered software released into the public domain.
|
2 |
-
|
3 |
-
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4 |
-
distribute this software, either in source code form or as a compiled
|
5 |
-
binary, for any purpose, commercial or non-commercial, and by any
|
6 |
-
means.
|
7 |
-
|
8 |
-
In jurisdictions that recognize copyright laws, the author or authors
|
9 |
-
of this software dedicate any and all copyright interest in the
|
10 |
-
software to the public domain. We make this dedication for the benefit
|
11 |
-
of the public at large and to the detriment of our heirs and
|
12 |
-
successors. We intend this dedication to be an overt act of
|
13 |
-
relinquishment in perpetuity of all present and future rights to this
|
14 |
-
software under copyright law.
|
15 |
-
|
16 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17 |
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18 |
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19 |
-
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20 |
-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21 |
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22 |
-
OTHER DEALINGS IN THE SOFTWARE.
|
23 |
-
|
24 |
-
For more information, please refer to <https://unlicense.org>
|
|
|
1 |
+
This is free and unencumbered software released into the public domain.
|
2 |
+
|
3 |
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4 |
+
distribute this software, either in source code form or as a compiled
|
5 |
+
binary, for any purpose, commercial or non-commercial, and by any
|
6 |
+
means.
|
7 |
+
|
8 |
+
In jurisdictions that recognize copyright laws, the author or authors
|
9 |
+
of this software dedicate any and all copyright interest in the
|
10 |
+
software to the public domain. We make this dedication for the benefit
|
11 |
+
of the public at large and to the detriment of our heirs and
|
12 |
+
successors. We intend this dedication to be an overt act of
|
13 |
+
relinquishment in perpetuity of all present and future rights to this
|
14 |
+
software under copyright law.
|
15 |
+
|
16 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19 |
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20 |
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21 |
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22 |
+
OTHER DEALINGS IN THE SOFTWARE.
|
23 |
+
|
24 |
+
For more information, please refer to <https://unlicense.org>
|
README.md
CHANGED
@@ -1,2 +1,33 @@
|
|
1 |
-
# simple-chat-bot
|
2 |
-
This is a simple chat bot using openAI GPT models.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# simple-chat-bot
|
2 |
+
This is a simple chat bot using openAI GPT models.
|
3 |
+
|
4 |
+
## Create env
|
5 |
+
|
6 |
+
1. Create conda env
|
7 |
+
```
|
8 |
+
conda create -n chat_bot_env python=3.10
|
9 |
+
```
|
10 |
+
|
11 |
+
2. Activate env
|
12 |
+
|
13 |
+
```
|
14 |
+
conda activate chat_bot_env
|
15 |
+
```
|
16 |
+
|
17 |
+
3. install packages
|
18 |
+
```
|
19 |
+
pip install -r requirements.txt
|
20 |
+
```
|
21 |
+
|
22 |
+
## Run the application
|
23 |
+
|
24 |
+
```
|
25 |
+
streamlit run src\app.py
|
26 |
+
```
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
pyproject.toml
CHANGED
@@ -1,190 +1,188 @@
|
|
1 |
-
[project]
|
2 |
-
name = "simple-chat-bot"
|
3 |
-
authors = [
|
4 |
-
{name = "Fahad Mattoo", email = "[email protected]"},
|
5 |
-
]
|
6 |
-
description = "A simple chat bot."
|
7 |
-
readme = "README.md"
|
8 |
-
classifiers = [
|
9 |
-
"Development Status :: beta",
|
10 |
-
"Programming Language :: Python :: 3 :: Only",
|
11 |
-
"Programming Language :: Python :: 3.10",
|
12 |
-
"Programming Language :: Python :: 3.11"
|
13 |
-
]
|
14 |
-
requires-python = ">=3.10"
|
15 |
-
dynamic = ["version"]
|
16 |
-
|
17 |
-
[tool.black]
|
18 |
-
line-length = 120
|
19 |
-
fast = true
|
20 |
-
|
21 |
-
[tool.coverage.run]
|
22 |
-
branch = true
|
23 |
-
|
24 |
-
[tool.coverage.report]
|
25 |
-
fail_under =
|
26 |
-
|
27 |
-
[tool.pytest.ini_options]
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
"
|
37 |
-
"
|
38 |
-
"
|
39 |
-
"
|
40 |
-
"
|
41 |
-
"
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
"
|
81 |
-
"
|
82 |
-
"
|
83 |
-
"
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
"
|
111 |
-
|
112 |
-
|
113 |
-
]
|
114 |
-
|
115 |
-
|
116 |
-
ignore-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
ignore-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
missing-member-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
"
|
155 |
-
"
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
"
|
161 |
-
"
|
162 |
-
"
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
max-
|
171 |
-
max-
|
172 |
-
max-
|
173 |
-
max-
|
174 |
-
max-
|
175 |
-
max-
|
176 |
-
max-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
"Exception"
|
190 |
-
]
|
|
|
1 |
+
[project]
|
2 |
+
name = "simple-chat-bot"
|
3 |
+
authors = [
|
4 |
+
{name = "Fahad Mattoo", email = "[email protected]"},
|
5 |
+
]
|
6 |
+
description = "A simple chat bot."
|
7 |
+
readme = "README.md"
|
8 |
+
classifiers = [
|
9 |
+
"Development Status :: beta",
|
10 |
+
"Programming Language :: Python :: 3 :: Only",
|
11 |
+
"Programming Language :: Python :: 3.10",
|
12 |
+
"Programming Language :: Python :: 3.11"
|
13 |
+
]
|
14 |
+
requires-python = ">=3.10"
|
15 |
+
dynamic = ["version"]
|
16 |
+
|
17 |
+
[tool.black]
|
18 |
+
line-length = 120
|
19 |
+
fast = true
|
20 |
+
|
21 |
+
[tool.coverage.run]
|
22 |
+
branch = true
|
23 |
+
|
24 |
+
[tool.coverage.report]
|
25 |
+
fail_under = 0
|
26 |
+
|
27 |
+
[tool.pytest.ini_options]
|
28 |
+
pythonpath = [
|
29 |
+
"src"
|
30 |
+
]
|
31 |
+
|
32 |
+
[tool.pylint]
|
33 |
+
extension-pkg-whitelist= [
|
34 |
+
"numpy",
|
35 |
+
"torch",
|
36 |
+
"cv2",
|
37 |
+
"pyodbc",
|
38 |
+
"pydantic",
|
39 |
+
"ciso8601",
|
40 |
+
"netcdf4",
|
41 |
+
"scipy"
|
42 |
+
]
|
43 |
+
ignore="CVS"
|
44 |
+
ignore-patterns="test.*?py,conftest.py"
|
45 |
+
init-hook='import sys; sys.setrecursionlimit(8 * sys.getrecursionlimit())'
|
46 |
+
jobs=0
|
47 |
+
limit-inference-results=100
|
48 |
+
persistent="yes"
|
49 |
+
suggestion-mode="yes"
|
50 |
+
unsafe-load-any-extension="no"
|
51 |
+
|
52 |
+
[tool.pylint.'MESSAGES CONTROL']
|
53 |
+
enable="c-extension-no-member"
|
54 |
+
|
55 |
+
[tool.pylint.'REPORTS']
|
56 |
+
evaluation="10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)"
|
57 |
+
output-format="text"
|
58 |
+
reports="no"
|
59 |
+
score="yes"
|
60 |
+
|
61 |
+
[tool.pylint.'REFACTORING']
|
62 |
+
max-nested-blocks=5
|
63 |
+
never-returning-functions="sys.exit"
|
64 |
+
|
65 |
+
[tool.pylint.'BASIC']
|
66 |
+
argument-naming-style="snake_case"
|
67 |
+
attr-naming-style="snake_case"
|
68 |
+
bad-names= [
|
69 |
+
"foo",
|
70 |
+
"bar"
|
71 |
+
]
|
72 |
+
class-attribute-naming-style="any"
|
73 |
+
class-naming-style="PascalCase"
|
74 |
+
const-naming-style="UPPER_CASE"
|
75 |
+
docstring-min-length=-1
|
76 |
+
function-naming-style="snake_case"
|
77 |
+
good-names= [
|
78 |
+
"i",
|
79 |
+
"j",
|
80 |
+
"k",
|
81 |
+
"ex",
|
82 |
+
"Run",
|
83 |
+
"_"
|
84 |
+
]
|
85 |
+
include-naming-hint="yes"
|
86 |
+
inlinevar-naming-style="any"
|
87 |
+
method-naming-style="snake_case"
|
88 |
+
module-naming-style="any"
|
89 |
+
no-docstring-rgx="^_"
|
90 |
+
property-classes="abc.abstractproperty"
|
91 |
+
variable-naming-style="snake_case"
|
92 |
+
|
93 |
+
[tool.pylint.'FORMAT']
|
94 |
+
ignore-long-lines="^\\s*(# )?.*['\"]?<?https?://\\S+>?"
|
95 |
+
indent-after-paren=4
|
96 |
+
indent-string=' '
|
97 |
+
max-line-length=120
|
98 |
+
max-module-lines=1000
|
99 |
+
single-line-class-stmt="no"
|
100 |
+
single-line-if-stmt="no"
|
101 |
+
|
102 |
+
[tool.pylint.'LOGGING']
|
103 |
+
logging-format-style="old"
|
104 |
+
logging-modules="logging"
|
105 |
+
|
106 |
+
[tool.pylint.'MISCELLANEOUS']
|
107 |
+
notes= [
|
108 |
+
"FIXME",
|
109 |
+
"XXX",
|
110 |
+
"TODO"
|
111 |
+
]
|
112 |
+
|
113 |
+
[tool.pylint.'SIMILARITIES']
|
114 |
+
ignore-comments="yes"
|
115 |
+
ignore-docstrings="yes"
|
116 |
+
ignore-imports="yes"
|
117 |
+
min-similarity-lines=7
|
118 |
+
|
119 |
+
[tool.pylint.'SPELLING']
|
120 |
+
max-spelling-suggestions=4
|
121 |
+
spelling-store-unknown-words="no"
|
122 |
+
|
123 |
+
[tool.pylint.'STRING']
|
124 |
+
check-str-concat-over-line-jumps="no"
|
125 |
+
|
126 |
+
[tool.pylint.'TYPECHECK']
|
127 |
+
contextmanager-decorators="contextlib.contextmanager"
|
128 |
+
generated-members="numpy.*,np.*,pyspark.sql.functions,collect_list"
|
129 |
+
ignore-mixin-members="yes"
|
130 |
+
ignore-none="yes"
|
131 |
+
ignore-on-opaque-inference="yes"
|
132 |
+
ignored-classes="optparse.Values,thread._local,_thread._local,numpy,torch,swagger_client"
|
133 |
+
ignored-modules="numpy,torch,swagger_client,netCDF4,scipy"
|
134 |
+
missing-member-hint="yes"
|
135 |
+
missing-member-hint-distance=1
|
136 |
+
missing-member-max-choices=1
|
137 |
+
|
138 |
+
[tool.pylint.'VARIABLES']
|
139 |
+
additional-builtins="dbutils"
|
140 |
+
allow-global-unused-variables="yes"
|
141 |
+
callbacks= [
|
142 |
+
"cb_",
|
143 |
+
"_cb"
|
144 |
+
]
|
145 |
+
dummy-variables-rgx="_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_"
|
146 |
+
ignored-argument-names="_.*|^ignored_|^unused_"
|
147 |
+
init-import="no"
|
148 |
+
redefining-builtins-modules="six.moves,past.builtins,future.builtins,builtins,io"
|
149 |
+
|
150 |
+
[tool.pylint.'CLASSES']
|
151 |
+
defining-attr-methods= [
|
152 |
+
"__init__",
|
153 |
+
"__new__",
|
154 |
+
"setUp",
|
155 |
+
"__post_init__"
|
156 |
+
]
|
157 |
+
exclude-protected= [
|
158 |
+
"_asdict",
|
159 |
+
"_fields",
|
160 |
+
"_replace",
|
161 |
+
"_source",
|
162 |
+
"_make"
|
163 |
+
]
|
164 |
+
valid-classmethod-first-arg="cls"
|
165 |
+
valid-metaclass-classmethod-first-arg="cls"
|
166 |
+
|
167 |
+
[tool.pylint.'DESIGN']
|
168 |
+
max-args=5
|
169 |
+
max-attributes=7
|
170 |
+
max-bool-expr=5
|
171 |
+
max-branches=12
|
172 |
+
max-locals=15
|
173 |
+
max-parents=7
|
174 |
+
max-public-methods=20
|
175 |
+
max-returns=6
|
176 |
+
max-statements=50
|
177 |
+
min-public-methods=2
|
178 |
+
|
179 |
+
[tool.pylint.'IMPORTS']
|
180 |
+
allow-wildcard-with-all="no"
|
181 |
+
analyse-fallback-blocks="no"
|
182 |
+
deprecated-modules="optparse,tkinter.tix"
|
183 |
+
|
184 |
+
[tool.pylint.'EXCEPTIONS']
|
185 |
+
overgeneral-exceptions= [
|
186 |
+
"BaseException",
|
187 |
+
"Exception"
|
188 |
+
]
|
|
|
|
requirements.txt
CHANGED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit==1.31.1
|
2 |
+
openai==1.13.3
|
src/app.py
CHANGED
@@ -1,5 +1,103 @@
|
|
1 |
-
"""Module doc string"""
|
2 |
-
|
3 |
-
import
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Module doc string"""
|
2 |
+
|
3 |
+
import openai
|
4 |
+
import streamlit as st
|
5 |
+
from openai import OpenAI
|
6 |
+
|
7 |
+
def return_true():
|
8 |
+
"""_summary_
|
9 |
+
"""
|
10 |
+
return True
|
11 |
+
|
12 |
+
def reset_history():
|
13 |
+
"""_summary_"""
|
14 |
+
st.session_state.messages = []
|
15 |
+
|
16 |
+
|
17 |
+
def check_openai_api_key():
|
18 |
+
"""_summary_"""
|
19 |
+
try:
|
20 |
+
client = OpenAI(api_key=st.session_state.openai_api_key)
|
21 |
+
try:
|
22 |
+
client.models.list()
|
23 |
+
except openai.AuthenticationError as error:
|
24 |
+
with st.chat_message("assistant"):
|
25 |
+
st.error(str(error))
|
26 |
+
return False
|
27 |
+
return True
|
28 |
+
except Exception as error:
|
29 |
+
with st.chat_message("assistant"):
|
30 |
+
st.error(str(error))
|
31 |
+
return False
|
32 |
+
|
33 |
+
|
34 |
+
def main():
|
35 |
+
"""_summary_"""
|
36 |
+
st.set_page_config(
|
37 |
+
page_title="Test", layout="centered", initial_sidebar_state="auto"
|
38 |
+
)
|
39 |
+
st.title("Simple Chat Bot")
|
40 |
+
|
41 |
+
if "messages" not in st.session_state:
|
42 |
+
st.session_state.messages = []
|
43 |
+
|
44 |
+
if "openai_model" not in st.session_state:
|
45 |
+
st.session_state["openai_model"] = "gpt-3.5-turbo"
|
46 |
+
|
47 |
+
if "openai_api_key" not in st.session_state:
|
48 |
+
st.session_state["openai_api_key"] = None
|
49 |
+
|
50 |
+
if "openai_maxtokens" not in st.session_state:
|
51 |
+
st.session_state["openai_maxtokens"] = 50
|
52 |
+
|
53 |
+
if st.session_state.openai_api_key is not None:
|
54 |
+
if check_openai_api_key():
|
55 |
+
client = OpenAI(api_key=st.session_state.openai_api_key)
|
56 |
+
|
57 |
+
for message in st.session_state.messages:
|
58 |
+
with st.chat_message(message["role"]):
|
59 |
+
st.markdown(message["content"])
|
60 |
+
|
61 |
+
if prompt := st.chat_input("Type your Query"):
|
62 |
+
with st.chat_message("user"):
|
63 |
+
st.markdown(prompt)
|
64 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
65 |
+
|
66 |
+
with st.chat_message("assistant"):
|
67 |
+
stream = client.chat.completions.create(
|
68 |
+
model=st.session_state["openai_model"],
|
69 |
+
messages=[
|
70 |
+
{"role": m["role"], "content": m["content"]}
|
71 |
+
for m in st.session_state.messages
|
72 |
+
],
|
73 |
+
max_tokens=st.session_state["openai_maxtokens"],
|
74 |
+
stream=True,
|
75 |
+
)
|
76 |
+
response = st.write_stream(stream)
|
77 |
+
st.session_state.messages.append(
|
78 |
+
{"role": "assistant", "content": response}
|
79 |
+
)
|
80 |
+
else:
|
81 |
+
reset_history()
|
82 |
+
|
83 |
+
with st.sidebar:
|
84 |
+
st.text_input(
|
85 |
+
label="OpenAI API key",
|
86 |
+
value="***",
|
87 |
+
key="openai_api_key",
|
88 |
+
help="This will not be saved or stored.",
|
89 |
+
type="password",
|
90 |
+
)
|
91 |
+
|
92 |
+
st.selectbox(
|
93 |
+
"Select the GPT model",
|
94 |
+
("gpt-3.5-turbo", "gpt-4-turbo-preview"),
|
95 |
+
)
|
96 |
+
st.slider(
|
97 |
+
"Max Tokens", min_value=20, max_value=80, step=10, key="openai_maxtokens"
|
98 |
+
)
|
99 |
+
st.button(label="Reset Chat", on_click=reset_history)
|
100 |
+
|
101 |
+
|
102 |
+
if __name__ == "__main__":
|
103 |
+
main()
|
tests/test_return_true.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pytest
|
2 |
+
from app import return_true
|
3 |
+
|
4 |
+
|
5 |
+
def test_reset_history():
|
6 |
+
assert return_true() == True
|