Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,15 @@
|
|
1 |
-
'''🔧 Prerequisites
|
2 |
-
|
3 |
-
Install the necessary packages:
|
4 |
-
|
5 |
-
pip install gradio transformers
|
6 |
-
|
7 |
-
📱 Gradio Chatbot App Code
|
8 |
-
'''
|
9 |
import gradio as gr
|
10 |
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
|
11 |
import torch
|
12 |
|
13 |
# List of available premium models
|
14 |
premium_models = [
|
15 |
-
"
|
16 |
-
"
|
17 |
-
"Qwen/Qwen2.
|
18 |
-
"Qwen/Qwen2.
|
19 |
-
"
|
20 |
-
"
|
21 |
-
"Alibaba-NLP/gte-Qwen2-7B-instruct",
|
22 |
]
|
23 |
|
24 |
# Dictionary to cache loaded pipelines
|
@@ -72,6 +63,9 @@ with gr.Blocks() as demo:
|
|
72 |
|
73 |
with gr.Row():
|
74 |
model_choice = gr.Dropdown(label="Select Model", choices=premium_models, value=premium_models[0])
|
|
|
|
|
|
|
75 |
|
76 |
chatbot_ui = gr.Chatbot(type="messages")
|
77 |
user_input = gr.Textbox(show_label=False, placeholder="Type your message and press Enter")
|
@@ -83,25 +77,3 @@ with gr.Blocks() as demo:
|
|
83 |
clear_btn.click(lambda: ([], ""), None, [chatbot_ui, state])
|
84 |
|
85 |
demo.launch()
|
86 |
-
'''
|
87 |
-
✅ Features:
|
88 |
-
|
89 |
-
Model selection from dropdown
|
90 |
-
|
91 |
-
Maintains chat history
|
92 |
-
|
93 |
-
Respects a system prompt
|
94 |
-
|
95 |
-
Uses text-generation pipeline
|
96 |
-
|
97 |
-
🧠 Optional Upgrades:
|
98 |
-
|
99 |
-
Replace text-generation with chat-completion if models support it (like OpenChat, Mistral-instruct, etc.)
|
100 |
-
|
101 |
-
Add streaming or token-by-token response if supported
|
102 |
-
|
103 |
-
Save/load chat history
|
104 |
-
|
105 |
-
Add support for vision models (Qwen2.5-VL-7B-Instruct) using a different UI tab
|
106 |
-
|
107 |
-
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
|
3 |
import torch
|
4 |
|
5 |
# List of available premium models
|
6 |
premium_models = [
|
7 |
+
"Qwen/Qwen2-0.5B",
|
8 |
+
"Qwen/Qwen2-0.5B-Instruct",
|
9 |
+
"Qwen/Qwen2-0.5B-Coder",
|
10 |
+
"Qwen/Qwen2-1.5B",
|
11 |
+
"Qwen/Qwen2-1.5B-Instruct",
|
12 |
+
"Qwen/Qwen2-1.5B-Coder",
|
|
|
13 |
]
|
14 |
|
15 |
# Dictionary to cache loaded pipelines
|
|
|
63 |
|
64 |
with gr.Row():
|
65 |
model_choice = gr.Dropdown(label="Select Model", choices=premium_models, value=premium_models[0])
|
66 |
+
|
67 |
+
with gr.Row():
|
68 |
+
model_choice = gr.Textbox(label="System Prompt", choices=premium_models, value=default_system_prompt)
|
69 |
|
70 |
chatbot_ui = gr.Chatbot(type="messages")
|
71 |
user_input = gr.Textbox(show_label=False, placeholder="Type your message and press Enter")
|
|
|
77 |
clear_btn.click(lambda: ([], ""), None, [chatbot_ui, state])
|
78 |
|
79 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|