-
Notifications
You must be signed in to change notification settings - Fork 17
/
pyproject.toml
277 lines (243 loc) · 6.87 KB
/
pyproject.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
requires-python = ">=3.8"
name = "libre-chat"
description = "Free and Open Source Large Language Model (LLM) chatbot web UI and API. Self-hosted, offline capable and easy to setup. Powered by LangChain and Llama 2."
readme = "README.md"
license = { file = "LICENSE.txt" }
authors = [
{ name = "Vincent Emonet", email = "[email protected]" },
]
maintainers = [
{ name = "Vincent Emonet", email = "[email protected]" },
]
keywords = [
"Python",
]
classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dynamic = ["version"]
dependencies = [
"gradio >=4.0.0",
"langchain",
"langchain-community",
"llama-cpp-python", # To perform LLM inference
"qdrant-client", # Vectorstore
# "fastembed",
"faiss-cpu >=1.7.4", # To generate the vectorstore
"sentence_transformers", # To produce the embeddings
"pypdf", # For PDFloader, or use PDFMiner?
"unstructured", # For the email loader
"typer >=0.6.0",
"fastapi",
"pydantic >=2.0.0",
"pydantic-settings",
"pydantic-yaml",
"requests",
"tqdm",
"uvicorn",
"gunicorn",
# "redis", # To add a shared store for all workers
]
[project.scripts]
libre-chat = "libre_chat.__main__:cli"
[project.optional-dependencies]
test = [
"pytest >=7.4.0",
"pytest-cov >=3.0.0",
"pytest-asyncio",
"pre-commit",
"mypy >=1.4.1",
"httpx",
"pip-tools",
"types-requests",
"types-setuptools",
# "types-redis",
]
doc = [
"mkdocs >=1.4.2",
"mkdocs-material >=8.2.7",
"mkdocstrings[python] >=0.19.1",
"mdx-include >=1.4.1",
"mkdocs-markdownextradata-plugin >=0.2.5", # ,<0.3.0
"mkdocs-open-in-new-tab",
]
windows = [
"python-magic-bin" # Required by magic, used by unstructured for the EmailLoader https://pydigger.com/pypi/python-magic
]
gpu = [
"faiss-gpu",
# "ctransformers[cuda]",
]
[project.urls]
Homepage = "https://github.com/vemonet/libre-chat"
Documentation = "https://github.com/vemonet/libre-chat"
History = "https://github.com/vemonet/libre-chat/releases"
Tracker = "https://github.com/vemonet/libre-chat/issues"
Source = "https://github.com/vemonet/libre-chat"
# ENVIRONMENTS AND SCRIPTS
[tool.hatch.envs.default]
features = [
"test",
"doc",
]
post-install-commands = [
"pre-commit install",
]
[tool.hatch.envs.default.scripts]
dev = "uvicorn scripts.main:app {args}"
vector = [
"libre-chat start config/chat-vectorstore-qa.yml",
]
vector-build = [
"rm -rf vectorstore/db_faiss",
"vector",
]
fmt = [
"pre-commit run --all --all-files",
"mypy",
]
test = [
"fmt",
"pytest {args}",
]
cov = [
"fmt",
"pytest --cov-report html {args}",
"cov-start",
]
cov-start = "python -m http.server 3000 --directory ./htmlcov"
docs = "mkdocs serve -a localhost:8001 -f docs/mkdocs.yml"
requirements = "pip-compile -o scripts/requirements.txt pyproject.toml"
release = [
"hatch build",
"hatch publish",
"gh release create",
]
[[tool.hatch.envs.all.matrix]]
python = ["3.8", "3.9", "3.10", "3.11"]
## TOOLS
[tool.hatch.build.targets.wheel]
packages = ["src/libre_chat"]
[tool.hatch.version]
path = "src/libre_chat/__init__.py"
[tool.hatch.build.targets.sdist]
exclude = [
"/.github",
"/documents",
]
# https://coverage.readthedocs.io/en/7.2.2/config.html
[tool.coverage.run]
branch = true
parallel = true # Append process id to the data file name
source = [ "src/libre_chat" ]
[tool.coverage.paths]
libre_chat = ["src/libre_chat", "*/src/libre_chat", "*\\src\\libre_chat"]
[tool.coverage.report]
omit = ["tests/*", "src/libre_chat/ui.py"]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
show_missing = true
# fail_under = 85 skip_covered = true
[tool.mypy]
files = ["src/"]
strict = true
implicit_reexport = true
follow_imports = "normal"
ignore_missing_imports = true
pretty = true
show_column_numbers = true
warn_no_return = true
warn_unused_ignores = true
warn_redundant_casts = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_any_generics = true
no_implicit_optional = true
[tool.pytest.ini_options]
addopts = [
"-vvv", # Verbose level 3
"--durations=10", # Show 10 slowest tests durations
"--cov=src",
"--color=yes",
"--cov-report=term-missing",
"--cov-fail-under=85",
# "-n", "4", # should run in parallel on 4 processes, requires pytest-xdist
]
filterwarnings = [
# "ignore::DeprecationWarning", # Ignore all deprecation warnings
"ignore::DeprecationWarning:httpx.*:",
"ignore::DeprecationWarning:setuptools.*:",
"ignore::DeprecationWarning:gradio.*:",
"ignore::DeprecationWarning:distutils.*",
"ignore::DeprecationWarning:pkg_resources.*",
"ignore::DeprecationWarning:faiss.*:",
"ignore::DeprecationWarning:altair.*:",
]
[tool.black]
color = true
line-length = 100
target-version = ['py38']
skip-string-normalization = false
# https://github.com/charliermarsh/ruff#supported-rules
[tool.ruff]
src = ["src", "tests", "scripts"]
target-version = "py38"
line-length = 120
select = [
"I", # isort
"N", # pep8-naming
"S", # bandit
"A", # flake8-builtins
"YTT", # flake8-2020
"B", # flake8-bugbear
"C", # flake8-comprehensions
"ICN", # flake8-import-conventions
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"Q", # flake8-quotes
# "FBT", # flake8-boolean-trap
"F", # pyflakes
"UP", # pyupgrade
"E", # pycodestyle errors
"W", # pycodestyle warnings
"PLC", # pylint convention
"PLE", # pylint error
# "PLR", # pylint refactor Magic value used in comparison, consider replacing 400 with a constant variable
"PLW", # pylint warning
"RUF", # ruff specific
"T",
]
ignore = [
"B007", # Loop control variable `x` not used within loop body
"E501", # line too long
"C901", # too complex
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"T201", # do not use print
"B008", # do not perform function calls in argument defaults
]
[tool.ruff.per-file-ignores]
"__init__.py" = ["I", "F401"] # module imported but unused
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "S105", "TID252"]
[tool.ruff.mccabe]
max-complexity = 10
[tool.ruff.isort]
known-third-party = ["langchain"]
# If you need to import packages from git URLs
# [tool.hatch.metadata]
# allow-direct-references = true
# [tool.hatch.build]
# sources = ["src/libre_chat"]