Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -857,6 +857,21 @@ def get_topics_list() -> List[str]:
|
|
| 857 |
print(f"β Error retrieving topics: {str(e)}")
|
| 858 |
return ["All Topics"]
|
| 859 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 860 |
|
| 861 |
# Define custom CSS for the Gradio interface
|
| 862 |
custom_css = """
|
|
|
|
| 857 |
print(f"β Error retrieving topics: {str(e)}")
|
| 858 |
return ["All Topics"]
|
| 859 |
|
| 860 |
+
def send_message(user_input: str, topic_input: str) -> Tuple[str, str]:
|
| 861 |
+
"""Handle sending a user message and getting AI response."""
|
| 862 |
+
try:
|
| 863 |
+
if not user_input.strip():
|
| 864 |
+
return "β Please enter a message", user_input
|
| 865 |
+
if not topic_input.strip():
|
| 866 |
+
return "β Please enter a topic", user_input
|
| 867 |
+
|
| 868 |
+
response, error = groq_with_memory(user_input, topic_input)
|
| 869 |
+
if error:
|
| 870 |
+
return f"β {error}", user_input
|
| 871 |
+
return response, "" # Clear user input after successful submission
|
| 872 |
+
except Exception as e:
|
| 873 |
+
return f"β Error processing message: {str(e)}", user_input
|
| 874 |
+
|
| 875 |
|
| 876 |
# Define custom CSS for the Gradio interface
|
| 877 |
custom_css = """
|