Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -116,14 +116,26 @@ def responsenew(data):
|
|
116 |
}
|
117 |
|
118 |
elif "add to do" in text:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
respo = {
|
120 |
'message': "Todo added!",
|
121 |
'action': "create_todo",
|
122 |
'function': {
|
123 |
-
'name':
|
124 |
'id': idval,
|
125 |
'subTasks': [{
|
126 |
-
'task':
|
127 |
'done': False
|
128 |
}],
|
129 |
'shared': [],
|
|
|
116 |
}
|
117 |
|
118 |
elif "add to do" in text:
|
119 |
+
replaced_string = text.replace("add todo", "").replace("add to do","")
|
120 |
+
# 1. Replace "note down" with an empty string:
|
121 |
+
replaced_string = text.replace("note down", "")
|
122 |
+
|
123 |
+
# 2. Split the string into words:
|
124 |
+
words = replaced_string.split()
|
125 |
+
|
126 |
+
# 3. Extract the first two words:
|
127 |
+
first_two_words = words[:2] # Get the first two elements of the list
|
128 |
+
|
129 |
+
# 4. Join the words back into a string (if needed):
|
130 |
+
result_string = " ".join(first_two_words)
|
131 |
respo = {
|
132 |
'message': "Todo added!",
|
133 |
'action': "create_todo",
|
134 |
'function': {
|
135 |
+
'name': result_string,
|
136 |
'id': idval,
|
137 |
'subTasks': [{
|
138 |
+
'task':replaced_string,
|
139 |
'done': False
|
140 |
}],
|
141 |
'shared': [],
|