hayas commited on
Commit
20a05ed
1 Parent(s): 1e56efd
.pre-commit-config.yaml CHANGED
@@ -1,6 +1,6 @@
1
  repos:
2
  - repo: https://github.com/pre-commit/pre-commit-hooks
3
- rev: v4.6.0
4
  hooks:
5
  - id: check-executables-have-shebangs
6
  - id: check-json
@@ -13,18 +13,15 @@ repos:
13
  args: ["--fix=lf"]
14
  - id: requirements-txt-fixer
15
  - id: trailing-whitespace
16
- - repo: https://github.com/myint/docformatter
17
- rev: v1.7.5
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.9.0
28
  hooks:
29
  - id: mypy
30
  args: ["--ignore-missing-imports"]
@@ -35,14 +32,8 @@ repos:
35
  "types-PyYAML",
36
  "types-pytz",
37
  ]
38
- - repo: https://github.com/psf/black
39
- rev: 24.4.0
40
- hooks:
41
- - id: black
42
- language_version: python3.10
43
- args: ["--line-length", "119"]
44
  - repo: https://github.com/kynan/nbstripout
45
- rev: 0.7.1
46
  hooks:
47
  - id: nbstripout
48
  args:
@@ -51,7 +42,7 @@ repos:
51
  "metadata.interpreter metadata.kernelspec cell.metadata.pycharm",
52
  ]
53
  - repo: https://github.com/nbQA-dev/nbQA
54
- rev: 1.8.5
55
  hooks:
56
  - id: nbqa-black
57
  - id: nbqa-pyupgrade
 
1
  repos:
2
  - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
  hooks:
5
  - id: check-executables-have-shebangs
6
  - id: check-json
 
13
  args: ["--fix=lf"]
14
  - id: requirements-txt-fixer
15
  - id: trailing-whitespace
16
+ - repo: https://github.com/astral-sh/ruff-pre-commit
17
+ rev: v0.8.4
18
  hooks:
19
+ - id: ruff
20
+ args: ["--fix"]
21
+ - id: ruff-format
22
+ args: ["--line-length", "119"]
 
 
 
23
  - repo: https://github.com/pre-commit/mirrors-mypy
24
+ rev: v1.14.0
25
  hooks:
26
  - id: mypy
27
  args: ["--ignore-missing-imports"]
 
32
  "types-PyYAML",
33
  "types-pytz",
34
  ]
 
 
 
 
 
 
35
  - repo: https://github.com/kynan/nbstripout
36
+ rev: 0.8.1
37
  hooks:
38
  - id: nbstripout
39
  args:
 
42
  "metadata.interpreter metadata.kernelspec cell.metadata.pycharm",
43
  ]
44
  - repo: https://github.com/nbQA-dev/nbQA
45
+ rev: 1.9.1
46
  hooks:
47
  - id: nbqa-black
48
  - 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,25 +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
  }
 
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: red
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 5.1.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
 
4
  colorFrom: red
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 5.9.1
8
  app_file: app.py
9
  pinned: false
10
  license: mit
app.py CHANGED
@@ -1,8 +1,8 @@
1
  #!/usr/bin/env python
2
 
3
  import os
 
4
  from threading import Thread
5
- from typing import Iterator
6
 
7
  import gradio as gr
8
  import spaces
@@ -27,8 +27,7 @@ if torch.cuda.is_available():
27
 
28
  def apply_chat_template(conversation: list[dict[str, str]]) -> str:
29
  prompt = "\n".join([f"{c['role']}: {c['content']}" for c in conversation])
30
- prompt = f"{prompt}\nASSISTANT: "
31
- return prompt
32
 
33
 
34
  @spaces.GPU
@@ -120,9 +119,9 @@ demo = gr.ChatInterface(
120
  stop_btn=None,
121
  examples=[
122
  ["東京の観光名所を教えて。"],
123
- ["落武者って何?"],
124
- ["暴れん坊将軍って誰のこと?"],
125
- ["人がヘリを食べるのにかかる時間は?"],
126
  ],
127
  description=DESCRIPTION,
128
  css_paths="style.css",
 
1
  #!/usr/bin/env python
2
 
3
  import os
4
+ from collections.abc import Iterator
5
  from threading import Thread
 
6
 
7
  import gradio as gr
8
  import spaces
 
27
 
28
  def apply_chat_template(conversation: list[dict[str, str]]) -> str:
29
  prompt = "\n".join([f"{c['role']}: {c['content']}" for c in conversation])
30
+ return f"{prompt}\nASSISTANT: "
 
31
 
32
 
33
  @spaces.GPU
 
119
  stop_btn=None,
120
  examples=[
121
  ["東京の観光名所を教えて。"],
122
+ ["落武者って何?"], # noqa: RUF001
123
+ ["暴れん坊将軍って誰のこと?"], # noqa: RUF001
124
+ ["人がヘリを食べるのにかかる時間は?"], # noqa: RUF001
125
  ],
126
  description=DESCRIPTION,
127
  css_paths="style.css",
pyproject.toml CHANGED
@@ -5,11 +5,47 @@ description = ""
5
  readme = "README.md"
6
  requires-python = ">=3.10"
7
  dependencies = [
8
- "accelerate>=1.0.1",
9
- "bitsandbytes>=0.44.1",
10
- "gradio>=5.1.0",
11
  "hf-transfer>=0.1.8",
12
- "spaces>=0.30.4",
13
  "torch==2.4.0",
14
- "transformers>=4.45.2",
15
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  readme = "README.md"
6
  requires-python = ">=3.10"
7
  dependencies = [
8
+ "accelerate>=1.2.1",
9
+ "bitsandbytes>=0.45.0",
10
+ "gradio>=5.9.1",
11
  "hf-transfer>=0.1.8",
12
+ "spaces>=0.31.1",
13
  "torch==2.4.0",
14
+ "transformers>=4.47.1",
15
  ]
16
+
17
+ [tool.ruff]
18
+ line-length = 119
19
+
20
+ [tool.ruff.lint]
21
+ select = ["ALL"]
22
+ ignore = [
23
+ "COM812", # missing-trailing-comma
24
+ "D203", # one-blank-line-before-class
25
+ "D213", # multi-line-summary-second-line
26
+ "E501", # line-too-long
27
+ "SIM117", # multiple-with-statements
28
+ ]
29
+ extend-ignore = [
30
+ "D100", # undocumented-public-module
31
+ "D101", # undocumented-public-class
32
+ "D102", # undocumented-public-method
33
+ "D103", # undocumented-public-function
34
+ "D104", # undocumented-public-package
35
+ "D105", # undocumented-magic-method
36
+ "D107", # undocumented-public-init
37
+ "EM101", # raw-string-in-exception
38
+ "FBT001", # boolean-type-hint-positional-argument
39
+ "FBT002", # boolean-default-value-positional-argument
40
+ "PD901", # pandas-df-variable-name
41
+ "PGH003", # blanket-type-ignore
42
+ "PLR0913", # too-many-arguments
43
+ "PLR0915", # too-many-statements
44
+ "TRY003", # raise-vanilla-args
45
+ ]
46
+ unfixable = [
47
+ "F401", # unused-import
48
+ ]
49
+
50
+ [tool.ruff.format]
51
+ docstring-code-format = true
requirements.txt CHANGED
@@ -1,34 +1,34 @@
1
  # This file was autogenerated by uv via the following command:
2
  # uv pip compile pyproject.toml -o requirements.txt
3
- accelerate==1.0.1
4
  # via rakutenai-7b-chat (pyproject.toml)
5
  aiofiles==23.2.1
6
  # via gradio
7
  annotated-types==0.7.0
8
  # via pydantic
9
- anyio==4.6.2.post1
10
  # via
11
  # gradio
12
  # httpx
13
  # starlette
14
- bitsandbytes==0.44.1
15
  # via rakutenai-7b-chat (pyproject.toml)
16
- certifi==2024.8.30
17
  # via
18
  # httpcore
19
  # httpx
20
  # requests
21
- charset-normalizer==3.4.0
22
  # via requests
23
- click==8.1.7
24
  # via
25
  # typer
26
  # uvicorn
27
  exceptiongroup==1.2.2
28
  # via anyio
29
- fastapi==0.115.2
30
  # via gradio
31
- ffmpy==0.4.0
32
  # via gradio
33
  filelock==3.16.1
34
  # via
@@ -36,16 +36,16 @@ filelock==3.16.1
36
  # torch
37
  # transformers
38
  # triton
39
- fsspec==2024.9.0
40
  # via
41
  # gradio-client
42
  # huggingface-hub
43
  # torch
44
- gradio==5.1.0
45
  # via
46
  # rakutenai-7b-chat (pyproject.toml)
47
  # spaces
48
- gradio-client==1.4.0
49
  # via gradio
50
  h11==0.14.0
51
  # via
@@ -53,14 +53,15 @@ h11==0.14.0
53
  # uvicorn
54
  hf-transfer==0.1.8
55
  # via rakutenai-7b-chat (pyproject.toml)
56
- httpcore==1.0.6
57
  # via httpx
58
- httpx==0.27.2
59
  # via
60
  # gradio
61
  # gradio-client
 
62
  # spaces
63
- huggingface-hub==0.26.0
64
  # via
65
  # accelerate
66
  # gradio
@@ -72,7 +73,7 @@ idna==3.10
72
  # anyio
73
  # httpx
74
  # requests
75
- jinja2==3.1.4
76
  # via
77
  # gradio
78
  # torch
@@ -86,9 +87,9 @@ mdurl==0.1.2
86
  # via markdown-it-py
87
  mpmath==1.3.0
88
  # via sympy
89
- networkx==3.4.1
90
  # via torch
91
- numpy==2.1.2
92
  # via
93
  # accelerate
94
  # bitsandbytes
@@ -120,15 +121,15 @@ nvidia-cusparse-cu12==12.1.0.106
120
  # torch
121
  nvidia-nccl-cu12==2.20.5
122
  # via torch
123
- nvidia-nvjitlink-cu12==12.6.77
124
  # via
125
  # nvidia-cusolver-cu12
126
  # nvidia-cusparse-cu12
127
  nvidia-nvtx-cu12==12.1.105
128
  # via torch
129
- orjson==3.10.9
130
  # via gradio
131
- packaging==24.1
132
  # via
133
  # accelerate
134
  # gradio
@@ -138,18 +139,18 @@ packaging==24.1
138
  # transformers
139
  pandas==2.2.3
140
  # via gradio
141
- pillow==10.4.0
142
  # via gradio
143
  psutil==5.9.8
144
  # via
145
  # accelerate
146
  # spaces
147
- pydantic==2.9.2
148
  # via
149
  # fastapi
150
  # gradio
151
  # spaces
152
- pydantic-core==2.23.4
153
  # via pydantic
154
  pydub==0.25.1
155
  # via gradio
@@ -157,7 +158,7 @@ pygments==2.18.0
157
  # via rich
158
  python-dateutil==2.9.0.post0
159
  # via pandas
160
- python-multipart==0.0.12
161
  # via gradio
162
  pytz==2024.2
163
  # via pandas
@@ -167,16 +168,18 @@ pyyaml==6.0.2
167
  # gradio
168
  # huggingface-hub
169
  # transformers
170
- regex==2024.9.11
171
  # via transformers
172
  requests==2.32.3
173
  # via
174
  # huggingface-hub
175
  # spaces
176
  # transformers
177
- rich==13.9.2
178
  # via typer
179
- ruff==0.7.0
 
 
180
  # via gradio
181
  safetensors==0.4.5
182
  # via
@@ -186,40 +189,41 @@ 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 rakutenai-7b-chat (pyproject.toml)
197
- starlette==0.40.0
198
- # via fastapi
 
 
199
  sympy==1.13.3
200
  # via torch
201
- tokenizers==0.20.1
202
  # via transformers
203
- tomlkit==0.12.0
204
  # via gradio
205
  torch==2.4.0
206
  # via
207
  # rakutenai-7b-chat (pyproject.toml)
208
  # accelerate
209
  # bitsandbytes
210
- tqdm==4.66.5
211
  # via
212
  # huggingface-hub
213
  # transformers
214
- transformers==4.45.2
215
  # via rakutenai-7b-chat (pyproject.toml)
216
  triton==3.0.0
217
  # via torch
218
- typer==0.12.5
219
  # via gradio
220
  typing-extensions==4.12.2
221
  # via
222
  # anyio
 
223
  # fastapi
224
  # gradio
225
  # gradio-client
@@ -233,9 +237,9 @@ typing-extensions==4.12.2
233
  # uvicorn
234
  tzdata==2024.2
235
  # via pandas
236
- urllib3==2.2.3
237
  # via requests
238
- uvicorn==0.32.0
239
  # via gradio
240
- websockets==12.0
241
  # 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 rakutenai-7b-chat (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
+ bitsandbytes==0.45.0
15
  # via rakutenai-7b-chat (pyproject.toml)
16
+ certifi==2024.12.14
17
  # via
18
  # httpcore
19
  # httpx
20
  # requests
21
+ charset-normalizer==3.4.1
22
  # via requests
23
+ click==8.1.8
24
  # via
25
  # typer
26
  # uvicorn
27
  exceptiongroup==1.2.2
28
  # via anyio
29
+ fastapi==0.115.6
30
  # via gradio
31
+ ffmpy==0.5.0
32
  # via gradio
33
  filelock==3.16.1
34
  # via
 
36
  # torch
37
  # transformers
38
  # triton
39
+ fsspec==2024.12.0
40
  # via
41
  # gradio-client
42
  # huggingface-hub
43
  # torch
44
+ gradio==5.9.1
45
  # via
46
  # rakutenai-7b-chat (pyproject.toml)
47
  # spaces
48
+ gradio-client==1.5.2
49
  # via gradio
50
  h11==0.14.0
51
  # via
 
53
  # uvicorn
54
  hf-transfer==0.1.8
55
  # via rakutenai-7b-chat (pyproject.toml)
56
+ httpcore==1.0.7
57
  # via httpx
58
+ httpx==0.28.1
59
  # via
60
  # gradio
61
  # gradio-client
62
+ # safehttpx
63
  # spaces
64
+ huggingface-hub==0.27.0
65
  # via
66
  # accelerate
67
  # gradio
 
73
  # anyio
74
  # httpx
75
  # requests
76
+ jinja2==3.1.5
77
  # via
78
  # gradio
79
  # torch
 
87
  # via markdown-it-py
88
  mpmath==1.3.0
89
  # via sympy
90
+ networkx==3.4.2
91
  # via torch
92
+ numpy==2.2.1
93
  # via
94
  # accelerate
95
  # bitsandbytes
 
121
  # torch
122
  nvidia-nccl-cu12==2.20.5
123
  # via torch
124
+ nvidia-nvjitlink-cu12==12.6.85
125
  # via
126
  # nvidia-cusolver-cu12
127
  # nvidia-cusparse-cu12
128
  nvidia-nvtx-cu12==12.1.105
129
  # via torch
130
+ orjson==3.10.13
131
  # via gradio
132
+ packaging==24.2
133
  # via
134
  # accelerate
135
  # gradio
 
139
  # transformers
140
  pandas==2.2.3
141
  # via gradio
142
+ pillow==11.1.0
143
  # via gradio
144
  psutil==5.9.8
145
  # via
146
  # accelerate
147
  # spaces
148
+ pydantic==2.10.4
149
  # via
150
  # fastapi
151
  # gradio
152
  # spaces
153
+ pydantic-core==2.27.2
154
  # via pydantic
155
  pydub==0.25.1
156
  # via gradio
 
158
  # via rich
159
  python-dateutil==2.9.0.post0
160
  # via pandas
161
+ python-multipart==0.0.20
162
  # via gradio
163
  pytz==2024.2
164
  # via pandas
 
168
  # gradio
169
  # huggingface-hub
170
  # transformers
171
+ regex==2024.11.6
172
  # via transformers
173
  requests==2.32.3
174
  # via
175
  # huggingface-hub
176
  # spaces
177
  # transformers
178
+ rich==13.9.4
179
  # via typer
180
+ ruff==0.8.4
181
+ # via gradio
182
+ safehttpx==0.1.6
183
  # via gradio
184
  safetensors==0.4.5
185
  # via
 
189
  # via gradio
190
  shellingham==1.5.4
191
  # via typer
192
+ six==1.17.0
193
  # via python-dateutil
194
  sniffio==1.3.1
195
+ # via anyio
196
+ spaces==0.31.1
 
 
197
  # via rakutenai-7b-chat (pyproject.toml)
198
+ starlette==0.41.3
199
+ # via
200
+ # fastapi
201
+ # gradio
202
  sympy==1.13.3
203
  # via torch
204
+ tokenizers==0.21.0
205
  # via transformers
206
+ tomlkit==0.13.2
207
  # via gradio
208
  torch==2.4.0
209
  # via
210
  # rakutenai-7b-chat (pyproject.toml)
211
  # accelerate
212
  # bitsandbytes
213
+ tqdm==4.67.1
214
  # via
215
  # huggingface-hub
216
  # transformers
217
+ transformers==4.47.1
218
  # via rakutenai-7b-chat (pyproject.toml)
219
  triton==3.0.0
220
  # via torch
221
+ typer==0.15.1
222
  # via gradio
223
  typing-extensions==4.12.2
224
  # via
225
  # anyio
226
+ # bitsandbytes
227
  # fastapi
228
  # gradio
229
  # gradio-client
 
237
  # uvicorn
238
  tzdata==2024.2
239
  # via pandas
240
+ urllib3==2.3.0
241
  # via requests
242
+ uvicorn==0.34.0
243
  # via gradio
244
+ websockets==14.1
245
  # via gradio-client
uv.lock CHANGED
The diff for this file is too large to render. See raw diff