Spaces:
Running
Running
update
Browse files
app.py
CHANGED
|
@@ -24,19 +24,6 @@ Always respond with code that can be executed or rendered directly.
|
|
| 24 |
|
| 25 |
Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text."""
|
| 26 |
|
| 27 |
-
MODEL_LIST = [
|
| 28 |
-
{
|
| 29 |
-
"name": "DeepSeek V3",
|
| 30 |
-
"value": "deepseek-ai/DeepSeek-V3-0324",
|
| 31 |
-
"description": "Latest DeepSeek model for coding tasks"
|
| 32 |
-
},
|
| 33 |
-
{
|
| 34 |
-
"name": "DeepSeek R1",
|
| 35 |
-
"value": "deepseek-ai/DeepSeek-R1-0528",
|
| 36 |
-
"description": "DeepSeek R1 model for coding tasks"
|
| 37 |
-
}
|
| 38 |
-
]
|
| 39 |
-
|
| 40 |
DEMO_LIST = [
|
| 41 |
{
|
| 42 |
"title": "Todo App",
|
|
@@ -75,7 +62,7 @@ DEMO_LIST = [
|
|
| 75 |
# HF Inference Client
|
| 76 |
YOUR_API_TOKEN = os.getenv('HF_TOKEN3')
|
| 77 |
client = InferenceClient(
|
| 78 |
-
provider="
|
| 79 |
api_key=YOUR_API_TOKEN,
|
| 80 |
bill_to="huggingface"
|
| 81 |
)
|
|
@@ -192,7 +179,6 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 192 |
history = gr.State([])
|
| 193 |
setting = gr.State({
|
| 194 |
"system": SystemPrompt,
|
| 195 |
-
"model": "deepseek-ai/DeepSeek-V3-0324",
|
| 196 |
})
|
| 197 |
|
| 198 |
with ms.Application() as app:
|
|
@@ -225,19 +211,11 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 225 |
"βοΈ set system Prompt", type="default")
|
| 226 |
codeBtn = antd.Button("π§βπ» view code", type="default")
|
| 227 |
historyBtn = antd.Button("π history", type="default")
|
| 228 |
-
modelBtn = antd.Button("π€ select model", type="default")
|
| 229 |
|
| 230 |
with antd.Modal(open=False, title="set system Prompt", width="800px") as system_prompt_modal:
|
| 231 |
systemPromptInput = antd.InputTextarea(
|
| 232 |
SystemPrompt, auto_size=True)
|
| 233 |
|
| 234 |
-
with antd.Modal(open=False, title="select model", width="600px") as model_modal:
|
| 235 |
-
modelSelect = antd.Select(
|
| 236 |
-
options=[{"label": model["name"], "value": model["value"], "description": model["description"]} for model in MODEL_LIST],
|
| 237 |
-
placeholder="Select a model",
|
| 238 |
-
style={"width": "100%"}
|
| 239 |
-
)
|
| 240 |
-
|
| 241 |
settingPromptBtn.click(lambda: gr.update(
|
| 242 |
open=True), inputs=[], outputs=[system_prompt_modal])
|
| 243 |
system_prompt_modal.ok(lambda input: ({"system": input}, gr.update(
|
|
@@ -245,13 +223,6 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 245 |
system_prompt_modal.cancel(lambda: gr.update(
|
| 246 |
open=False), outputs=[system_prompt_modal])
|
| 247 |
|
| 248 |
-
modelBtn.click(lambda: gr.update(
|
| 249 |
-
open=True), inputs=[], outputs=[model_modal])
|
| 250 |
-
model_modal.ok(lambda model_value: ({"model": model_value}, gr.update(
|
| 251 |
-
open=False)), inputs=[modelSelect], outputs=[setting, model_modal])
|
| 252 |
-
model_modal.cancel(lambda: gr.update(
|
| 253 |
-
open=False), outputs=[model_modal])
|
| 254 |
-
|
| 255 |
with antd.Drawer(open=False, title="code", placement="left", width="750px") as code_drawer:
|
| 256 |
code_output = legacy.Markdown()
|
| 257 |
|
|
@@ -288,7 +259,7 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 288 |
|
| 289 |
try:
|
| 290 |
completion = client.chat.completions.create(
|
| 291 |
-
model=
|
| 292 |
messages=messages,
|
| 293 |
stream=True
|
| 294 |
)
|
|
@@ -332,4 +303,4 @@ with gr.Blocks(css_paths="app.css") as demo:
|
|
| 332 |
clear_btn.click(clear_history, inputs=[], outputs=[history])
|
| 333 |
|
| 334 |
if __name__ == "__main__":
|
| 335 |
-
demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
|
|
|
|
| 24 |
|
| 25 |
Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text."""
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
DEMO_LIST = [
|
| 28 |
{
|
| 29 |
"title": "Todo App",
|
|
|
|
| 62 |
# HF Inference Client
|
| 63 |
YOUR_API_TOKEN = os.getenv('HF_TOKEN3')
|
| 64 |
client = InferenceClient(
|
| 65 |
+
provider="novita",
|
| 66 |
api_key=YOUR_API_TOKEN,
|
| 67 |
bill_to="huggingface"
|
| 68 |
)
|
|
|
|
| 179 |
history = gr.State([])
|
| 180 |
setting = gr.State({
|
| 181 |
"system": SystemPrompt,
|
|
|
|
| 182 |
})
|
| 183 |
|
| 184 |
with ms.Application() as app:
|
|
|
|
| 211 |
"βοΈ set system Prompt", type="default")
|
| 212 |
codeBtn = antd.Button("π§βπ» view code", type="default")
|
| 213 |
historyBtn = antd.Button("π history", type="default")
|
|
|
|
| 214 |
|
| 215 |
with antd.Modal(open=False, title="set system Prompt", width="800px") as system_prompt_modal:
|
| 216 |
systemPromptInput = antd.InputTextarea(
|
| 217 |
SystemPrompt, auto_size=True)
|
| 218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
settingPromptBtn.click(lambda: gr.update(
|
| 220 |
open=True), inputs=[], outputs=[system_prompt_modal])
|
| 221 |
system_prompt_modal.ok(lambda input: ({"system": input}, gr.update(
|
|
|
|
| 223 |
system_prompt_modal.cancel(lambda: gr.update(
|
| 224 |
open=False), outputs=[system_prompt_modal])
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
with antd.Drawer(open=False, title="code", placement="left", width="750px") as code_drawer:
|
| 227 |
code_output = legacy.Markdown()
|
| 228 |
|
|
|
|
| 259 |
|
| 260 |
try:
|
| 261 |
completion = client.chat.completions.create(
|
| 262 |
+
model="deepseek-ai/DeepSeek-V3-0324",
|
| 263 |
messages=messages,
|
| 264 |
stream=True
|
| 265 |
)
|
|
|
|
| 303 |
clear_btn.click(clear_history, inputs=[], outputs=[history])
|
| 304 |
|
| 305 |
if __name__ == "__main__":
|
| 306 |
+
demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
|