Skip to content

Commit 282abd6

Browse files
authored
fix: do not bolden Holmes result (#1958)
1 parent 5d38f08 commit 282abd6

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/robusta/core/sinks/robusta/dal/model_conversion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def add_ai_chat_data(structured_data: List[Dict], block: HolmesChatResultsBlock)
123123
{
124124
"type": "markdown",
125125
"metadata": metadata,
126-
"data": Transformer.to_github_markdown(block.holmes_result.analysis),
126+
"data": Transformer.to_github_markdown(block.holmes_result.analysis, single_asterisks_is_bold=False),
127127
}
128128
)
129129
ModelConversion.append_to_structured_files(block.holmes_result.files, structured_data)
@@ -146,15 +146,15 @@ def add_ai_analysis_data(structured_data: List[Dict], block: HolmesResultsBlock)
146146
{
147147
"type": "markdown",
148148
"metadata": {"type": "ai_investigation_result"},
149-
"data": Transformer.to_github_markdown(block.holmes_result.analysis),
149+
"data": Transformer.to_github_markdown(block.holmes_result.analysis, single_asterisks_is_bold=False),
150150
}
151151
)
152152
ModelConversion.append_to_structured_data_tool_calls(block.holmes_result.tool_calls, structured_data)
153153
if block.holmes_result.sections and len(block.holmes_result.sections) > 0:
154154
transformed_sections = {}
155155
for section_title, section_content in block.holmes_result.sections.items():
156156
if section_content:
157-
transformed_sections[section_title] = Transformer.to_github_markdown(section_content)
157+
transformed_sections[section_title] = Transformer.to_github_markdown(section_content, single_asterisks_is_bold=False)
158158

159159
structured_data.append(
160160
{

src/robusta/core/sinks/transformer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def get_markdown_links(markdown_data: str) -> List[str]:
112112
return links
113113

114114
@staticmethod
115-
def to_github_markdown(markdown_data: str, add_angular_brackets: bool = True) -> str:
115+
def to_github_markdown(markdown_data: str, add_angular_brackets: bool = True, single_asterisks_is_bold: bool = True) -> str:
116116
"""Transform all occurrences of slack markdown, <URL|LINK TEXT>, to github markdown [LINK TEXT](URL)."""
117117
# some markdown parsers doesn't support angular brackets on links
118118
OPENING_ANGULAR = "<" if add_angular_brackets else ""
@@ -126,7 +126,11 @@ def to_github_markdown(markdown_data: str, add_angular_brackets: bool = True) ->
126126
parsed_url = parsed_url._replace(path=urllib.parse.quote_plus(parsed_url.path, safe="/"))
127127
replacement = f"[{splits[1]}]({OPENING_ANGULAR}{parsed_url.geturl()}{CLOSING_ANGULAR})"
128128
markdown_data = markdown_data.replace(match, replacement)
129-
return re.sub(r"\*([^\*]*)\*", r"**\1**", markdown_data)
129+
130+
if single_asterisks_is_bold:
131+
return re.sub(r"\*([^\*]*)\*", r"**\1**", markdown_data)
132+
else:
133+
return markdown_data
130134

131135
@classmethod
132136
def __markdown_to_html(cls, mrkdwn_text: str, html_class: str = None) -> str:

0 commit comments

Comments
 (0)