Update app.py
Browse files
app.py
CHANGED
@@ -119,8 +119,8 @@ def transcribe_audio(audio_file):
|
|
119 |
def improve_task_description(text):
|
120 |
"""Improve and summarize task description using SambaNova API"""
|
121 |
try:
|
122 |
-
prompt = f"""Please
|
123 |
-
|
124 |
Original task: {text}
|
125 |
|
126 |
Please provide:
|
@@ -128,6 +128,13 @@ Please provide:
|
|
128 |
2. Key objectives
|
129 |
3. Suggested deadline (if not specified)
|
130 |
4. Any important details or requirements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
"""
|
132 |
|
133 |
headers = {
|
@@ -155,8 +162,22 @@ Please provide:
|
|
155 |
if response.status_code != 200:
|
156 |
raise Exception(f"SambaNova API request failed: {response.text}")
|
157 |
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
except Exception as e:
|
161 |
raise Exception(f"Error improving task description: {str(e)}")
|
162 |
|
@@ -271,17 +292,19 @@ Add your progress notes here...
|
|
271 |
def process_input(input_text, selected_members):
|
272 |
"""Process input text and create Trello card"""
|
273 |
try:
|
274 |
-
# Improve the task description
|
275 |
-
improved_description = improve_task_description(input_text)
|
276 |
|
277 |
-
# Create Trello card
|
278 |
-
card_url = create_trello_card(improved_description, selected_members)
|
279 |
|
280 |
# Get member names for display
|
281 |
members_dict = get_trello_members()
|
282 |
member_names = [name for name, mid in members_dict.items()
|
283 |
if mid in selected_members]
|
284 |
|
|
|
|
|
285 |
return f"""
|
286 |
Original Input:
|
287 |
--------------
|
@@ -293,6 +316,7 @@ Improved Task Description:
|
|
293 |
|
294 |
Task Created in Trello:
|
295 |
----------------------
|
|
|
296 |
Assigned to: {', '.join(member_names) if member_names else 'Not assigned'}
|
297 |
Card URL: {card_url}
|
298 |
"""
|
|
|
119 |
def improve_task_description(text):
|
120 |
"""Improve and summarize task description using SambaNova API"""
|
121 |
try:
|
122 |
+
prompt = f"""Please analyze and structure this task description, including determining its urgency level.
|
123 |
+
|
124 |
Original task: {text}
|
125 |
|
126 |
Please provide:
|
|
|
128 |
2. Key objectives
|
129 |
3. Suggested deadline (if not specified)
|
130 |
4. Any important details or requirements
|
131 |
+
5. Urgency level assessment (choose one: normal, high, urgent) based on:
|
132 |
+
- Time-sensitive language (ASAP, immediately, urgent, etc.)
|
133 |
+
- Deadlines mentioned
|
134 |
+
- Impact and consequences described
|
135 |
+
- Business criticality
|
136 |
+
|
137 |
+
Format the response with "URGENCY_LEVEL: [level]" as the first line, followed by the structured description.
|
138 |
"""
|
139 |
|
140 |
headers = {
|
|
|
162 |
if response.status_code != 200:
|
163 |
raise Exception(f"SambaNova API request failed: {response.text}")
|
164 |
|
165 |
+
response_text = response.json()['choices'][0]['message']['content']
|
166 |
+
|
167 |
+
# Extract urgency level and description
|
168 |
+
lines = response_text.split('\n')
|
169 |
+
urgency_line = lines[0].strip()
|
170 |
+
urgency = "normal" # default
|
171 |
+
|
172 |
+
if urgency_line.startswith("URGENCY_LEVEL:"):
|
173 |
+
level = urgency_line.split(":")[1].strip().lower()
|
174 |
+
if level in ["normal", "high", "urgent"]:
|
175 |
+
urgency = level
|
176 |
+
description = '\n'.join(lines[1:]).strip()
|
177 |
+
else:
|
178 |
+
description = response_text
|
179 |
+
|
180 |
+
return description, urgency
|
181 |
except Exception as e:
|
182 |
raise Exception(f"Error improving task description: {str(e)}")
|
183 |
|
|
|
292 |
def process_input(input_text, selected_members):
|
293 |
"""Process input text and create Trello card"""
|
294 |
try:
|
295 |
+
# Improve the task description and get urgency
|
296 |
+
improved_description, urgency = improve_task_description(input_text)
|
297 |
|
298 |
+
# Create Trello card with detected urgency
|
299 |
+
card_url = create_trello_card(improved_description, selected_members, urgency=urgency)
|
300 |
|
301 |
# Get member names for display
|
302 |
members_dict = get_trello_members()
|
303 |
member_names = [name for name, mid in members_dict.items()
|
304 |
if mid in selected_members]
|
305 |
|
306 |
+
urgency_emoji = {"normal": "π", "high": "β οΈ", "urgent": "π΄"}
|
307 |
+
|
308 |
return f"""
|
309 |
Original Input:
|
310 |
--------------
|
|
|
316 |
|
317 |
Task Created in Trello:
|
318 |
----------------------
|
319 |
+
Priority: {urgency_emoji.get(urgency, "π")} {urgency.upper()}
|
320 |
Assigned to: {', '.join(member_names) if member_names else 'Not assigned'}
|
321 |
Card URL: {card_url}
|
322 |
"""
|