Spaces:
Running
Running
Johnny Lee
commited on
Commit
·
dd9b964
1
Parent(s):
98f6c30
quick fix
Browse files
app.py
CHANGED
@@ -162,6 +162,15 @@ class PollQuestions(BaseModel): # type: ignore[misc]
|
|
162 |
poll_questions = PollQuestions.from_json_file("templates.json")
|
163 |
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
def reset_textbox():
|
166 |
return (None,) * 3
|
167 |
|
@@ -234,7 +243,6 @@ class ChatSession(BaseModel):
|
|
234 |
Current date: {current_date}
|
235 |
"""
|
236 |
else:
|
237 |
-
knowledge_cutoff = "Early 2023"
|
238 |
system_msg = (
|
239 |
f"""Knowledge cutoff: {knowledge_cutoff}
|
240 |
Current date: {current_date}
|
@@ -398,6 +406,9 @@ async def respond(
|
|
398 |
return user_msg, memory_buffer
|
399 |
|
400 |
try:
|
|
|
|
|
|
|
401 |
if state is None:
|
402 |
if chatbot_mode == ChatbotMode.DEBATE_PARTNER:
|
403 |
new_session = ChatSession.new(
|
@@ -599,7 +610,7 @@ with gr.Blocks(
|
|
599 |
with gr.Tab("Chatbot"):
|
600 |
with gr.Row():
|
601 |
chatbot_mode = gr.Radio(
|
602 |
-
label="Mode",
|
603 |
choices=config.chatbot_modes,
|
604 |
value=ChatbotMode.DEFAULT,
|
605 |
)
|
|
|
162 |
poll_questions = PollQuestions.from_json_file("templates.json")
|
163 |
|
164 |
|
165 |
+
def logout(request: gr.Request):
|
166 |
+
cookies = ["access-token-unsecure", "access-token"]
|
167 |
+
for cookie in cookies:
|
168 |
+
if request.cookies.get(cookie):
|
169 |
+
request.cookies.clear()
|
170 |
+
del request.cookies[cookie]
|
171 |
+
LOG.warning(f"Deleted cookie for {request.request}")
|
172 |
+
|
173 |
+
|
174 |
def reset_textbox():
|
175 |
return (None,) * 3
|
176 |
|
|
|
243 |
Current date: {current_date}
|
244 |
"""
|
245 |
else:
|
|
|
246 |
system_msg = (
|
247 |
f"""Knowledge cutoff: {knowledge_cutoff}
|
248 |
Current date: {current_date}
|
|
|
406 |
return user_msg, memory_buffer
|
407 |
|
408 |
try:
|
409 |
+
if request.username is None:
|
410 |
+
logout(request)
|
411 |
+
raise RuntimeError(f"Username not found for request: {request.request}")
|
412 |
if state is None:
|
413 |
if chatbot_mode == ChatbotMode.DEBATE_PARTNER:
|
414 |
new_session = ChatSession.new(
|
|
|
610 |
with gr.Tab("Chatbot"):
|
611 |
with gr.Row():
|
612 |
chatbot_mode = gr.Radio(
|
613 |
+
label="Mode (Please use Debate Parter for AI Dialogue Assignments)",
|
614 |
choices=config.chatbot_modes,
|
615 |
value=ChatbotMode.DEFAULT,
|
616 |
)
|