Spaces:
Sleeping
Sleeping
gradio depreciation
Browse files
app.py
CHANGED
|
@@ -181,20 +181,14 @@ async def generate_stream_api(request: GenerateRequest):
|
|
| 181 |
)
|
| 182 |
|
| 183 |
def chat_gradio(message, history, language, system_prompt, max_length, temperature):
|
| 184 |
-
|
| 185 |
-
# previous messages in gradio is stored in
|
| 186 |
messages = []
|
| 187 |
|
| 188 |
if system_prompt:
|
| 189 |
messages.append({"role": "system", "content": system_prompt})
|
| 190 |
|
| 191 |
-
# only uses the last 10 messages
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
for user_msg, bot_msg in recent_history:
|
| 195 |
-
messages.append({"role": "user", "content": user_msg})
|
| 196 |
-
if bot_msg:
|
| 197 |
-
messages.append({"role": "assistant", "content": bot_msg})
|
| 198 |
|
| 199 |
messages.append({"role": "user", "content": message})
|
| 200 |
|
|
@@ -215,7 +209,8 @@ with gr.Blocks(title="Language Learning Chatbot", theme=gr.themes.Soft()) as dem
|
|
| 215 |
chatbot = gr.Chatbot(
|
| 216 |
label="Conversation",
|
| 217 |
height=500,
|
| 218 |
-
show_copy_button=True # Let users copy messages
|
|
|
|
| 219 |
)
|
| 220 |
|
| 221 |
# User input
|
|
|
|
| 181 |
)
|
| 182 |
|
| 183 |
def chat_gradio(message, history, language, system_prompt, max_length, temperature):
|
| 184 |
+
|
|
|
|
| 185 |
messages = []
|
| 186 |
|
| 187 |
if system_prompt:
|
| 188 |
messages.append({"role": "system", "content": system_prompt})
|
| 189 |
|
| 190 |
+
# only uses the last 10 messages to keep within context limit
|
| 191 |
+
messages.extend(history[-10:])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
messages.append({"role": "user", "content": message})
|
| 194 |
|
|
|
|
| 209 |
chatbot = gr.Chatbot(
|
| 210 |
label="Conversation",
|
| 211 |
height=500,
|
| 212 |
+
show_copy_button=True, # Let users copy messages
|
| 213 |
+
type="messages"
|
| 214 |
)
|
| 215 |
|
| 216 |
# User input
|