Spaces:
Runtime error
Runtime error
Commit ·
55f097c
1
Parent(s): d50d44d
Update app.py
Browse files
app.py
CHANGED
|
@@ -97,22 +97,22 @@ def chat(input_text):
|
|
| 97 |
outputs = model.generate(**inputs, max_new_tokens=350, do_sample=True)
|
| 98 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 99 |
|
| 100 |
-
# Remove
|
| 101 |
if base_prompt in response:
|
| 102 |
response = response.replace(base_prompt, "").strip()
|
| 103 |
if personality_reminder in response:
|
| 104 |
response = response.replace(personality_reminder, "").strip()
|
| 105 |
if "### Conversation History ###" in response:
|
| 106 |
response = response.replace("### Conversation History ###", "").strip()
|
|
|
|
|
|
|
| 107 |
|
| 108 |
# Add Rena's response to the conversation history
|
| 109 |
conversation_history.append(f"Rena: {response}")
|
| 110 |
|
| 111 |
-
#
|
| 112 |
-
if len(conversation_history) == 2
|
| 113 |
response = f"{emotions[current_emotion]} {response}"
|
| 114 |
-
elif "error" in input_text.lower(): # Add emotional response only for errors
|
| 115 |
-
response += f" {emotions['concerned']}"
|
| 116 |
|
| 117 |
# List of witty error responses
|
| 118 |
error_responses = [
|
|
@@ -121,7 +121,7 @@ def chat(input_text):
|
|
| 121 |
"That’s not a bug, it’s a feature in disguise! Let’s tame it.",
|
| 122 |
"Oops, something went wrong. But hey, at least it’s not my fault this time!",
|
| 123 |
"Ah, the sweet symphony of errors. Let’s orchestrate a fix, shall we?",
|
| 124 |
-
"Debugging is 90% frustration and 10%
|
| 125 |
]
|
| 126 |
|
| 127 |
# Handle specific inputs
|
|
@@ -138,6 +138,7 @@ def chat(input_text):
|
|
| 138 |
|
| 139 |
|
| 140 |
|
|
|
|
| 141 |
# Custom CSS for avatar styling
|
| 142 |
css = """
|
| 143 |
#rena_avatar img {
|
|
|
|
| 97 |
outputs = model.generate(**inputs, max_new_tokens=350, do_sample=True)
|
| 98 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 99 |
|
| 100 |
+
# Remove redundant text from the response
|
| 101 |
if base_prompt in response:
|
| 102 |
response = response.replace(base_prompt, "").strip()
|
| 103 |
if personality_reminder in response:
|
| 104 |
response = response.replace(personality_reminder, "").strip()
|
| 105 |
if "### Conversation History ###" in response:
|
| 106 |
response = response.replace("### Conversation History ###", "").strip()
|
| 107 |
+
if emotions[current_emotion] in response:
|
| 108 |
+
response = response.replace(emotions[current_emotion], "").strip()
|
| 109 |
|
| 110 |
# Add Rena's response to the conversation history
|
| 111 |
conversation_history.append(f"Rena: {response}")
|
| 112 |
|
| 113 |
+
# Contextual emotional response: Apply only if no direct match in history
|
| 114 |
+
if len(conversation_history) == 2 or "error" in input_text.lower():
|
| 115 |
response = f"{emotions[current_emotion]} {response}"
|
|
|
|
|
|
|
| 116 |
|
| 117 |
# List of witty error responses
|
| 118 |
error_responses = [
|
|
|
|
| 121 |
"That’s not a bug, it’s a feature in disguise! Let’s tame it.",
|
| 122 |
"Oops, something went wrong. But hey, at least it’s not my fault this time!",
|
| 123 |
"Ah, the sweet symphony of errors. Let’s orchestrate a fix, shall we?",
|
| 124 |
+
"Debugging is 90% frustration and 10% gagging .. I mean googling! —you’re doing great!"
|
| 125 |
]
|
| 126 |
|
| 127 |
# Handle specific inputs
|
|
|
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
+
|
| 142 |
# Custom CSS for avatar styling
|
| 143 |
css = """
|
| 144 |
#rena_avatar img {
|