Ibraaheem commited on
Commit
51ddb70
·
1 Parent(s): 67549d4

Upload 19 files

Browse files
.dockerignore ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .venv
2
+ models
3
+ .github
4
+ .vscode
5
+ .DS_Store
6
+ .mypy_cache
7
+ .ruff_cache
8
+ local_data
9
+ terraform
10
+ tests
11
+ Dockerfile
12
+ Dockerfile.*
.gitignore ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .venv
2
+
3
+ settings-me.yaml
4
+
5
+ .ruff_cache
6
+ .pytest_cache
7
+ .mypy_cache
8
+
9
+ # byte-compiled / optimized / DLL files
10
+ __pycache__/
11
+ *.py[cod]
12
+
13
+ # unit tests / coverage reports
14
+ /tests-results.xml
15
+ /.coverage
16
+ /coverage.xml
17
+ /htmlcov/
18
+
19
+ # pyenv
20
+ /.python-version
21
+
22
+ # IDE
23
+ .idea/
24
+ .vscode/
25
+ /.run/
26
+ .fleet/
27
+
28
+ # macOS
29
+ .DS_Store
.pre-commit-config.yaml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ default_install_hook_types:
2
+ # Mandatory to install both pre-commit and pre-push hooks (see https://pre-commit.com/#top_level-default_install_hook_types)
3
+ # Add new hook types here to ensure automatic installation when running `pre-commit install`
4
+ - pre-commit
5
+ - pre-push
6
+ repos:
7
+ - repo: https://github.com/pre-commit/pre-commit-hooks
8
+ rev: v4.3.0
9
+ hooks:
10
+ - id: trailing-whitespace
11
+ - id: end-of-file-fixer
12
+ - id: check-yaml
13
+ - id: check-json
14
+ - id: check-added-large-files
15
+
16
+ - repo: local
17
+ hooks:
18
+ - id: black
19
+ name: Formatting (black)
20
+ entry: black
21
+ language: system
22
+ types: [python]
23
+ stages: [commit]
24
+ - id: ruff
25
+ name: Linter (ruff)
26
+ entry: ruff
27
+ language: system
28
+ types: [python]
29
+ stages: [commit]
30
+ - id: mypy
31
+ name: Type checking (mypy)
32
+ entry: make mypy
33
+ pass_filenames: false
34
+ language: system
35
+ types: [python]
36
+ stages: [commit]
37
+ - id: test
38
+ name: Unit tests (pytest)
39
+ entry: make test
40
+ pass_filenames: false
41
+ language: system
42
+ types: [python]
43
+ stages: [push]
CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog
2
+
3
+ ## [0.1.0](https://github.com/imartinez/privateGPT/compare/v0.0.2...v0.1.0) (2023-11-30)
4
+
5
+
6
+ ### Features
7
+
8
+ * Disable Gradio Analytics ([#1165](https://github.com/imartinez/privateGPT/issues/1165)) ([6583dc8](https://github.com/imartinez/privateGPT/commit/6583dc84c082773443fc3973b1cdf8095fa3fec3))
9
+ * Drop loguru and use builtin `logging` ([#1133](https://github.com/imartinez/privateGPT/issues/1133)) ([64c5ae2](https://github.com/imartinez/privateGPT/commit/64c5ae214a9520151c9c2d52ece535867d799367))
10
+ * enable resume download for hf_hub_download ([#1249](https://github.com/imartinez/privateGPT/issues/1249)) ([4197ada](https://github.com/imartinez/privateGPT/commit/4197ada6267c822f32c1d7ba2be6e7ce145a3404))
11
+ * move torch and transformers to local group ([#1172](https://github.com/imartinez/privateGPT/issues/1172)) ([0d677e1](https://github.com/imartinez/privateGPT/commit/0d677e10b970aec222ec04837d0f08f1631b6d4a))
12
+ * Qdrant support ([#1228](https://github.com/imartinez/privateGPT/issues/1228)) ([03d1ae6](https://github.com/imartinez/privateGPT/commit/03d1ae6d70dffdd2411f0d4e92f65080fff5a6e2))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * Docker and sagemaker setup ([#1118](https://github.com/imartinez/privateGPT/issues/1118)) ([895588b](https://github.com/imartinez/privateGPT/commit/895588b82a06c2bc71a9e22fb840c7f6442a3b5b))
18
+ * fix pytorch version to avoid wheel bug ([#1123](https://github.com/imartinez/privateGPT/issues/1123)) ([24cfddd](https://github.com/imartinez/privateGPT/commit/24cfddd60f74aadd2dade4c63f6012a2489938a1))
19
+ * Remove global state ([#1216](https://github.com/imartinez/privateGPT/issues/1216)) ([022bd71](https://github.com/imartinez/privateGPT/commit/022bd718e3dfc197027b1e24fb97e5525b186db4))
20
+ * sagemaker config and chat methods ([#1142](https://github.com/imartinez/privateGPT/issues/1142)) ([a517a58](https://github.com/imartinez/privateGPT/commit/a517a588c4927aa5c5c2a93e4f82a58f0599d251))
21
+ * typo in README.md ([#1091](https://github.com/imartinez/privateGPT/issues/1091)) ([ba23443](https://github.com/imartinez/privateGPT/commit/ba23443a70d323cd4f9a242b33fd9dce1bacd2db))
22
+ * Windows 11 failing to auto-delete tmp file ([#1260](https://github.com/imartinez/privateGPT/issues/1260)) ([0d52002](https://github.com/imartinez/privateGPT/commit/0d520026a3d5b08a9b8487be992d3095b21e710c))
23
+ * Windows permission error on ingest service tmp files ([#1280](https://github.com/imartinez/privateGPT/issues/1280)) ([f1cbff0](https://github.com/imartinez/privateGPT/commit/f1cbff0fb7059432d9e71473cbdd039032dab60d))
24
+
25
+ ## [0.0.2](https://github.com/imartinez/privateGPT/compare/v0.0.1...v0.0.2) (2023-10-20)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * chromadb max batch size ([#1087](https://github.com/imartinez/privateGPT/issues/1087)) ([f5a9bf4](https://github.com/imartinez/privateGPT/commit/f5a9bf4e374b2d4c76438cf8a97cccf222ec8e6f))
31
+
32
+ ## 0.0.1 (2023-10-20)
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * Initial version ([490d93f](https://github.com/imartinez/privateGPT/commit/490d93fdc1977443c92f6c42e57a1c585aa59430))
CITATION.cff ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This CITATION.cff file was generated with cffinit.
2
+ # Visit https://bit.ly/cffinit to generate yours today!
3
+
4
+ cff-version: 1.2.0
5
+ title: PrivateGPT
6
+ message: >-
7
+ If you use this software, please cite it using the
8
+ metadata from this file.
9
+ type: software
10
+ authors:
11
+ - given-names: Iván
12
+ family-names: Martínez Toro
13
14
+ orcid: 'https://orcid.org/0009-0004-5065-2311'
15
+ - family-names: Gallego Vico
16
+ given-names: Daniel
17
18
+ orcid: 'https://orcid.org/0009-0006-8582-4384'
19
+ - given-names: Pablo
20
+ family-names: Orgaz
21
22
+ orcid: 'https://orcid.org/0009-0008-0080-1437'
23
+ repository-code: 'https://github.com/imartinez/privateGPT'
24
+ license: Apache-2.0
25
+ date-released: '2023-05-02'
Dockerfile ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11.6-slim-bookworm as base
2
+
3
+ # Install poetry
4
+ RUN pip install pipx
5
+ RUN python3 -m pipx ensurepath
6
+ RUN pipx install poetry
7
+ ENV PATH="/root/.local/bin:$PATH"
8
+
9
+ # https://python-poetry.org/docs/configuration/#virtualenvsin-project
10
+ ENV POETRY_VIRTUALENVS_IN_PROJECT=true
11
+
12
+ FROM base as dependencies
13
+ WORKDIR /home/worker/app
14
+ COPY pyproject.toml poetry.lock ./
15
+
16
+ # Explicitly copy the project files before running poetry install
17
+ COPY pyproject.toml poetry.lock ./
18
+ RUN poetry config installer.max-workers 10
19
+ RUN poetry install --with ui
20
+
21
+ FROM base as app
22
+
23
+ ENV PYTHONUNBUFFERED=1
24
+ ENV PORT=8080
25
+ EXPOSE 8080
26
+
27
+ # Prepare a non-root user
28
+ RUN adduser --system worker
29
+ WORKDIR /home/worker/app
30
+
31
+ RUN mkdir local_data; chown worker local_data
32
+ RUN mkdir models; chown worker models
33
+
34
+ # Copy only the necessary files for the app
35
+ COPY --chown=worker --from=dependencies /home/worker/app/.venv/ .venv
36
+ COPY --chown=worker private_gpt/ private_gpt
37
+ COPY --chown=worker docs/ docs
38
+ COPY --chown=worker *.yaml *.md ./
39
+
40
+ USER worker
41
+ CMD ["uvicorn", "private_gpt.main:app", "--host", "0.0.0.0", "--port", "7860"]
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
Makefile ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Any args passed to the make script, use with $(call args, default_value)
2
+ args = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
3
+
4
+ ########################################################################################################################
5
+ # Quality checks
6
+ ########################################################################################################################
7
+
8
+ test:
9
+ PYTHONPATH=. poetry run pytest tests
10
+
11
+ test-coverage:
12
+ PYTHONPATH=. poetry run pytest tests --cov private_gpt --cov-report term --cov-report=html --cov-report xml --junit-xml=tests-results.xml
13
+
14
+ black:
15
+ poetry run black . --check
16
+
17
+ ruff:
18
+ poetry run ruff check private_gpt tests
19
+
20
+ format:
21
+ poetry run black .
22
+ poetry run ruff check private_gpt tests --fix
23
+
24
+ mypy:
25
+ poetry run mypy private_gpt
26
+
27
+ check:
28
+ make format
29
+ make mypy
30
+
31
+ ########################################################################################################################
32
+ # Run
33
+ ########################################################################################################################
34
+
35
+ run:
36
+ poetry run python -m private_gpt
37
+
38
+ dev-windows:
39
+ (set PGPT_PROFILES=local & poetry run python -m uvicorn private_gpt.main:app --reload --port 8001)
40
+
41
+ dev:
42
+ PYTHONUNBUFFERED=1 PGPT_PROFILES=local poetry run python -m uvicorn private_gpt.main:app --reload --port 8001
43
+
44
+ ########################################################################################################################
45
+ # Misc
46
+ ########################################################################################################################
47
+
48
+ api-docs:
49
+ PGPT_PROFILES=mock poetry run python scripts/extract_openapi.py private_gpt.main:app --out fern/openapi/openapi.json
50
+
51
+ ingest:
52
+ @poetry run python scripts/ingest_folder.py $(call args)
53
+
54
+ wipe:
55
+ poetry run python scripts/utils.py wipe
docker-compose.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ private-gpt:
3
+ build:
4
+ dockerfile: Dockerfile.local
5
+ volumes:
6
+ - ./local_data/:/home/worker/app/local_data
7
+ - ./models/:/home/worker/app/models
8
+ ports:
9
+ - 8001:8080
10
+ environment:
11
+ PORT: 8080
12
+ PGPT_PROFILES: docker
13
+ PGPT_MODE: local
14
+
poetry.lock ADDED
The diff for this file is too large to render. See raw diff
 
pyproject.toml ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "private-gpt"
3
+ version = "0.1.0"
4
+ description = "Private GPT"
5
+ authors = ["Zylon <[email protected]>"]
6
+
7
+ [tool.poetry.dependencies]
8
+ python = ">=3.11,<3.12"
9
+ fastapi = { extras = ["all"], version = "^0.103.1" }
10
+ boto3 = "^1.28.56"
11
+ injector = "^0.21.0"
12
+ pyyaml = "^6.0.1"
13
+ python-multipart = "^0.0.6"
14
+ pypdf = "^3.16.2"
15
+ llama-index = { extras = ["local_models"], version = "0.9.3" }
16
+ watchdog = "^3.0.0"
17
+ qdrant-client = "^1.6.9"
18
+ chromadb = {version = "^0.4.13", optional = true}
19
+
20
+ [tool.poetry.group.dev.dependencies]
21
+ black = "^22"
22
+ mypy = "^1.2"
23
+ pre-commit = "^2"
24
+ pytest = "^7"
25
+ pytest-cov = "^3"
26
+ ruff = "^0"
27
+ pytest-asyncio = "^0.21.1"
28
+ types-pyyaml = "^6.0.12.12"
29
+
30
+ # Dependencies for gradio UI
31
+ [tool.poetry.group.ui]
32
+ optional = true
33
+ [tool.poetry.group.ui.dependencies]
34
+ gradio = "^4.4.1"
35
+
36
+ [tool.poetry.group.local]
37
+ optional = true
38
+ [tool.poetry.group.local.dependencies]
39
+ llama-cpp-python = "^0.2.11"
40
+ numpy = "1.26.0"
41
+ sentence-transformers = "^2.2.2"
42
+ # https://stackoverflow.com/questions/76327419/valueerror-libcublas-so-0-9-not-found-in-the-system-path
43
+ torch = ">=2.0.0, !=2.0.1, !=2.1.0"
44
+ transformers = "^4.34.0"
45
+
46
+ [tool.poetry.extras]
47
+ chroma = ["chromadb"]
48
+
49
+ [build-system]
50
+ requires = ["poetry-core>=1.0.0"]
51
+ build-backend = "poetry.core.masonry.api"
52
+
53
+ # Packages configs
54
+
55
+ ## coverage
56
+
57
+ [tool.coverage.run]
58
+ branch = true
59
+
60
+ [tool.coverage.report]
61
+ skip_empty = true
62
+ precision = 2
63
+
64
+ ## black
65
+
66
+ [tool.black]
67
+ target-version = ['py311']
68
+
69
+ ## ruff
70
+ # Recommended ruff config for now, to be updated as we go along.
71
+ [tool.ruff]
72
+ target-version = 'py311'
73
+
74
+ # See all rules at https://beta.ruff.rs/docs/rules/
75
+ select = [
76
+ "E", # pycodestyle
77
+ "W", # pycodestyle
78
+ "F", # Pyflakes
79
+ "B", # flake8-bugbear
80
+ "C4", # flake8-comprehensions
81
+ "D", # pydocstyle
82
+ "I", # isort
83
+ "SIM", # flake8-simplify
84
+ "TCH", # flake8-type-checking
85
+ "TID", # flake8-tidy-imports
86
+ "Q", # flake8-quotes
87
+ "UP", # pyupgrade
88
+ "PT", # flake8-pytest-style
89
+ "RUF", # Ruff-specific rules
90
+ ]
91
+
92
+ ignore = [
93
+ "E501", # "Line too long"
94
+ # -> line length already regulated by black
95
+ "PT011", # "pytest.raises() should specify expected exception"
96
+ # -> would imply to update tests every time you update exception message
97
+ "SIM102", # "Use a single `if` statement instead of nested `if` statements"
98
+ # -> too restrictive,
99
+ "D100",
100
+ "D101",
101
+ "D102",
102
+ "D103",
103
+ "D104",
104
+ "D105",
105
+ "D106",
106
+ "D107"
107
+ # -> "Missing docstring in public function too restrictive"
108
+ ]
109
+
110
+ [tool.ruff.pydocstyle]
111
+ # Automatically disable rules that are incompatible with Google docstring convention
112
+ convention = "google"
113
+
114
+ [tool.ruff.pycodestyle]
115
+ max-doc-length = 88
116
+
117
+ [tool.ruff.flake8-tidy-imports]
118
+ ban-relative-imports = "all"
119
+
120
+ [tool.ruff.flake8-type-checking]
121
+ strict = true
122
+ runtime-evaluated-base-classes = ["pydantic.BaseModel"]
123
+ # Pydantic needs to be able to evaluate types at runtime
124
+ # see https://pypi.org/project/flake8-type-checking/ for flake8-type-checking documentation
125
+ # see https://beta.ruff.rs/docs/settings/#flake8-type-checking-runtime-evaluated-base-classes for ruff documentation
126
+
127
+ [tool.ruff.per-file-ignores]
128
+ # Allow missing docstrings for tests
129
+ "tests/**/*.py" = ["D1"]
130
+
131
+ ## mypy
132
+
133
+ [tool.mypy]
134
+ python_version = "3.11"
135
+ strict = true
136
+ check_untyped_defs = false
137
+ explicit_package_bases = true
138
+ warn_unused_ignores = false
139
+ exclude = ["tests"]
140
+
141
+ [tool.pytest.ini_options]
142
+ asyncio_mode = "auto"
143
+ testpaths = ["tests"]
144
+ addopts = [
145
+ "--import-mode=importlib",
146
+ ]
settings-docker.yaml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server:
2
+ env_name: ${APP_ENV:prod}
3
+ port: ${PORT:8080}
4
+
5
+ llm:
6
+ mode: ${PGPT_MODE:mock}
7
+
8
+ local:
9
+ llm_hf_repo_id: ${PGPT_HF_REPO_ID:TheBloke/Mistral-7B-Instruct-v0.1-GGUF}
10
+ llm_hf_model_file: ${PGPT_HF_MODEL_FILE:mistral-7b-instruct-v0.1.Q4_K_M.gguf}
11
+ embedding_hf_model_name: ${PGPT_EMBEDDING_HF_MODEL_NAME:BAAI/bge-small-en-v1.5}
12
+
13
+ sagemaker:
14
+ llm_endpoint_name: ${PGPT_SAGEMAKER_LLM_ENDPOINT_NAME:}
15
+ embedding_endpoint_name: ${PGPT_SAGEMAKER_EMBEDDING_ENDPOINT_NAME:}
16
+
17
+ ui:
18
+ enabled: true
19
+ path: /
settings-local.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ server:
2
+ env_name: ${APP_ENV:local}
3
+
4
+ llm:
5
+ mode: local
settings-mock.yaml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ server:
2
+ env_name: ${APP_ENV:mock}
3
+
4
+ # This configuration allows you to use GPU for creating embeddings while avoiding loading LLM into vRAM
5
+ llm:
6
+ mode: mock
7
+ embedding:
8
+ mode: local
settings-sagemaker.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server:
2
+ env_name: ${APP_ENV:prod}
3
+ port: ${PORT:8001}
4
+
5
+ ui:
6
+ enabled: true
7
+ path: /
8
+
9
+ llm:
10
+ mode: sagemaker
11
+
12
+ sagemaker:
13
+ llm_endpoint_name: huggingface-pytorch-tgi-inference-2023-09-25-19-53-32-140
14
+ embedding_endpoint_name: huggingface-pytorch-inference-2023-11-03-07-41-36-479
settings-test.yaml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server:
2
+ env_name: test
3
+ auth:
4
+ enabled: false
5
+ # Dummy secrets used for tests
6
+ secret: "foo bar; dummy secret"
7
+
8
+ data:
9
+ local_data_folder: local_data/tests
10
+
11
+ qdrant:
12
+ path: local_data/tests
13
+
14
+ llm:
15
+ mode: mock
16
+
17
+ ui:
18
+ enabled: false
settings.yaml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The default configuration file.
2
+ # More information about configuration can be found in the documentation: https://docs.privategpt.dev/
3
+ # Syntax in `private_pgt/settings/settings.py`
4
+ server:
5
+ env_name: ${APP_ENV:prod}
6
+ port: ${PORT:8001}
7
+ cors:
8
+ enabled: false
9
+ allow_origins: ["*"]
10
+ allow_methods: ["*"]
11
+ allow_headers: ["*"]
12
+ auth:
13
+ enabled: false
14
+ # python -c 'import base64; print("Basic " + base64.b64encode("secret:key".encode()).decode())'
15
+ # 'secret' is the username and 'key' is the password for basic auth by default
16
+ # If the auth is enabled, this value must be set in the "Authorization" header of the request.
17
+ secret: "Basic c2VjcmV0OmtleQ=="
18
+
19
+ data:
20
+ local_data_folder: local_data/private_gpt
21
+
22
+ ui:
23
+ enabled: false
24
+ path: /
25
+
26
+ llm:
27
+ mode: openai
28
+
29
+ embedding:
30
+ # Should be matching the value above in most cases
31
+ mode: openai
32
+ ingest_mode: simple
33
+
34
+ vectorstore:
35
+ database: qdrant
36
+
37
+ qdrant:
38
+ path: local_data/private_gpt/qdrant
39
+
40
+ local:
41
+ prompt_style: "llama2"
42
+ llm_hf_repo_id: TheBloke/Mistral-7B-Instruct-v0.1-GGUF
43
+ llm_hf_model_file: mistral-7b-instruct-v0.1.Q4_K_M.gguf
44
+ embedding_hf_model_name: BAAI/bge-small-en-v1.5
45
+
46
+ sagemaker:
47
+ llm_endpoint_name: huggingface-pytorch-tgi-inference-2023-09-25-19-53-32-140
48
+ embedding_endpoint_name: huggingface-pytorch-inference-2023-11-03-07-41-36-479
49
+
50
+ openai:
51
+ api_key: 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
version.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 0.1.0