Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,37 +3,7 @@ from huggingface_hub import InferenceClient
|
|
| 3 |
from sentence_transformers import SentenceTransformer
|
| 4 |
import torch
|
| 5 |
import gradio as gr
|
| 6 |
-
import random
|
| 7 |
-
|
| 8 |
-
def respond(message, history):
|
| 9 |
-
messages = [{"role":"system", "content":"You are a friendly chatbot :)"}]
|
| 10 |
-
if history:
|
| 11 |
-
messages.extend(history)
|
| 12 |
-
messages.append({"role":"user", "content":message})
|
| 13 |
-
response = client.chat_completion(messages, max_tokens=100, temperature=1.3, top_p=0.2)
|
| 14 |
-
# temperature and top_p control randomness
|
| 15 |
-
return response["choices"][0]["message"]["content"].strip()
|
| 16 |
-
|
| 17 |
-
chat_theme = gr.themes.Soft(
|
| 18 |
-
primary_hue="indigo",
|
| 19 |
-
secondary_hue="purple",
|
| 20 |
-
neutral_hue="gray",
|
| 21 |
-
spacing_size="lg",
|
| 22 |
-
radius_size="lg"
|
| 23 |
-
).set(
|
| 24 |
-
# Input area
|
| 25 |
-
input_background_fill="*neutral_50",
|
| 26 |
-
input_border_color_focus="*primary_300",
|
| 27 |
-
# Button styling
|
| 28 |
-
button_primary_background_fill="*primary_500",
|
| 29 |
-
button_primary_background_fill_hover="*primary_400"
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
-
chatbot = gr.ChatInterface(respond, type="messages", theme=chat_theme)
|
| 33 |
-
|
| 34 |
-
chatbot.launch(ssr_mode=False)
|
| 35 |
-
|
| 36 |
-
|
| 37 |
|
| 38 |
# Making requests to the model to generate responses:
|
| 39 |
client = InferenceClient('Qwen/Qwen2.5-72B-Instruct')
|
|
@@ -163,7 +133,24 @@ def respond(message, history):
|
|
| 163 |
|
| 164 |
return response['choices'][0]['message']['content'].strip()
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
chatbot = gr.ChatInterface(respond, type="messages")
|
| 169 |
chatbot.launch()
|
|
|
|
| 3 |
from sentence_transformers import SentenceTransformer
|
| 4 |
import torch
|
| 5 |
import gradio as gr
|
| 6 |
+
import random
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Making requests to the model to generate responses:
|
| 9 |
client = InferenceClient('Qwen/Qwen2.5-72B-Instruct')
|
|
|
|
| 133 |
|
| 134 |
return response['choices'][0]['message']['content'].strip()
|
| 135 |
|
| 136 |
+
chat_theme = gr.themes.Soft(
|
| 137 |
+
primary_hue="indigo",
|
| 138 |
+
secondary_hue="purple",
|
| 139 |
+
neutral_hue="gray",
|
| 140 |
+
spacing_size="lg",
|
| 141 |
+
radius_size="lg"
|
| 142 |
+
).set(
|
| 143 |
+
# Input area
|
| 144 |
+
input_background_fill="*neutral_50",
|
| 145 |
+
input_border_color_focus="*primary_300",
|
| 146 |
+
# Button styling
|
| 147 |
+
button_primary_background_fill="*primary_500",
|
| 148 |
+
button_primary_background_fill_hover="*primary_400"
|
| 149 |
+
)
|
| 150 |
|
| 151 |
+
chatbot = gr.ChatInterface(respond, type="messages", theme=chat_theme)
|
| 152 |
+
|
| 153 |
+
chatbot.launch(ssr_mode=False)
|
| 154 |
|
| 155 |
chatbot = gr.ChatInterface(respond, type="messages")
|
| 156 |
chatbot.launch()
|