Spaces:
Running
on
Zero
Running
on
Zero
Update
Browse files- README.md +2 -2
- app.py +3 -9
- requirements.txt +259 -6
README.md
CHANGED
@@ -4,10 +4,10 @@ emoji: 😻
|
|
4 |
colorFrom: indigo
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
short_description: Chatbot
|
11 |
---
|
12 |
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
4 |
colorFrom: indigo
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.44.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
short_description: Chatbot
|
11 |
---
|
12 |
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -37,21 +37,14 @@ model.eval()
|
|
37 |
@spaces.GPU(duration=90)
|
38 |
def generate(
|
39 |
message: str,
|
40 |
-
chat_history: list[
|
41 |
max_new_tokens: int = 1024,
|
42 |
temperature: float = 0.6,
|
43 |
top_p: float = 0.9,
|
44 |
top_k: int = 50,
|
45 |
repetition_penalty: float = 1.2,
|
46 |
) -> Iterator[str]:
|
47 |
-
conversation =
|
48 |
-
for user, assistant in chat_history:
|
49 |
-
conversation.extend(
|
50 |
-
[
|
51 |
-
{"role": "user", "content": user},
|
52 |
-
{"role": "assistant", "content": assistant},
|
53 |
-
]
|
54 |
-
)
|
55 |
conversation.append({"role": "user", "content": message})
|
56 |
|
57 |
input_ids = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, return_tensors="pt")
|
@@ -129,6 +122,7 @@ chat_interface = gr.ChatInterface(
|
|
129 |
["Write a 100-word article on 'Benefits of Open-Source in AI research'"],
|
130 |
],
|
131 |
cache_examples=False,
|
|
|
132 |
)
|
133 |
|
134 |
with gr.Blocks(css="style.css", fill_height=True) as demo:
|
|
|
37 |
@spaces.GPU(duration=90)
|
38 |
def generate(
|
39 |
message: str,
|
40 |
+
chat_history: list[dict],
|
41 |
max_new_tokens: int = 1024,
|
42 |
temperature: float = 0.6,
|
43 |
top_p: float = 0.9,
|
44 |
top_k: int = 50,
|
45 |
repetition_penalty: float = 1.2,
|
46 |
) -> Iterator[str]:
|
47 |
+
conversation = chat_history.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
conversation.append({"role": "user", "content": message})
|
49 |
|
50 |
input_ids = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, return_tensors="pt")
|
|
|
122 |
["Write a 100-word article on 'Benefits of Open-Source in AI research'"],
|
123 |
],
|
124 |
cache_examples=False,
|
125 |
+
type="messages",
|
126 |
)
|
127 |
|
128 |
with gr.Blocks(css="style.css", fill_height=True) as demo:
|
requirements.txt
CHANGED
@@ -1,6 +1,259 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file was autogenerated by uv via the following command:
|
2 |
+
# uv pip compile pyproject.toml -o requirements.txt
|
3 |
+
accelerate==0.34.2
|
4 |
+
# via gemma-2-9b-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 |
+
contourpy==1.3.0
|
26 |
+
# via matplotlib
|
27 |
+
cycler==0.12.1
|
28 |
+
# via matplotlib
|
29 |
+
exceptiongroup==1.2.2
|
30 |
+
# via anyio
|
31 |
+
fastapi==0.115.0
|
32 |
+
# via gradio
|
33 |
+
ffmpy==0.4.0
|
34 |
+
# via gradio
|
35 |
+
filelock==3.16.1
|
36 |
+
# via
|
37 |
+
# huggingface-hub
|
38 |
+
# torch
|
39 |
+
# transformers
|
40 |
+
# triton
|
41 |
+
fonttools==4.54.1
|
42 |
+
# via matplotlib
|
43 |
+
fsspec==2024.9.0
|
44 |
+
# via
|
45 |
+
# gradio-client
|
46 |
+
# huggingface-hub
|
47 |
+
# torch
|
48 |
+
gradio==4.44.0
|
49 |
+
# via
|
50 |
+
# gemma-2-9b-it (pyproject.toml)
|
51 |
+
# spaces
|
52 |
+
gradio-client==1.3.0
|
53 |
+
# via gradio
|
54 |
+
h11==0.14.0
|
55 |
+
# via
|
56 |
+
# httpcore
|
57 |
+
# uvicorn
|
58 |
+
hf-transfer==0.1.8
|
59 |
+
# via gemma-2-9b-it (pyproject.toml)
|
60 |
+
httpcore==1.0.5
|
61 |
+
# via httpx
|
62 |
+
httpx==0.27.2
|
63 |
+
# via
|
64 |
+
# gradio
|
65 |
+
# gradio-client
|
66 |
+
# spaces
|
67 |
+
huggingface-hub==0.25.1
|
68 |
+
# via
|
69 |
+
# accelerate
|
70 |
+
# gradio
|
71 |
+
# gradio-client
|
72 |
+
# tokenizers
|
73 |
+
# transformers
|
74 |
+
idna==3.10
|
75 |
+
# via
|
76 |
+
# anyio
|
77 |
+
# httpx
|
78 |
+
# requests
|
79 |
+
importlib-resources==6.4.5
|
80 |
+
# via gradio
|
81 |
+
jinja2==3.1.4
|
82 |
+
# via
|
83 |
+
# gradio
|
84 |
+
# torch
|
85 |
+
kiwisolver==1.4.7
|
86 |
+
# via matplotlib
|
87 |
+
markdown-it-py==3.0.0
|
88 |
+
# via rich
|
89 |
+
markupsafe==2.1.5
|
90 |
+
# via
|
91 |
+
# gradio
|
92 |
+
# jinja2
|
93 |
+
matplotlib==3.9.2
|
94 |
+
# via gradio
|
95 |
+
mdurl==0.1.2
|
96 |
+
# via markdown-it-py
|
97 |
+
mpmath==1.3.0
|
98 |
+
# via sympy
|
99 |
+
networkx==3.3
|
100 |
+
# via torch
|
101 |
+
numpy==2.1.1
|
102 |
+
# via
|
103 |
+
# accelerate
|
104 |
+
# contourpy
|
105 |
+
# gradio
|
106 |
+
# matplotlib
|
107 |
+
# pandas
|
108 |
+
# transformers
|
109 |
+
nvidia-cublas-cu12==12.1.3.1
|
110 |
+
# via
|
111 |
+
# nvidia-cudnn-cu12
|
112 |
+
# nvidia-cusolver-cu12
|
113 |
+
# torch
|
114 |
+
nvidia-cuda-cupti-cu12==12.1.105
|
115 |
+
# via torch
|
116 |
+
nvidia-cuda-nvrtc-cu12==12.1.105
|
117 |
+
# via torch
|
118 |
+
nvidia-cuda-runtime-cu12==12.1.105
|
119 |
+
# via torch
|
120 |
+
nvidia-cudnn-cu12==9.1.0.70
|
121 |
+
# via torch
|
122 |
+
nvidia-cufft-cu12==11.0.2.54
|
123 |
+
# via torch
|
124 |
+
nvidia-curand-cu12==10.3.2.106
|
125 |
+
# via torch
|
126 |
+
nvidia-cusolver-cu12==11.4.5.107
|
127 |
+
# via torch
|
128 |
+
nvidia-cusparse-cu12==12.1.0.106
|
129 |
+
# via
|
130 |
+
# nvidia-cusolver-cu12
|
131 |
+
# torch
|
132 |
+
nvidia-nccl-cu12==2.20.5
|
133 |
+
# via torch
|
134 |
+
nvidia-nvjitlink-cu12==12.6.68
|
135 |
+
# via
|
136 |
+
# nvidia-cusolver-cu12
|
137 |
+
# nvidia-cusparse-cu12
|
138 |
+
nvidia-nvtx-cu12==12.1.105
|
139 |
+
# via torch
|
140 |
+
orjson==3.10.7
|
141 |
+
# via gradio
|
142 |
+
packaging==24.1
|
143 |
+
# via
|
144 |
+
# accelerate
|
145 |
+
# gradio
|
146 |
+
# gradio-client
|
147 |
+
# huggingface-hub
|
148 |
+
# matplotlib
|
149 |
+
# spaces
|
150 |
+
# transformers
|
151 |
+
pandas==2.2.3
|
152 |
+
# via gradio
|
153 |
+
pillow==10.4.0
|
154 |
+
# via
|
155 |
+
# gradio
|
156 |
+
# matplotlib
|
157 |
+
psutil==5.9.8
|
158 |
+
# via
|
159 |
+
# accelerate
|
160 |
+
# spaces
|
161 |
+
pydantic==2.9.2
|
162 |
+
# via
|
163 |
+
# fastapi
|
164 |
+
# gradio
|
165 |
+
# spaces
|
166 |
+
pydantic-core==2.23.4
|
167 |
+
# via pydantic
|
168 |
+
pydub==0.25.1
|
169 |
+
# via gradio
|
170 |
+
pygments==2.18.0
|
171 |
+
# via rich
|
172 |
+
pyparsing==3.1.4
|
173 |
+
# via matplotlib
|
174 |
+
python-dateutil==2.9.0.post0
|
175 |
+
# via
|
176 |
+
# matplotlib
|
177 |
+
# pandas
|
178 |
+
python-multipart==0.0.12
|
179 |
+
# via gradio
|
180 |
+
pytz==2024.2
|
181 |
+
# via pandas
|
182 |
+
pyyaml==6.0.2
|
183 |
+
# via
|
184 |
+
# accelerate
|
185 |
+
# gradio
|
186 |
+
# huggingface-hub
|
187 |
+
# transformers
|
188 |
+
regex==2024.9.11
|
189 |
+
# via transformers
|
190 |
+
requests==2.32.3
|
191 |
+
# via
|
192 |
+
# huggingface-hub
|
193 |
+
# spaces
|
194 |
+
# transformers
|
195 |
+
rich==13.8.1
|
196 |
+
# via typer
|
197 |
+
ruff==0.6.8
|
198 |
+
# via gradio
|
199 |
+
safetensors==0.4.5
|
200 |
+
# via
|
201 |
+
# accelerate
|
202 |
+
# transformers
|
203 |
+
semantic-version==2.10.0
|
204 |
+
# via gradio
|
205 |
+
shellingham==1.5.4
|
206 |
+
# via typer
|
207 |
+
six==1.16.0
|
208 |
+
# via python-dateutil
|
209 |
+
sniffio==1.3.1
|
210 |
+
# via
|
211 |
+
# anyio
|
212 |
+
# httpx
|
213 |
+
spaces==0.30.2
|
214 |
+
# via gemma-2-9b-it (pyproject.toml)
|
215 |
+
starlette==0.38.6
|
216 |
+
# via fastapi
|
217 |
+
sympy==1.13.3
|
218 |
+
# via torch
|
219 |
+
tokenizers==0.20.0
|
220 |
+
# via transformers
|
221 |
+
tomlkit==0.12.0
|
222 |
+
# via gradio
|
223 |
+
torch==2.4.0
|
224 |
+
# via
|
225 |
+
# gemma-2-9b-it (pyproject.toml)
|
226 |
+
# accelerate
|
227 |
+
tqdm==4.66.5
|
228 |
+
# via
|
229 |
+
# huggingface-hub
|
230 |
+
# transformers
|
231 |
+
transformers==4.45.1
|
232 |
+
# via gemma-2-9b-it (pyproject.toml)
|
233 |
+
triton==3.0.0
|
234 |
+
# via torch
|
235 |
+
typer==0.12.5
|
236 |
+
# via gradio
|
237 |
+
typing-extensions==4.12.2
|
238 |
+
# via
|
239 |
+
# anyio
|
240 |
+
# fastapi
|
241 |
+
# gradio
|
242 |
+
# gradio-client
|
243 |
+
# huggingface-hub
|
244 |
+
# pydantic
|
245 |
+
# pydantic-core
|
246 |
+
# spaces
|
247 |
+
# torch
|
248 |
+
# typer
|
249 |
+
# uvicorn
|
250 |
+
tzdata==2024.2
|
251 |
+
# via pandas
|
252 |
+
urllib3==2.2.3
|
253 |
+
# via
|
254 |
+
# gradio
|
255 |
+
# requests
|
256 |
+
uvicorn==0.31.0
|
257 |
+
# via gradio
|
258 |
+
websockets==12.0
|
259 |
+
# via gradio-client
|