Update space
Browse files
app.py
CHANGED
|
@@ -63,10 +63,13 @@ def extract_table(url):
|
|
| 63 |
<td>{row['Topic']}</td>
|
| 64 |
<td>
|
| 65 |
<button onclick='
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
| 70 |
'>
|
| 71 |
Prepare
|
| 72 |
</button>
|
|
@@ -94,29 +97,26 @@ def generate_response(history, system_message):
|
|
| 94 |
|
| 95 |
def prepare_topic_message(index):
|
| 96 |
try:
|
| 97 |
-
# Debug print
|
| 98 |
-
print(f"Received index: '{index}'")
|
| 99 |
|
| 100 |
-
#
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
| 103 |
return ""
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
date = data[index]["Date"]
|
| 109 |
message = f"Please prepare a 10-minute reading guide for the topic '{topic}' scheduled for {date}"
|
| 110 |
print(f"Generated message: {message}") # Debug print
|
| 111 |
return message
|
| 112 |
else:
|
| 113 |
-
print(f"Index {
|
| 114 |
return ""
|
| 115 |
-
except ValueError as e:
|
| 116 |
-
print(f"Error converting index: {e}")
|
| 117 |
-
return ""
|
| 118 |
except Exception as e:
|
| 119 |
-
print(f"
|
| 120 |
return ""
|
| 121 |
|
| 122 |
def clear_chat():
|
|
|
|
| 63 |
<td>{row['Topic']}</td>
|
| 64 |
<td>
|
| 65 |
<button onclick='
|
| 66 |
+
(function() {{
|
| 67 |
+
const indexInput = document.getElementById("prepare-index");
|
| 68 |
+
indexInput.value = {i};
|
| 69 |
+
const event = new Event("input", {{ bubbles: true }});
|
| 70 |
+
indexInput.dispatchEvent(event);
|
| 71 |
+
document.getElementById("prepare-trigger").click();
|
| 72 |
+
}})();
|
| 73 |
'>
|
| 74 |
Prepare
|
| 75 |
</button>
|
|
|
|
| 97 |
|
| 98 |
def prepare_topic_message(index):
|
| 99 |
try:
|
| 100 |
+
print(f"Received index: '{index}'") # Debug print
|
|
|
|
| 101 |
|
| 102 |
+
# Convert index to integer, handling both string and numeric inputs
|
| 103 |
+
try:
|
| 104 |
+
idx = int(float(index))
|
| 105 |
+
except (ValueError, TypeError):
|
| 106 |
+
print(f"Invalid index value: {index}")
|
| 107 |
return ""
|
| 108 |
+
|
| 109 |
+
if 0 <= idx < len(data):
|
| 110 |
+
topic = data[idx]["Topic"]
|
| 111 |
+
date = data[idx]["Date"]
|
|
|
|
| 112 |
message = f"Please prepare a 10-minute reading guide for the topic '{topic}' scheduled for {date}"
|
| 113 |
print(f"Generated message: {message}") # Debug print
|
| 114 |
return message
|
| 115 |
else:
|
| 116 |
+
print(f"Index {idx} out of range")
|
| 117 |
return ""
|
|
|
|
|
|
|
|
|
|
| 118 |
except Exception as e:
|
| 119 |
+
print(f"Error in prepare_topic_message: {e}")
|
| 120 |
return ""
|
| 121 |
|
| 122 |
def clear_chat():
|