Spaces:
Sleeping
Sleeping
Commit ·
57798ee
1
Parent(s): d6ffd09
Downgrade Gradio to 4.44.1 and revert to stable Chatbot format
Browse files- README.md +1 -1
- app.py +5 -12
- requirements.txt +1 -1
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 💬
|
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
hf_oauth: true
|
|
|
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
hf_oauth: true
|
app.py
CHANGED
|
@@ -167,7 +167,6 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="gray"), css=custom_css) as demo
|
|
| 167 |
elem_id="chatbot",
|
| 168 |
show_label=False,
|
| 169 |
bubble_full_width=False,
|
| 170 |
-
type="messages" # Updated for Gradio 5
|
| 171 |
)
|
| 172 |
|
| 173 |
with gr.Row(elem_id="input-container"):
|
|
@@ -183,20 +182,14 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="gray"), css=custom_css) as demo
|
|
| 183 |
|
| 184 |
# Linking components
|
| 185 |
def chat_echo(message, history):
|
| 186 |
-
|
| 187 |
-
return "", history
|
| 188 |
|
| 189 |
def bot_response(history, model_id, system_message, max_tokens, temperature, top_p):
|
| 190 |
-
user_message = history[-1][
|
| 191 |
|
| 192 |
-
# Convert messages format back to legacy for the respond function or update respond
|
| 193 |
legacy_history = []
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
if i+1 < len(history):
|
| 197 |
-
legacy_history.append([history[i]["content"], history[i+1]["content"]])
|
| 198 |
-
|
| 199 |
-
history.append({"role": "assistant", "content": ""})
|
| 200 |
|
| 201 |
response_gen = respond(
|
| 202 |
user_message,
|
|
@@ -209,7 +202,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="gray"), css=custom_css) as demo
|
|
| 209 |
)
|
| 210 |
|
| 211 |
for partial_response in response_gen:
|
| 212 |
-
history[-1][
|
| 213 |
yield history
|
| 214 |
|
| 215 |
msg.submit(chat_echo, [msg, chatbot], [msg, chatbot], queue=False).then(
|
|
|
|
| 167 |
elem_id="chatbot",
|
| 168 |
show_label=False,
|
| 169 |
bubble_full_width=False,
|
|
|
|
| 170 |
)
|
| 171 |
|
| 172 |
with gr.Row(elem_id="input-container"):
|
|
|
|
| 182 |
|
| 183 |
# Linking components
|
| 184 |
def chat_echo(message, history):
|
| 185 |
+
return "", history + [[message, None]]
|
|
|
|
| 186 |
|
| 187 |
def bot_response(history, model_id, system_message, max_tokens, temperature, top_p):
|
| 188 |
+
user_message = history[-1][0]
|
| 189 |
|
|
|
|
| 190 |
legacy_history = []
|
| 191 |
+
for i in range(len(history) - 1):
|
| 192 |
+
legacy_history.append([history[i][0], history[i][1]])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
response_gen = respond(
|
| 195 |
user_message,
|
|
|
|
| 202 |
)
|
| 203 |
|
| 204 |
for partial_response in response_gen:
|
| 205 |
+
history[-1][1] = partial_response
|
| 206 |
yield history
|
| 207 |
|
| 208 |
msg.submit(chat_echo, [msg, chatbot], [msg, chatbot], queue=False).then(
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
gradio
|
| 2 |
huggingface_hub
|
| 3 |
python-dotenv
|
| 4 |
transformers
|
|
|
|
| 1 |
+
gradio==4.44.1
|
| 2 |
huggingface_hub
|
| 3 |
python-dotenv
|
| 4 |
transformers
|