Spaces:
Runtime error
Runtime error
Commit
·
e298b33
1
Parent(s):
b213ce2
Update app.py
Browse files
app.py
CHANGED
@@ -44,6 +44,7 @@ def regenerate(chatbot, chat_history_state, system_msg, max_tokens, temperature,
|
|
44 |
|
45 |
|
46 |
def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
|
|
47 |
history = history or []
|
48 |
|
49 |
# Use BASE_SYSTEM_MESSAGE if system_message is empty
|
@@ -51,7 +52,7 @@ def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetit
|
|
51 |
|
52 |
# A última mensagem do usuário
|
53 |
user_prompt = history[-1][0] if history else ""
|
54 |
-
|
55 |
# Preparar a entrada para o modelo
|
56 |
prompt_template = f'''system
|
57 |
{system_message_to_use.strip()}
|
@@ -74,13 +75,14 @@ assistant
|
|
74 |
# Decodificar a saída
|
75 |
decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
|
76 |
assistant_response = decoded_output.split('assistant')[-1].strip() # Pegar apenas a última resposta do assistente
|
77 |
-
|
78 |
# Atualizar o histórico
|
79 |
if history:
|
80 |
history[-1][1] += assistant_response
|
81 |
else:
|
82 |
history.append(["", assistant_response])
|
83 |
-
|
|
|
84 |
return history, history, ""
|
85 |
|
86 |
|
|
|
44 |
|
45 |
|
46 |
def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
47 |
+
print(f"Chat function called with history: {history}")
|
48 |
history = history or []
|
49 |
|
50 |
# Use BASE_SYSTEM_MESSAGE if system_message is empty
|
|
|
52 |
|
53 |
# A última mensagem do usuário
|
54 |
user_prompt = history[-1][0] if history else ""
|
55 |
+
print(f"User prompt used for generation: {user_prompt}") # Debug print
|
56 |
# Preparar a entrada para o modelo
|
57 |
prompt_template = f'''system
|
58 |
{system_message_to_use.strip()}
|
|
|
75 |
# Decodificar a saída
|
76 |
decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
|
77 |
assistant_response = decoded_output.split('assistant')[-1].strip() # Pegar apenas a última resposta do assistente
|
78 |
+
print(f"Generated assistant response: {assistant_response}") # Debug print
|
79 |
# Atualizar o histórico
|
80 |
if history:
|
81 |
history[-1][1] += assistant_response
|
82 |
else:
|
83 |
history.append(["", assistant_response])
|
84 |
+
|
85 |
+
print(f"Updated history: {history}")
|
86 |
return history, history, ""
|
87 |
|
88 |
|