fix2
This commit is contained in:
14
tasks.py
14
tasks.py
@@ -366,26 +366,38 @@ def preview_action_items_task(self, text_content):
|
||||
self.update_progress(10, 100, "Requesting Dify for action items...")
|
||||
api_key = app.config.get("DIFY_ACTION_EXTRACTOR_API_KEY")
|
||||
plain_text = re.sub(r'^(\s*\[.*?\])\s*', '', text_content, flags=re.MULTILINE)
|
||||
|
||||
if not plain_text.strip():
|
||||
return {'status': 'Success', 'items': []}
|
||||
|
||||
response = ask_dify(api_key, plain_text)
|
||||
answer_text = response.get("answer", "")
|
||||
self.update_progress(80, 100, "Parsing response...")
|
||||
|
||||
parsed_items = []
|
||||
try:
|
||||
# Find the JSON array within the response string
|
||||
match = re.search(r'\[.*\]', answer_text, re.DOTALL)
|
||||
if match:
|
||||
json_str = match.group(0)
|
||||
parsed_items = json.loads(json_str)
|
||||
|
||||
# Ensure it's a list, otherwise reset to empty
|
||||
if not isinstance(parsed_items, list):
|
||||
parsed_items = []
|
||||
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
# If parsing fails, leave it as an empty list
|
||||
parsed_items = []
|
||||
|
||||
self.update_progress(100, 100, "Action item preview generated.")
|
||||
return {'status': 'Success', 'parsed_items': parsed_items}
|
||||
return {'status': 'Success', 'items': parsed_items}
|
||||
except Exception as e:
|
||||
self.update_state(
|
||||
state='FAILURE',
|
||||
meta={'exc_type': type(e).__name__, 'exc_message': str(e)}
|
||||
)
|
||||
return {'status': 'Error', 'error': str(e)}
|
||||
|
||||
@celery.task(bind=True)
|
||||
def process_meeting_flow(self, meeting_id, target_language=None):
|
||||
|
Reference in New Issue
Block a user