Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -352,6 +352,7 @@ class OpenRouterLLM:
|
|
| 352 |
except Exception as e:
|
| 353 |
yield f"Streaming error: {str(e)}"
|
| 354 |
|
|
|
|
| 355 |
class UserSession:
|
| 356 |
def __init__(self):
|
| 357 |
self.current_user = None
|
|
@@ -390,12 +391,15 @@ class UserSession:
|
|
| 390 |
return self.welcome_message
|
| 391 |
|
| 392 |
def add_to_history(self, role, message):
|
|
|
|
| 393 |
self.conversation_history.append({"role": role, "content": message})
|
| 394 |
|
| 395 |
def get_conversation_history(self):
|
|
|
|
| 396 |
return self.conversation_history
|
| 397 |
|
| 398 |
def get_formatted_history(self):
|
|
|
|
| 399 |
formatted_history = ""
|
| 400 |
for entry in self.conversation_history:
|
| 401 |
role = "User" if entry["role"] == "user" else "Assistant"
|
|
@@ -524,7 +528,14 @@ def chatbot_interface():
|
|
| 524 |
# User registration section
|
| 525 |
registration_container = gr.Column(visible=True)
|
| 526 |
with registration_container:
|
| 527 |
-
gr.Markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 528 |
|
| 529 |
with gr.Row():
|
| 530 |
first_name = gr.Textbox(
|
|
@@ -543,7 +554,7 @@ def chatbot_interface():
|
|
| 543 |
with chatbot_container:
|
| 544 |
chat_interface = gr.ChatInterface(
|
| 545 |
fn=rag_memory_stream,
|
| 546 |
-
title="Chat with
|
| 547 |
fill_height=True,
|
| 548 |
)
|
| 549 |
|
|
|
|
| 352 |
except Exception as e:
|
| 353 |
yield f"Streaming error: {str(e)}"
|
| 354 |
|
| 355 |
+
|
| 356 |
class UserSession:
|
| 357 |
def __init__(self):
|
| 358 |
self.current_user = None
|
|
|
|
| 391 |
return self.welcome_message
|
| 392 |
|
| 393 |
def add_to_history(self, role, message):
|
| 394 |
+
"""Add a message to the conversation history"""
|
| 395 |
self.conversation_history.append({"role": role, "content": message})
|
| 396 |
|
| 397 |
def get_conversation_history(self):
|
| 398 |
+
"""Get the full conversation history"""
|
| 399 |
return self.conversation_history
|
| 400 |
|
| 401 |
def get_formatted_history(self):
|
| 402 |
+
"""Get conversation history formatted as a string for the LLM"""
|
| 403 |
formatted_history = ""
|
| 404 |
for entry in self.conversation_history:
|
| 405 |
role = "User" if entry["role"] == "user" else "Assistant"
|
|
|
|
| 528 |
# User registration section
|
| 529 |
registration_container = gr.Column(visible=True)
|
| 530 |
with registration_container:
|
| 531 |
+
gr.Markdown(
|
| 532 |
+
"""
|
| 533 |
+
<div style='font-size: 26px;'>
|
| 534 |
+
Your privacy is our concern, please provide your nickname.
|
| 535 |
+
</div>
|
| 536 |
+
"""
|
| 537 |
+
)
|
| 538 |
+
|
| 539 |
|
| 540 |
with gr.Row():
|
| 541 |
first_name = gr.Textbox(
|
|
|
|
| 554 |
with chatbot_container:
|
| 555 |
chat_interface = gr.ChatInterface(
|
| 556 |
fn=rag_memory_stream,
|
| 557 |
+
title="Chat with GBVR",
|
| 558 |
fill_height=True,
|
| 559 |
)
|
| 560 |
|