Update space
Browse files
app.py
CHANGED
@@ -92,12 +92,25 @@ def generate_response(history, system_message):
|
|
92 |
|
93 |
def prepare_topic_message(index):
|
94 |
try:
|
|
|
|
|
|
|
|
|
95 |
index = int(index)
|
96 |
if 0 <= index < len(data):
|
97 |
topic = data[index]["Topic"]
|
98 |
date = data[index]["Date"]
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
return ""
|
102 |
|
103 |
def clear_chat():
|
@@ -142,16 +155,10 @@ with gr.Blocks() as demo:
|
|
142 |
fn=prepare_topic_message,
|
143 |
inputs=[prepare_index],
|
144 |
outputs=[msg]
|
145 |
-
)
|
146 |
-
|
147 |
-
# Submit button handler for prepare trigger
|
148 |
-
prepare_trigger.click(
|
149 |
fn=add_text,
|
150 |
inputs=[chatbot, msg],
|
151 |
outputs=[chatbot]
|
152 |
-
).success(
|
153 |
-
fn=lambda: "",
|
154 |
-
outputs=[msg]
|
155 |
).then(
|
156 |
fn=generate_response,
|
157 |
inputs=[chatbot, system_message],
|
|
|
92 |
|
93 |
def prepare_topic_message(index):
|
94 |
try:
|
95 |
+
# Print for debugging
|
96 |
+
print(f"Received index: {index}")
|
97 |
+
print(f"Current data: {data}")
|
98 |
+
|
99 |
index = int(index)
|
100 |
if 0 <= index < len(data):
|
101 |
topic = data[index]["Topic"]
|
102 |
date = data[index]["Date"]
|
103 |
+
message = f"Please prepare a 10-minute reading guide for the topic '{topic}' scheduled for {date}"
|
104 |
+
|
105 |
+
# Print the generated message for debugging
|
106 |
+
print(f"Generated message: {message}")
|
107 |
+
|
108 |
+
return message
|
109 |
+
else:
|
110 |
+
print(f"Index {index} out of range")
|
111 |
+
return ""
|
112 |
+
except Exception as e:
|
113 |
+
print(f"Error in prepare_topic_message: {e}")
|
114 |
return ""
|
115 |
|
116 |
def clear_chat():
|
|
|
155 |
fn=prepare_topic_message,
|
156 |
inputs=[prepare_index],
|
157 |
outputs=[msg]
|
158 |
+
).then(
|
|
|
|
|
|
|
159 |
fn=add_text,
|
160 |
inputs=[chatbot, msg],
|
161 |
outputs=[chatbot]
|
|
|
|
|
|
|
162 |
).then(
|
163 |
fn=generate_response,
|
164 |
inputs=[chatbot, system_message],
|