Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,11 +25,15 @@ print("Model ready!")
|
|
| 25 |
def generate_response(message, history, temperature, top_p, top_k, max_tokens):
|
| 26 |
"""Generate response from the model with streaming"""
|
| 27 |
|
| 28 |
-
# Build conversation history
|
| 29 |
messages = []
|
| 30 |
for user_msg, assistant_msg in history:
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
messages.append({"role": "user", "content": message})
|
| 34 |
|
| 35 |
# Apply chat template
|
|
@@ -86,7 +90,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 86 |
chatbot = gr.Chatbot(
|
| 87 |
height=500,
|
| 88 |
label="Chat History",
|
| 89 |
-
type="messages",
|
| 90 |
avatar_images=(None, "https://em-content.zobj.net/source/twitter/53/robot-face_1f916.png")
|
| 91 |
)
|
| 92 |
|
|
@@ -212,4 +215,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 212 |
)
|
| 213 |
|
| 214 |
if __name__ == "__main__":
|
| 215 |
-
demo.queue().launch()
|
|
|
|
| 25 |
def generate_response(message, history, temperature, top_p, top_k, max_tokens):
|
| 26 |
"""Generate response from the model with streaming"""
|
| 27 |
|
| 28 |
+
# Build conversation history - history is list of [user_msg, bot_msg] pairs
|
| 29 |
messages = []
|
| 30 |
for user_msg, assistant_msg in history:
|
| 31 |
+
if user_msg:
|
| 32 |
+
messages.append({"role": "user", "content": user_msg})
|
| 33 |
+
if assistant_msg:
|
| 34 |
+
messages.append({"role": "assistant", "content": assistant_msg})
|
| 35 |
+
|
| 36 |
+
# Add current message
|
| 37 |
messages.append({"role": "user", "content": message})
|
| 38 |
|
| 39 |
# Apply chat template
|
|
|
|
| 90 |
chatbot = gr.Chatbot(
|
| 91 |
height=500,
|
| 92 |
label="Chat History",
|
|
|
|
| 93 |
avatar_images=(None, "https://em-content.zobj.net/source/twitter/53/robot-face_1f916.png")
|
| 94 |
)
|
| 95 |
|
|
|
|
| 215 |
)
|
| 216 |
|
| 217 |
if __name__ == "__main__":
|
| 218 |
+
demo.queue().launch()
|