Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26606,6 +26606,7 @@ components:
enum:
- csv
- jsonl
- jsonl_flat
title: LLMExportFormat
LLMIntegration:
type: string
Expand Down
2 changes: 1 addition & 1 deletion src/splunk_ao/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def records(
),
)

if export_format == LLMExportFormat.JSONL:
if export_format in (LLMExportFormat.JSONL, LLMExportFormat.JSONL_FLAT):
for line in response_iterator:
if line:
yield json.loads(line)
Expand Down
1 change: 1 addition & 0 deletions src/splunk_ao/resources/models/llm_export_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class LLMExportFormat(str, Enum):
CSV = "csv"
JSONL = "jsonl"
JSONL_FLAT = "jsonl_flat"

def __str__(self) -> str:
return str(self.value)
24 changes: 24 additions & 0 deletions tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,27 @@ def test_export_records_include_code_metric_metadata_opt_in(mock_export_records_
request_body = mock_export_records_stream.call_args.kwargs["body"]
assert request_body.include_code_metric_metadata is True
assert request_body.to_dict()["include_code_metric_metadata"] is True


@patch("splunk_ao.export.export_records_stream")
def test_export_records_jsonl_flat(mock_export_records_stream):
project_id = str(uuid4())
records = [{"id": "1", "type": "llm"}, {"id": "2", "type": "trace"}]
mock_export_records_stream.return_value = iter(json.dumps(r) for r in records)

result = list(
export_records(
project_id=project_id,
root_type=RootType.TRACE,
export_format=LLMExportFormat.JSONL_FLAT,
filters=[],
sort=LogRecordsSortClause(column_id="created_at", ascending=False),
log_stream_id=str(uuid4()),
)
)

assert len(result) == 2
assert result[0] == {"id": "1", "type": "llm"}
assert result[1] == {"id": "2", "type": "trace"}
request_body = mock_export_records_stream.call_args.kwargs["body"]
assert request_body.export_format == LLMExportFormat.JSONL_FLAT
Loading