Spaces:
Sleeping
Sleeping
Add files
Browse files- .pre-commit-config.yaml +33 -0
- .python-version +1 -0
- .vscode/extensions.json +8 -0
- .vscode/settings.json +17 -0
- LICENSE +21 -0
- README.md +3 -3
- app.py +23 -0
- pyproject.toml +51 -0
- requirements.txt +149 -0
- style.css +11 -0
- uv.lock +0 -0
.pre-commit-config.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 7 |
+
- id: check-merge-conflict
|
| 8 |
+
- id: check-shebang-scripts-are-executable
|
| 9 |
+
- id: check-toml
|
| 10 |
+
- id: check-yaml
|
| 11 |
+
- id: end-of-file-fixer
|
| 12 |
+
- id: mixed-line-ending
|
| 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.9.7
|
| 18 |
+
hooks:
|
| 19 |
+
- id: ruff
|
| 20 |
+
args: ["--fix"]
|
| 21 |
+
- id: ruff-format
|
| 22 |
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
| 23 |
+
rev: v1.15.0
|
| 24 |
+
hooks:
|
| 25 |
+
- id: mypy
|
| 26 |
+
args: ["--ignore-missing-imports"]
|
| 27 |
+
additional_dependencies:
|
| 28 |
+
[
|
| 29 |
+
"types-python-slugify",
|
| 30 |
+
"types-pytz",
|
| 31 |
+
"types-PyYAML",
|
| 32 |
+
"types-requests",
|
| 33 |
+
]
|
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.10
|
.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
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 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.formatOnSave.enabled": true
|
| 17 |
+
}
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2023 hysts
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
title: Deepseek R1 Sample
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.18.0
|
| 8 |
app_file: app.py
|
|
|
|
| 1 |
---
|
| 2 |
title: Deepseek R1 Sample
|
| 3 |
+
emoji: ⚡
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.18.0
|
| 8 |
app_file: app.py
|
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
from collections.abc import Iterator
|
| 5 |
+
|
| 6 |
+
import gradio as gr
|
| 7 |
+
from huggingface_hub import InferenceClient
|
| 8 |
+
|
| 9 |
+
client = InferenceClient(model="deepseek-ai/DeepSeek-R1", provider="together", api_key=os.getenv("HF_TOKEN"))
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def fn(message: str, history: list[dict]) -> Iterator[str]:
|
| 13 |
+
messages = [*history, {"role": "user", "content": message}]
|
| 14 |
+
out = ""
|
| 15 |
+
for chunk in client.chat_completion(messages=messages, max_tokens=2000, stream=True):
|
| 16 |
+
out += chunk.choices[0].delta.content or ""
|
| 17 |
+
yield out
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
demo = gr.ChatInterface(fn=fn, type="messages", chatbot=gr.Chatbot(type="messages", allow_tags=["think"], scale=1))
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
demo.launch()
|
pyproject.toml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "deepseek-r1-sample"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = ""
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
requires-python = ">=3.10"
|
| 7 |
+
dependencies = [
|
| 8 |
+
"gradio>=5.18.0",
|
| 9 |
+
]
|
| 10 |
+
|
| 11 |
+
[tool.ruff]
|
| 12 |
+
line-length = 119
|
| 13 |
+
|
| 14 |
+
[tool.ruff.lint]
|
| 15 |
+
select = ["ALL"]
|
| 16 |
+
ignore = [
|
| 17 |
+
"COM812", # missing-trailing-comma
|
| 18 |
+
"D203", # one-blank-line-before-class
|
| 19 |
+
"D213", # multi-line-summary-second-line
|
| 20 |
+
"E501", # line-too-long
|
| 21 |
+
"SIM117", # multiple-with-statements
|
| 22 |
+
]
|
| 23 |
+
extend-ignore = [
|
| 24 |
+
"D100", # undocumented-public-module
|
| 25 |
+
"D101", # undocumented-public-class
|
| 26 |
+
"D102", # undocumented-public-method
|
| 27 |
+
"D103", # undocumented-public-function
|
| 28 |
+
"D104", # undocumented-public-package
|
| 29 |
+
"D105", # undocumented-magic-method
|
| 30 |
+
"D107", # undocumented-public-init
|
| 31 |
+
"EM101", # raw-string-in-exception
|
| 32 |
+
"FBT001", # boolean-type-hint-positional-argument
|
| 33 |
+
"FBT002", # boolean-default-value-positional-argument
|
| 34 |
+
"PD901", # pandas-df-variable-name
|
| 35 |
+
"PGH003", # blanket-type-ignore
|
| 36 |
+
"PLR0913", # too-many-arguments
|
| 37 |
+
"PLR0915", # too-many-statements
|
| 38 |
+
"TRY003", # raise-vanilla-args
|
| 39 |
+
]
|
| 40 |
+
unfixable = [
|
| 41 |
+
"F401", # unused-import
|
| 42 |
+
]
|
| 43 |
+
|
| 44 |
+
[tool.ruff.lint.pydocstyle]
|
| 45 |
+
convention = "google"
|
| 46 |
+
|
| 47 |
+
[tool.ruff.lint.per-file-ignores]
|
| 48 |
+
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v via the following command:
|
| 2 |
+
# uv pip compile pyproject.toml -o requirements.txt
|
| 3 |
+
aiofiles==23.2.1
|
| 4 |
+
# via gradio
|
| 5 |
+
annotated-types==0.7.0
|
| 6 |
+
# via pydantic
|
| 7 |
+
anyio==4.8.0
|
| 8 |
+
# via
|
| 9 |
+
# gradio
|
| 10 |
+
# httpx
|
| 11 |
+
# starlette
|
| 12 |
+
certifi==2025.1.31
|
| 13 |
+
# via
|
| 14 |
+
# httpcore
|
| 15 |
+
# httpx
|
| 16 |
+
# requests
|
| 17 |
+
charset-normalizer==3.4.1
|
| 18 |
+
# via requests
|
| 19 |
+
click==8.1.8
|
| 20 |
+
# via
|
| 21 |
+
# typer
|
| 22 |
+
# uvicorn
|
| 23 |
+
exceptiongroup==1.2.2
|
| 24 |
+
# via anyio
|
| 25 |
+
fastapi==0.115.8
|
| 26 |
+
# via gradio
|
| 27 |
+
ffmpy==0.5.0
|
| 28 |
+
# via gradio
|
| 29 |
+
filelock==3.17.0
|
| 30 |
+
# via huggingface-hub
|
| 31 |
+
fsspec==2025.2.0
|
| 32 |
+
# via
|
| 33 |
+
# gradio-client
|
| 34 |
+
# huggingface-hub
|
| 35 |
+
gradio==5.18.0
|
| 36 |
+
# via deepseek-r1-sample (pyproject.toml)
|
| 37 |
+
gradio-client==1.7.2
|
| 38 |
+
# via gradio
|
| 39 |
+
h11==0.14.0
|
| 40 |
+
# via
|
| 41 |
+
# httpcore
|
| 42 |
+
# uvicorn
|
| 43 |
+
httpcore==1.0.7
|
| 44 |
+
# via httpx
|
| 45 |
+
httpx==0.28.1
|
| 46 |
+
# via
|
| 47 |
+
# gradio
|
| 48 |
+
# gradio-client
|
| 49 |
+
# safehttpx
|
| 50 |
+
huggingface-hub==0.29.1
|
| 51 |
+
# via
|
| 52 |
+
# gradio
|
| 53 |
+
# gradio-client
|
| 54 |
+
idna==3.10
|
| 55 |
+
# via
|
| 56 |
+
# anyio
|
| 57 |
+
# httpx
|
| 58 |
+
# requests
|
| 59 |
+
jinja2==3.1.5
|
| 60 |
+
# via gradio
|
| 61 |
+
markdown-it-py==3.0.0
|
| 62 |
+
# via rich
|
| 63 |
+
markupsafe==2.1.5
|
| 64 |
+
# via
|
| 65 |
+
# gradio
|
| 66 |
+
# jinja2
|
| 67 |
+
mdurl==0.1.2
|
| 68 |
+
# via markdown-it-py
|
| 69 |
+
numpy==2.2.3
|
| 70 |
+
# via
|
| 71 |
+
# gradio
|
| 72 |
+
# pandas
|
| 73 |
+
orjson==3.10.15
|
| 74 |
+
# via gradio
|
| 75 |
+
packaging==24.2
|
| 76 |
+
# via
|
| 77 |
+
# gradio
|
| 78 |
+
# gradio-client
|
| 79 |
+
# huggingface-hub
|
| 80 |
+
pandas==2.2.3
|
| 81 |
+
# via gradio
|
| 82 |
+
pillow==11.1.0
|
| 83 |
+
# via gradio
|
| 84 |
+
pydantic==2.10.6
|
| 85 |
+
# via
|
| 86 |
+
# fastapi
|
| 87 |
+
# gradio
|
| 88 |
+
pydantic-core==2.27.2
|
| 89 |
+
# via pydantic
|
| 90 |
+
pydub==0.25.1
|
| 91 |
+
# via gradio
|
| 92 |
+
pygments==2.19.1
|
| 93 |
+
# via rich
|
| 94 |
+
python-dateutil==2.9.0.post0
|
| 95 |
+
# via pandas
|
| 96 |
+
python-multipart==0.0.20
|
| 97 |
+
# via gradio
|
| 98 |
+
pytz==2025.1
|
| 99 |
+
# via pandas
|
| 100 |
+
pyyaml==6.0.2
|
| 101 |
+
# via
|
| 102 |
+
# gradio
|
| 103 |
+
# huggingface-hub
|
| 104 |
+
requests==2.32.3
|
| 105 |
+
# via huggingface-hub
|
| 106 |
+
rich==13.9.4
|
| 107 |
+
# via typer
|
| 108 |
+
ruff==0.9.7
|
| 109 |
+
# via gradio
|
| 110 |
+
safehttpx==0.1.6
|
| 111 |
+
# via gradio
|
| 112 |
+
semantic-version==2.10.0
|
| 113 |
+
# via gradio
|
| 114 |
+
shellingham==1.5.4
|
| 115 |
+
# via typer
|
| 116 |
+
six==1.17.0
|
| 117 |
+
# via python-dateutil
|
| 118 |
+
sniffio==1.3.1
|
| 119 |
+
# via anyio
|
| 120 |
+
starlette==0.45.3
|
| 121 |
+
# via
|
| 122 |
+
# fastapi
|
| 123 |
+
# gradio
|
| 124 |
+
tomlkit==0.13.2
|
| 125 |
+
# via gradio
|
| 126 |
+
tqdm==4.67.1
|
| 127 |
+
# via huggingface-hub
|
| 128 |
+
typer==0.15.1
|
| 129 |
+
# via gradio
|
| 130 |
+
typing-extensions==4.12.2
|
| 131 |
+
# via
|
| 132 |
+
# anyio
|
| 133 |
+
# fastapi
|
| 134 |
+
# gradio
|
| 135 |
+
# gradio-client
|
| 136 |
+
# huggingface-hub
|
| 137 |
+
# pydantic
|
| 138 |
+
# pydantic-core
|
| 139 |
+
# rich
|
| 140 |
+
# typer
|
| 141 |
+
# uvicorn
|
| 142 |
+
tzdata==2025.1
|
| 143 |
+
# via pandas
|
| 144 |
+
urllib3==2.3.0
|
| 145 |
+
# via requests
|
| 146 |
+
uvicorn==0.34.0
|
| 147 |
+
# via gradio
|
| 148 |
+
websockets==15.0
|
| 149 |
+
# via gradio-client
|
style.css
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
h1 {
|
| 2 |
+
text-align: center;
|
| 3 |
+
display: block;
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
#duplicate-button {
|
| 7 |
+
margin: auto;
|
| 8 |
+
color: #fff;
|
| 9 |
+
background: #1565c0;
|
| 10 |
+
border-radius: 100vh;
|
| 11 |
+
}
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|