Update app.py
Browse files
app.py
CHANGED
@@ -1,40 +1,20 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
# Hugging Face logo
|
22 |
-
HF_LOGO = "https://huggingface.co/front/assets/huggingface_logo-noborder.svg"
|
23 |
-
|
24 |
-
# Gradio interface
|
25 |
-
with gr.Blocks() as demo:
|
26 |
-
gr.Image(value=HF_LOGO, width=120, show_label=False, show_download_button=False)
|
27 |
-
gr.Markdown("### Chat with Microsoft Phi-4 Mini Instruct (ONNX)")
|
28 |
-
|
29 |
-
chatbot = gr.Chatbot()
|
30 |
-
user_input = gr.Textbox(label="Your message")
|
31 |
-
state = gr.State([])
|
32 |
-
|
33 |
-
send_btn = gr.Button("Send")
|
34 |
-
clear_btn = gr.Button("Clear")
|
35 |
-
|
36 |
-
send_btn.click(chat_with_phi4, [user_input, state], [chatbot, state])
|
37 |
-
user_input.submit(chat_with_phi4, [user_input, state], [chatbot, state])
|
38 |
-
clear_btn.click(lambda: ([], []), outputs=[chatbot, state])
|
39 |
-
|
40 |
-
demo.launch()
|
|
|
1 |
+
# Core Gradio UI library
|
2 |
+
gradio>=4.0.0,<5.0.0
|
3 |
+
|
4 |
+
# ONNX Runtime GenAI for inference (CPU version)
|
5 |
+
# Use --pre as it's often in pre-release
|
6 |
+
# NOTE: If targeting a GPU Space, change this to onnxruntime-genai-cuda
|
7 |
+
# and update EXECUTION_PROVIDER in app.py to "cuda"
|
8 |
+
onnxruntime-genai --pre
|
9 |
+
|
10 |
+
# Hugging Face Hub for downloading models/files
|
11 |
+
huggingface_hub>=0.20.0
|
12 |
+
|
13 |
+
# ONNX Runtime itself (will be installed as a dependency of onnxruntime-genai,
|
14 |
+
# but specifying can sometimes help resolve version conflicts if needed)
|
15 |
+
# onnxruntime>=1.17.0 # Generally not needed to list explicitly
|
16 |
+
|
17 |
+
# Git LFS is needed by huggingface_hub to download large model files.
|
18 |
+
# It needs to be installed on the Space environment, which is usually handled
|
19 |
+
# by the Hugging Face Spaces infrastructure if not using Docker.
|
20 |
+
# If you encounter download issues, ensure git-lfs is available.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|