@@ -407,16 +407,17 @@ def process_slack_message(event: Dict[str, Any], event_id: str, client: WebClien
407407 # system prompt. Instead, pull out and format the citations in the prompt manually
408408 prompt_value_keys = ["source number" , "title" , "filename" , "reference text" , "link" ]
409409 split = response_text .split ("------" ) # Citations are separated by ------
410- citations = []
410+
411+ citations : list [dict [str , str ]] = []
411412 if len (split ) != 1 :
412413 response_text = split [0 ]
413414 citation_block = split [1 ]
414-
415- citations = re .compile (r"<cit\b[^>]*>(.*?)</cit>" , re .DOTALL | re .IGNORECASE ).findall (citation_block )
416- if len (citations ) > 0 :
417- logger .info ("Found citation(s)" , extra = {"Citations" : citations })
418- citation_dict = [dict (zip (prompt_value_keys , citation .split ("|" ))) for citation in citations ]
419- logger .info ("Parsed citation(s)" , extra = {"CitationsDict " : citation_dict })
415+ raw_citations = []
416+ raw_citations = re .compile (r"<cit\b[^>]*>(.*?)</cit>" , re .DOTALL | re .IGNORECASE ).findall (citation_block )
417+ if len (raw_citations ) > 0 :
418+ logger .info ("Found citation(s)" , extra = {"Raw Citations" : raw_citations })
419+ citations = [dict (zip (prompt_value_keys , citation .split ("|" ))) for citation in raw_citations ]
420+ logger .info ("Parsed citation(s)" , extra = {"citations " : citations })
420421
421422 # Post the answer (plain) to get message_ts
422423 post_params = {"channel" : channel , "text" : response_text }
@@ -439,7 +440,7 @@ def process_slack_message(event: Dict[str, Any], event_id: str, client: WebClien
439440 # Store Q&A pair for feedback correlation
440441 store_qa_pair (conversation_key , user_query , response_text , message_ts , kb_response .get ("sessionId" ), user_id )
441442
442- blocks = _create_feedback_blocks (response_text , citations , conversation_key , channel , message_ts , thread_ts )
443+ blocks = _create_feedback_blocks (response_text , raw_citations , conversation_key , channel , message_ts , thread_ts )
443444 try :
444445 client .chat_update (channel = channel , ts = message_ts , text = response_text , blocks = blocks )
445446 except Exception as e :
0 commit comments