Skip to content

Commit 915d49c

Browse files
authored
Structured output support (#1793)
1 parent 691b51f commit 915d49c

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/robusta/core/reporting/holmes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class HolmesIssueChatRequest(HolmesChatRequest):
4747
class ToolCallResult(BaseModel):
4848
tool_name: str
4949
description: str
50-
result: str
50+
result: Union[str, dict] # dict is for new structured output results and string to support old versions of holmes
5151

5252

5353
class HolmesResult(BaseModel):

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ def get_empty_file_object(block: EmptyFileBlock):
8989
@staticmethod
9090
def append_to_structured_data_tool_calls(tool_calls: List[ToolCallResult], structured_data) -> None:
9191
for tool_call in tool_calls:
92-
file_block = FileBlock(f"{tool_call.description}.txt", tool_call.result.encode())
92+
if isinstance(tool_call.result, str):
93+
result = tool_call.result.encode()
94+
elif isinstance(tool_call.result, dict):
95+
result = json.dumps(tool_call.result).encode()
96+
97+
file_block = FileBlock(f"{tool_call.description}.txt", result)
9398
file_block.zip()
9499
data_obj = ModelConversion.get_file_object(file_block)
95100
data_obj["metadata"] = {"description": tool_call.description, "tool_name": tool_call.tool_name}

0 commit comments

Comments
 (0)