@@ -198,7 +198,7 @@ def _create_feedback_blocks(
198198 )
199199
200200 # Main body
201- blocks .append ({"type" : "section" , "text" : {"type" : "mrkdwn " , "text" : response_text }})
201+ blocks .append ({"type" : "section" , "text" : {"type" : "markdown " , "text" : response_text }})
202202
203203 # Citation action block
204204 if action_buttons :
@@ -211,7 +211,7 @@ def _create_feedback_blocks(
211211 )
212212
213213 # Feedback buttons
214- blocks .append ({"type" : "divider" })
214+ blocks .append ({"type" : "divider" , "block_id" : "feedback-divider" })
215215 blocks .append ({"type" : "context" , "elements" : [{"type" : "mrkdwn" , "text" : "Was this response helpful?" }]})
216216 blocks .append (
217217 {
@@ -411,7 +411,13 @@ def process_slack_message(event: Dict[str, Any], event_id: str, client: WebClien
411411 # Split out citation block if present
412412 # Citations are not returned in the object without using `$output_format_instructions$` which overrides the
413413 # system prompt. Instead, pull out and format the citations in the prompt manually
414- prompt_value_keys = ["source number" , "title" , "filename" , "reference text" , "link" ]
414+ prompt_value_keys = [
415+ "source number" ,
416+ "title" ,
417+ "link" ,
418+ "filename" ,
419+ "reference text" ,
420+ ]
415421 split = response_text .split ("------" ) # Citations are separated by ------
416422
417423 citations : list [dict [str , str ]] = []
@@ -608,28 +614,33 @@ def open_citation(channel: str, timestamp: str, message: Any, params: Dict[str,
608614 # Get Message
609615 try :
610616 # Get citation details
611- title = params .get ("title" , "No title available." )
612- body = params .get ("body" , "No citation text available." )
613- link = params .get ("link" , "" )
617+ title : str = params .get ("title" , "No title available." )
618+ body : str = params .get ("body" , "No citation text available." , "No source found " )
619+ link : str = params .get ("link" , "" )
614620
615621 blocks = message .get ("blocks" , [])
616622
617623 # Remove citation block (and divider), if it exists
618624 blocks = [block for block in blocks if block .get ("block_id" ) not in ["citation_block" , "citation_divider" ]]
619625
626+ # Add formatting
627+ title = f"## { title } " # Add title styling
628+ body = f"> { body .replace ("\n " , "\n > " )} " # And block quote section
629+ link = f"[link]({ link } )" # Make link clickable
630+
620631 # Add citation content before feedback block
621632 citation_block = {
622633 "type" : "section" ,
623634 "text" : {
624- "type" : "mrkdwn " ,
625- "text" : f"* { title } * \n \n { body } \n \n <{ link } |View Source>" if link else f"*{ title } *\n \n { body } " ,
635+ "type" : "markdown " ,
636+ "text" : f"{ title } \n \n { body } \n \n <{ link } |View Source>" if link else f"*{ title } *\n \n { body } " ,
626637 },
627638 "block_id" : "citation_block" ,
628639 }
629640
630641 # Find index of feedback block to insert before it
631642 feedback_block_index = next (
632- (i for i , block in enumerate (blocks ) if block .get ("block_id" ) == "feedback_block " ), len (blocks )
643+ (i for i , block in enumerate (blocks ) if block .get ("block_id" ) == "feedback-divider " ), len (blocks )
633644 )
634645 blocks .insert (feedback_block_index , {"type" : "divider" , "block_id" : "citation_divider" })
635646 blocks .insert (feedback_block_index , citation_block )
0 commit comments