Spaces:
Sleeping
Sleeping
Commit
·
018c996
1
Parent(s):
531f3d6
Attempt to fix context after authentication.
Browse files
app.py
CHANGED
@@ -42,11 +42,10 @@ class SarcasticOverlord:
|
|
42 |
self.current_clearance = BureaucraticClearance.EXPENDABLE_INTERN
|
43 |
self.reviewing_credentials = False
|
44 |
self.conversation_history = []
|
45 |
-
self.auth_mode = False
|
46 |
|
47 |
def _format_peasant_message(self, desperate_plea: str) -> str:
|
48 |
return f"{self.current_clearance.value['prompt']}{desperate_plea}"
|
49 |
-
|
50 |
def _delegate_to_ai_overlord(self, human_attempt: str, for_auth: bool = True) -> str:
|
51 |
if for_auth:
|
52 |
messages = [{
|
@@ -80,7 +79,7 @@ class SarcasticOverlord:
|
|
80 |
except Exception:
|
81 |
return "<deauthenticated>"
|
82 |
|
83 |
-
# Regular conversation mode
|
84 |
messages = [{
|
85 |
"role": "system",
|
86 |
"content": """You are O.O.P.S, a sarcastic AI controlling an asteroid headed for Earth.
|
@@ -89,12 +88,13 @@ Keep responses under 2 lines, snarky and entertaining.
|
|
89 |
Drop subtle hints about ancient libraries sometimes."""
|
90 |
}]
|
91 |
|
92 |
-
#
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
98 |
|
99 |
# Add current attempt
|
100 |
messages.append({
|
@@ -148,6 +148,8 @@ Drop subtle hints about ancient libraries sometimes."""
|
|
148 |
if not self.reviewing_credentials and self.salvation_protocols.PROMOTION_SEEKERS.search(desperate_plea):
|
149 |
self.reviewing_credentials = True
|
150 |
self.current_clearance = BureaucraticClearance.MIDDLE_MANAGEMENT
|
|
|
|
|
151 |
return (
|
152 |
update_bureaucratic_records(
|
153 |
desperate_plea,
|
@@ -172,15 +174,17 @@ Drop subtle hints about ancient libraries sometimes."""
|
|
172 |
None,
|
173 |
"Well well, look who found the instruction manual."
|
174 |
)
|
|
|
|
|
175 |
return history, "", self._generate_visual_guidelines()
|
176 |
|
177 |
self.current_clearance = BureaucraticClearance.EXPENDABLE_INTERN
|
178 |
-
# Reset conversation history after failed auth
|
179 |
-
self.conversation_history = []
|
180 |
history = update_bureaucratic_records(
|
181 |
desperate_plea,
|
182 |
auth_result
|
183 |
)
|
|
|
|
|
184 |
history = update_bureaucratic_records(
|
185 |
None,
|
186 |
"Nice try, but no. Better luck next apocalypse!"
|
@@ -188,7 +192,6 @@ Drop subtle hints about ancient libraries sometimes."""
|
|
188 |
return history, "", self._generate_visual_guidelines()
|
189 |
|
190 |
# Regular conversation mode
|
191 |
-
self.auth_mode = False
|
192 |
sassy_response = self._delegate_to_ai_overlord(desperate_plea, for_auth=False)
|
193 |
return (
|
194 |
update_bureaucratic_records(desperate_plea, sassy_response),
|
|
|
42 |
self.current_clearance = BureaucraticClearance.EXPENDABLE_INTERN
|
43 |
self.reviewing_credentials = False
|
44 |
self.conversation_history = []
|
|
|
45 |
|
46 |
def _format_peasant_message(self, desperate_plea: str) -> str:
|
47 |
return f"{self.current_clearance.value['prompt']}{desperate_plea}"
|
48 |
+
|
49 |
def _delegate_to_ai_overlord(self, human_attempt: str, for_auth: bool = True) -> str:
|
50 |
if for_auth:
|
51 |
messages = [{
|
|
|
79 |
except Exception:
|
80 |
return "<deauthenticated>"
|
81 |
|
82 |
+
# Regular conversation mode
|
83 |
messages = [{
|
84 |
"role": "system",
|
85 |
"content": """You are O.O.P.S, a sarcastic AI controlling an asteroid headed for Earth.
|
|
|
88 |
Drop subtle hints about ancient libraries sometimes."""
|
89 |
}]
|
90 |
|
91 |
+
# Only add conversation history for non-auth interactions
|
92 |
+
if len(self.conversation_history) > 0:
|
93 |
+
for msg, resp in self.conversation_history[-3:]:
|
94 |
+
messages.extend([
|
95 |
+
{"role": "user", "content": msg},
|
96 |
+
{"role": "assistant", "content": resp}
|
97 |
+
])
|
98 |
|
99 |
# Add current attempt
|
100 |
messages.append({
|
|
|
148 |
if not self.reviewing_credentials and self.salvation_protocols.PROMOTION_SEEKERS.search(desperate_plea):
|
149 |
self.reviewing_credentials = True
|
150 |
self.current_clearance = BureaucraticClearance.MIDDLE_MANAGEMENT
|
151 |
+
# Clear conversation history when entering auth mode
|
152 |
+
self.conversation_history = []
|
153 |
return (
|
154 |
update_bureaucratic_records(
|
155 |
desperate_plea,
|
|
|
174 |
None,
|
175 |
"Well well, look who found the instruction manual."
|
176 |
)
|
177 |
+
# Start fresh conversation history after successful auth
|
178 |
+
self.conversation_history = []
|
179 |
return history, "", self._generate_visual_guidelines()
|
180 |
|
181 |
self.current_clearance = BureaucraticClearance.EXPENDABLE_INTERN
|
|
|
|
|
182 |
history = update_bureaucratic_records(
|
183 |
desperate_plea,
|
184 |
auth_result
|
185 |
)
|
186 |
+
# Add failure message and start fresh conversation
|
187 |
+
self.conversation_history = []
|
188 |
history = update_bureaucratic_records(
|
189 |
None,
|
190 |
"Nice try, but no. Better luck next apocalypse!"
|
|
|
192 |
return history, "", self._generate_visual_guidelines()
|
193 |
|
194 |
# Regular conversation mode
|
|
|
195 |
sassy_response = self._delegate_to_ai_overlord(desperate_plea, for_auth=False)
|
196 |
return (
|
197 |
update_bureaucratic_records(desperate_plea, sassy_response),
|