hysts HF staff commited on
Commit
20ba797
1 Parent(s): 825bc54
.pre-commit-config.yaml CHANGED
@@ -18,13 +18,15 @@ repos:
18
  hooks:
19
  - id: docformatter
20
  args: ["--in-place"]
21
- - repo: https://github.com/pycqa/isort
22
- rev: 5.13.2
23
  hooks:
24
- - id: isort
25
- args: ["--profile", "black"]
 
 
26
  - repo: https://github.com/pre-commit/mirrors-mypy
27
- rev: v1.12.0
28
  hooks:
29
  - id: mypy
30
  args: ["--ignore-missing-imports"]
@@ -35,18 +37,8 @@ repos:
35
  "types-PyYAML",
36
  "types-pytz",
37
  ]
38
- - repo: https://github.com/psf/black
39
- rev: 24.10.0
40
- hooks:
41
- - id: black
42
- language_version: python3.10
43
- args: ["--line-length", "119"]
44
- - repo: https://github.com/charliermarsh/ruff-pre-commit
45
- rev: v0.7.0
46
- hooks:
47
- - id: ruff
48
  - repo: https://github.com/kynan/nbstripout
49
- rev: 0.7.1
50
  hooks:
51
  - id: nbstripout
52
  args:
@@ -55,7 +47,7 @@ repos:
55
  "metadata.interpreter metadata.kernelspec cell.metadata.pycharm",
56
  ]
57
  - repo: https://github.com/nbQA-dev/nbQA
58
- rev: 1.8.7
59
  hooks:
60
  - id: nbqa-black
61
  - id: nbqa-pyupgrade
 
18
  hooks:
19
  - id: docformatter
20
  args: ["--in-place"]
21
+ - repo: https://github.com/astral-sh/ruff-pre-commit
22
+ rev: v0.8.4
23
  hooks:
24
+ - id: ruff
25
+ args: ["--fix"]
26
+ - id: ruff-format
27
+ args: ["--line-length", "119"]
28
  - repo: https://github.com/pre-commit/mirrors-mypy
29
+ rev: v1.14.0
30
  hooks:
31
  - id: mypy
32
  args: ["--ignore-missing-imports"]
 
37
  "types-PyYAML",
38
  "types-pytz",
39
  ]
 
 
 
 
 
 
 
 
 
 
40
  - repo: https://github.com/kynan/nbstripout
41
+ rev: 0.8.1
42
  hooks:
43
  - id: nbstripout
44
  args:
 
47
  "metadata.interpreter metadata.kernelspec cell.metadata.pycharm",
48
  ]
49
  - repo: https://github.com/nbQA-dev/nbQA
50
+ rev: 1.9.1
51
  hooks:
52
  - id: nbqa-black
53
  - id: nbqa-pyupgrade
.vscode/extensions.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recommendations": [
3
+ "ms-python.python",
4
+ "charliermarsh.ruff",
5
+ "streetsidesoftware.code-spell-checker",
6
+ "tamasfe.even-better-toml"
7
+ ]
8
+ }
.vscode/settings.json CHANGED
@@ -2,29 +2,20 @@
2
  "editor.formatOnSave": true,
3
  "files.insertFinalNewline": false,
4
  "[python]": {
5
- "editor.defaultFormatter": "ms-python.black-formatter",
6
  "editor.formatOnType": true,
7
  "editor.codeActionsOnSave": {
 
8
  "source.organizeImports": "explicit"
9
  }
10
  },
11
  "[jupyter]": {
12
  "files.insertFinalNewline": false
13
  },
14
- "black-formatter.args": [
15
- "--line-length=119"
16
- ],
17
- "isort.args": ["--profile", "black"],
18
- "flake8.args": [
19
- "--max-line-length=119"
20
- ],
21
- "ruff.lint.args": [
22
- "--line-length=119"
23
- ],
24
  "notebook.output.scrolling": true,
25
  "notebook.formatOnCellExecution": true,
26
  "notebook.formatOnSave.enabled": true,
27
- "notebook.codeActionsOnSave": {
28
- "source.organizeImports": "explicit"
29
- }
30
  }
 
2
  "editor.formatOnSave": true,
3
  "files.insertFinalNewline": false,
4
  "[python]": {
5
+ "editor.defaultFormatter": "charliermarsh.ruff",
6
  "editor.formatOnType": true,
7
  "editor.codeActionsOnSave": {
8
+ "source.fixAll.ruff": "explicit",
9
  "source.organizeImports": "explicit"
10
  }
11
  },
12
  "[jupyter]": {
13
  "files.insertFinalNewline": false
14
  },
 
 
 
 
 
 
 
 
 
 
15
  "notebook.output.scrolling": true,
16
  "notebook.formatOnCellExecution": true,
17
  "notebook.formatOnSave.enabled": true,
18
+ "notebook.codeActionsOnSave": {
19
+ "source.organizeImports": "explicit"
20
+ }
21
  }
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 😻
4
  colorFrom: indigo
5
  colorTo: pink
6
  sdk: gradio
7
- sdk_version: 5.8.0
8
  app_file: app.py
9
  pinned: false
10
  short_description: Chatbot
 
4
  colorFrom: indigo
5
  colorTo: pink
6
  sdk: gradio
7
+ sdk_version: 5.9.1
8
  app_file: app.py
9
  pinned: false
10
  short_description: Chatbot
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
 
2
  from threading import Thread
3
- from typing import Iterator
4
 
5
  import gradio as gr
6
  import spaces
@@ -42,7 +42,7 @@ def generate(
42
  top_k: int = 50,
43
  repetition_penalty: float = 1.2,
44
  ) -> Iterator[str]:
45
- conversation = chat_history + [{"role": "user", "content": message}]
46
 
47
  input_ids = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, return_tensors="pt")
48
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
 
1
  import os
2
+ from collections.abc import Iterator
3
  from threading import Thread
 
4
 
5
  import gradio as gr
6
  import spaces
 
42
  top_k: int = 50,
43
  repetition_penalty: float = 1.2,
44
  ) -> Iterator[str]:
45
+ conversation = [*chat_history, {"role": "user", "content": message}]
46
 
47
  input_ids = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, return_tensors="pt")
48
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
pyproject.toml CHANGED
@@ -5,10 +5,43 @@ description = ""
5
  readme = "README.md"
6
  requires-python = ">=3.10"
7
  dependencies = [
8
- "accelerate>=1.2.0",
9
- "gradio>=5.8.0",
10
  "hf-transfer>=0.1.8",
11
- "spaces>=0.30.4",
12
  "torch==2.4.0",
13
- "transformers>=4.47.0",
14
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  readme = "README.md"
6
  requires-python = ">=3.10"
7
  dependencies = [
8
+ "accelerate>=1.2.1",
9
+ "gradio>=5.9.1",
10
  "hf-transfer>=0.1.8",
11
+ "spaces>=0.31.1",
12
  "torch==2.4.0",
13
+ "transformers>=4.47.1",
14
  ]
15
+
16
+ [tool.ruff]
17
+ line-length = 119
18
+
19
+ [tool.ruff.lint]
20
+ select = ["ALL"]
21
+ ignore = [
22
+ "COM812", # missing-trailing-comma
23
+ "D203", # one-blank-line-before-class
24
+ "D213", # multi-line-summary-second-line
25
+ "E501", # line-too-long
26
+ "SIM117", # multiple-with-statements
27
+ ]
28
+ extend-ignore = [
29
+ "D100", # undocumented-public-module
30
+ "D101", # undocumented-public-class
31
+ "D102", # undocumented-public-method
32
+ "D103", # undocumented-public-function
33
+ "EM101", # raw-string-in-exception
34
+ "FBT001", # boolean-type-hint-positional-argument
35
+ "FBT002", # boolean-default-value-positional-argument
36
+ "PD901", # pandas-df-variable-name
37
+ "PGH003", # blanket-type-ignore
38
+ "PLR0913", # too-many-arguments
39
+ "PLR0915", # too-many-statements
40
+ "TRY003", # raise-vanilla-args
41
+ ]
42
+ unfixable = [
43
+ "F401", # unused-import
44
+ ]
45
+
46
+ [tool.ruff.format]
47
+ docstring-code-format = true
requirements.txt CHANGED
@@ -1,32 +1,32 @@
1
  # This file was autogenerated by uv via the following command:
2
  # uv pip compile pyproject.toml -o requirements.txt
3
- accelerate==1.2.0
4
  # via gemma-2-2b-jpn-it (pyproject.toml)
5
  aiofiles==23.2.1
6
  # via gradio
7
  annotated-types==0.7.0
8
  # via pydantic
9
- anyio==4.6.0
10
  # via
11
  # gradio
12
  # httpx
13
  # starlette
14
- certifi==2024.8.30
15
  # via
16
  # httpcore
17
  # httpx
18
  # requests
19
- charset-normalizer==3.3.2
20
  # via requests
21
- click==8.1.7
22
  # via
23
  # typer
24
  # uvicorn
25
  exceptiongroup==1.2.2
26
  # via anyio
27
- fastapi==0.115.4
28
  # via gradio
29
- ffmpy==0.4.0
30
  # via gradio
31
  filelock==3.16.1
32
  # via
@@ -34,16 +34,16 @@ filelock==3.16.1
34
  # torch
35
  # transformers
36
  # triton
37
- fsspec==2024.9.0
38
  # via
39
  # gradio-client
40
  # huggingface-hub
41
  # torch
42
- gradio==5.8.0
43
  # via
44
  # gemma-2-2b-jpn-it (pyproject.toml)
45
  # spaces
46
- gradio-client==1.5.1
47
  # via gradio
48
  h11==0.14.0
49
  # via
@@ -51,15 +51,15 @@ h11==0.14.0
51
  # uvicorn
52
  hf-transfer==0.1.8
53
  # via gemma-2-2b-jpn-it (pyproject.toml)
54
- httpcore==1.0.6
55
  # via httpx
56
- httpx==0.27.2
57
  # via
58
  # gradio
59
  # gradio-client
60
  # safehttpx
61
  # spaces
62
- huggingface-hub==0.25.1
63
  # via
64
  # accelerate
65
  # gradio
@@ -71,7 +71,7 @@ idna==3.10
71
  # anyio
72
  # httpx
73
  # requests
74
- jinja2==3.1.4
75
  # via
76
  # gradio
77
  # torch
@@ -85,9 +85,9 @@ mdurl==0.1.2
85
  # via markdown-it-py
86
  mpmath==1.3.0
87
  # via sympy
88
- networkx==3.3
89
  # via torch
90
- numpy==2.1.1
91
  # via
92
  # accelerate
93
  # gradio
@@ -118,15 +118,15 @@ nvidia-cusparse-cu12==12.1.0.106
118
  # torch
119
  nvidia-nccl-cu12==2.20.5
120
  # via torch
121
- nvidia-nvjitlink-cu12==12.6.77
122
  # via
123
  # nvidia-cusolver-cu12
124
  # nvidia-cusparse-cu12
125
  nvidia-nvtx-cu12==12.1.105
126
  # via torch
127
- orjson==3.10.7
128
  # via gradio
129
- packaging==24.1
130
  # via
131
  # accelerate
132
  # gradio
@@ -136,18 +136,18 @@ packaging==24.1
136
  # transformers
137
  pandas==2.2.3
138
  # via gradio
139
- pillow==10.4.0
140
  # via gradio
141
  psutil==5.9.8
142
  # via
143
  # accelerate
144
  # spaces
145
- pydantic==2.9.2
146
  # via
147
  # fastapi
148
  # gradio
149
  # spaces
150
- pydantic-core==2.23.4
151
  # via pydantic
152
  pydub==0.25.1
153
  # via gradio
@@ -155,7 +155,7 @@ pygments==2.18.0
155
  # via rich
156
  python-dateutil==2.9.0.post0
157
  # via pandas
158
- python-multipart==0.0.19
159
  # via gradio
160
  pytz==2024.2
161
  # via pandas
@@ -165,16 +165,16 @@ pyyaml==6.0.2
165
  # gradio
166
  # huggingface-hub
167
  # transformers
168
- regex==2024.9.11
169
  # via transformers
170
  requests==2.32.3
171
  # via
172
  # huggingface-hub
173
  # spaces
174
  # transformers
175
- rich==13.9.1
176
  # via typer
177
- ruff==0.6.8
178
  # via gradio
179
  safehttpx==0.1.6
180
  # via gradio
@@ -186,15 +186,13 @@ semantic-version==2.10.0
186
  # via gradio
187
  shellingham==1.5.4
188
  # via typer
189
- six==1.16.0
190
  # via python-dateutil
191
  sniffio==1.3.1
192
- # via
193
- # anyio
194
- # httpx
195
- spaces==0.30.4
196
  # via gemma-2-2b-jpn-it (pyproject.toml)
197
- starlette==0.41.2
198
  # via
199
  # fastapi
200
  # gradio
@@ -202,21 +200,21 @@ sympy==1.13.3
202
  # via torch
203
  tokenizers==0.21.0
204
  # via transformers
205
- tomlkit==0.12.0
206
  # via gradio
207
  torch==2.4.0
208
  # via
209
  # gemma-2-2b-jpn-it (pyproject.toml)
210
  # accelerate
211
- tqdm==4.66.5
212
  # via
213
  # huggingface-hub
214
  # transformers
215
- transformers==4.47.0
216
  # via gemma-2-2b-jpn-it (pyproject.toml)
217
  triton==3.0.0
218
  # via torch
219
- typer==0.12.5
220
  # via gradio
221
  typing-extensions==4.12.2
222
  # via
@@ -234,9 +232,9 @@ typing-extensions==4.12.2
234
  # uvicorn
235
  tzdata==2024.2
236
  # via pandas
237
- urllib3==2.2.3
238
  # via requests
239
- uvicorn==0.31.0
240
  # via gradio
241
- websockets==12.0
242
  # via gradio-client
 
1
  # This file was autogenerated by uv via the following command:
2
  # uv pip compile pyproject.toml -o requirements.txt
3
+ accelerate==1.2.1
4
  # via gemma-2-2b-jpn-it (pyproject.toml)
5
  aiofiles==23.2.1
6
  # via gradio
7
  annotated-types==0.7.0
8
  # via pydantic
9
+ anyio==4.7.0
10
  # via
11
  # gradio
12
  # httpx
13
  # starlette
14
+ certifi==2024.12.14
15
  # via
16
  # httpcore
17
  # httpx
18
  # requests
19
+ charset-normalizer==3.4.1
20
  # via requests
21
+ click==8.1.8
22
  # via
23
  # typer
24
  # uvicorn
25
  exceptiongroup==1.2.2
26
  # via anyio
27
+ fastapi==0.115.6
28
  # via gradio
29
+ ffmpy==0.5.0
30
  # via gradio
31
  filelock==3.16.1
32
  # via
 
34
  # torch
35
  # transformers
36
  # triton
37
+ fsspec==2024.12.0
38
  # via
39
  # gradio-client
40
  # huggingface-hub
41
  # torch
42
+ gradio==5.9.1
43
  # via
44
  # gemma-2-2b-jpn-it (pyproject.toml)
45
  # spaces
46
+ gradio-client==1.5.2
47
  # via gradio
48
  h11==0.14.0
49
  # via
 
51
  # uvicorn
52
  hf-transfer==0.1.8
53
  # via gemma-2-2b-jpn-it (pyproject.toml)
54
+ httpcore==1.0.7
55
  # via httpx
56
+ httpx==0.28.1
57
  # via
58
  # gradio
59
  # gradio-client
60
  # safehttpx
61
  # spaces
62
+ huggingface-hub==0.27.0
63
  # via
64
  # accelerate
65
  # gradio
 
71
  # anyio
72
  # httpx
73
  # requests
74
+ jinja2==3.1.5
75
  # via
76
  # gradio
77
  # torch
 
85
  # via markdown-it-py
86
  mpmath==1.3.0
87
  # via sympy
88
+ networkx==3.4.2
89
  # via torch
90
+ numpy==2.2.1
91
  # via
92
  # accelerate
93
  # gradio
 
118
  # torch
119
  nvidia-nccl-cu12==2.20.5
120
  # via torch
121
+ nvidia-nvjitlink-cu12==12.6.85
122
  # via
123
  # nvidia-cusolver-cu12
124
  # nvidia-cusparse-cu12
125
  nvidia-nvtx-cu12==12.1.105
126
  # via torch
127
+ orjson==3.10.13
128
  # via gradio
129
+ packaging==24.2
130
  # via
131
  # accelerate
132
  # gradio
 
136
  # transformers
137
  pandas==2.2.3
138
  # via gradio
139
+ pillow==11.0.0
140
  # via gradio
141
  psutil==5.9.8
142
  # via
143
  # accelerate
144
  # spaces
145
+ pydantic==2.10.4
146
  # via
147
  # fastapi
148
  # gradio
149
  # spaces
150
+ pydantic-core==2.27.2
151
  # via pydantic
152
  pydub==0.25.1
153
  # via gradio
 
155
  # via rich
156
  python-dateutil==2.9.0.post0
157
  # via pandas
158
+ python-multipart==0.0.20
159
  # via gradio
160
  pytz==2024.2
161
  # via pandas
 
165
  # gradio
166
  # huggingface-hub
167
  # transformers
168
+ regex==2024.11.6
169
  # via transformers
170
  requests==2.32.3
171
  # via
172
  # huggingface-hub
173
  # spaces
174
  # transformers
175
+ rich==13.9.4
176
  # via typer
177
+ ruff==0.8.4
178
  # via gradio
179
  safehttpx==0.1.6
180
  # via gradio
 
186
  # via gradio
187
  shellingham==1.5.4
188
  # via typer
189
+ six==1.17.0
190
  # via python-dateutil
191
  sniffio==1.3.1
192
+ # via anyio
193
+ spaces==0.31.1
 
 
194
  # via gemma-2-2b-jpn-it (pyproject.toml)
195
+ starlette==0.41.3
196
  # via
197
  # fastapi
198
  # gradio
 
200
  # via torch
201
  tokenizers==0.21.0
202
  # via transformers
203
+ tomlkit==0.13.2
204
  # via gradio
205
  torch==2.4.0
206
  # via
207
  # gemma-2-2b-jpn-it (pyproject.toml)
208
  # accelerate
209
+ tqdm==4.67.1
210
  # via
211
  # huggingface-hub
212
  # transformers
213
+ transformers==4.47.1
214
  # via gemma-2-2b-jpn-it (pyproject.toml)
215
  triton==3.0.0
216
  # via torch
217
+ typer==0.15.1
218
  # via gradio
219
  typing-extensions==4.12.2
220
  # via
 
232
  # uvicorn
233
  tzdata==2024.2
234
  # via pandas
235
+ urllib3==2.3.0
236
  # via requests
237
+ uvicorn==0.34.0
238
  # via gradio
239
+ websockets==14.1
240
  # via gradio-client
uv.lock CHANGED
The diff for this file is too large to render. See raw diff