Skip to content

Commit f2d7a55

Browse files
etserendclaude
andcommitted
feat(export): add JSONL_FLAT export format (HYBIM-788)
Port upstream commit 6ccd06a from rungalileo/galileo-python (PR #621). Adds LLMExportFormat.JSONL_FLAT enum value and treats it identically to JSONL in the streaming decode path so callers can request flattened output. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 91f72dd commit f2d7a55

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

openapi.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26606,6 +26606,7 @@ components:
2660626606
enum:
2660726607
- csv
2660826608
- jsonl
26609+
- jsonl_flat
2660926610
title: LLMExportFormat
2661026611
LLMIntegration:
2661126612
type: string

src/splunk_ao/export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def records(
6161
),
6262
)
6363

64-
if export_format == LLMExportFormat.JSONL:
64+
if export_format in (LLMExportFormat.JSONL, LLMExportFormat.JSONL_FLAT):
6565
for line in response_iterator:
6666
if line:
6767
yield json.loads(line)

src/splunk_ao/resources/models/llm_export_format.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
class LLMExportFormat(str, Enum):
55
CSV = "csv"
66
JSONL = "jsonl"
7+
JSONL_FLAT = "jsonl_flat"
78

89
def __str__(self) -> str:
910
return str(self.value)

tests/test_export.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,27 @@ def test_export_records_include_code_metric_metadata_opt_in(mock_export_records_
296296
request_body = mock_export_records_stream.call_args.kwargs["body"]
297297
assert request_body.include_code_metric_metadata is True
298298
assert request_body.to_dict()["include_code_metric_metadata"] is True
299+
300+
301+
@patch("splunk_ao.export.export_records_stream")
302+
def test_export_records_jsonl_flat(mock_export_records_stream):
303+
project_id = str(uuid4())
304+
records = [{"id": "1", "type": "llm"}, {"id": "2", "type": "trace"}]
305+
mock_export_records_stream.return_value = iter(json.dumps(r) for r in records)
306+
307+
result = list(
308+
export_records(
309+
project_id=project_id,
310+
root_type=RootType.TRACE,
311+
export_format=LLMExportFormat.JSONL_FLAT,
312+
filters=[],
313+
sort=LogRecordsSortClause(column_id="created_at", ascending=False),
314+
log_stream_id=str(uuid4()),
315+
)
316+
)
317+
318+
assert len(result) == 2
319+
assert result[0] == {"id": "1", "type": "llm"}
320+
assert result[1] == {"id": "2", "type": "trace"}
321+
request_body = mock_export_records_stream.call_args.kwargs["body"]
322+
assert request_body.export_format == LLMExportFormat.JSONL_FLAT

0 commit comments

Comments
 (0)