Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,8 +48,19 @@ def generate(
|
|
| 48 |
"Espero que goste de mim. Como posso ajudá-lo hoje?"
|
| 49 |
]
|
| 50 |
|
| 51 |
-
|
|
|
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
| 54 |
output = ""
|
| 55 |
|
|
@@ -58,9 +69,8 @@ def generate(
|
|
| 58 |
yield output
|
| 59 |
return output
|
| 60 |
|
| 61 |
-
|
| 62 |
mychatbot = gr.Chatbot(
|
| 63 |
-
avatar_images=["./user.png", "./stella.jpg"], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True
|
| 64 |
|
| 65 |
demo = gr.ChatInterface(fn=generate,
|
| 66 |
chatbot=mychatbot,
|
|
@@ -69,4 +79,4 @@ demo = gr.ChatInterface(fn=generate,
|
|
| 69 |
undo_btn=None
|
| 70 |
)
|
| 71 |
|
| 72 |
-
demo.queue().launch(show_api=False)
|
|
|
|
| 48 |
"Espero que goste de mim. Como posso ajudá-lo hoje?"
|
| 49 |
]
|
| 50 |
|
| 51 |
+
# Add an initial user message
|
| 52 |
+
initial_user_message = "Olá, Stella! Como vai hoje?"
|
| 53 |
|
| 54 |
+
# Construct the prompt without the initial user message for the model
|
| 55 |
+
formatted_prompt = format_prompt(initial_user_message, history, system_messages)
|
| 56 |
+
|
| 57 |
+
# Send the initial user message to the model and ignore its response
|
| 58 |
+
client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
| 59 |
+
|
| 60 |
+
# Now, use the initial user message along with the system prompt for the rest of the conversation
|
| 61 |
+
formatted_prompt = format_prompt(prompt, history, system_messages + [initial_user_message])
|
| 62 |
+
|
| 63 |
+
# Continue the conversation and yield the output
|
| 64 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
| 65 |
output = ""
|
| 66 |
|
|
|
|
| 69 |
yield output
|
| 70 |
return output
|
| 71 |
|
|
|
|
| 72 |
mychatbot = gr.Chatbot(
|
| 73 |
+
avatar_images=["./user.png", "./stella.jpg"], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True)
|
| 74 |
|
| 75 |
demo = gr.ChatInterface(fn=generate,
|
| 76 |
chatbot=mychatbot,
|
|
|
|
| 79 |
undo_btn=None
|
| 80 |
)
|
| 81 |
|
| 82 |
+
demo.queue().launch(show_api=False)
|