Skip to content

Commit 8c3290f

Browse files
committed
model_dump_json add exclude_none=True
1 parent 5ab6dfc commit 8c3290f

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

CHANGLOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.1.28] - 2026-04-10
2+
### Fixed
3+
- model_dump_json add exclude_none=True
4+
15
## [0.1.27] - 2026-03-18
26
### Fixed
37
- remove tiktoken

cozeloop/internal/trace/exporter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def convert_input(span_key: str, span: Span) -> (str, List[UploadFile]):
235235
if pydantic.VERSION.startswith('1'):
236236
value_res = model_input.json()
237237
else:
238-
value_res = model_input.model_dump_json()
238+
value_res = model_input.model_dump_json(exclude_none=True)
239239

240240
if len(value_res) > MAX_BYTES_OF_ONE_TAG_VALUE_OF_INPUT_OUTPUT:
241241
value_res, f = transfer_text(value_res, span, span_key)
@@ -275,7 +275,10 @@ def convert_output(span_key: str, span: Span) -> (str, List[UploadFile]):
275275
files = transfer_message_part(part, span, span_key)
276276
upload_files.extend(files)
277277

278-
value_res = model_output.to_json()
278+
if pydantic.VERSION.startswith('1'):
279+
value_res = model_output.json()
280+
else:
281+
value_res = model_output.model_dump_json(exclude_none=True)
279282

280283
if len(value) > MAX_BYTES_OF_ONE_TAG_VALUE_OF_INPUT_OUTPUT:
281284
value_res, f = transfer_text(value_res, span, span_key)

cozeloop/internal/utils/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def to_json(param: Any) -> str:
8080
if pydantic.VERSION.startswith('1'):
8181
return param.json()
8282
else:
83-
return param.model_dump_json()
83+
return param.model_dump_json(exclude_none=True)
8484
return json.dumps(param, ensure_ascii=False)
8585
except json.JSONDecodeError:
8686
return param.__str__()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cozeloop"
3-
version = "0.1.27"
3+
version = "0.1.28"
44
description = "coze loop sdk"
55
authors = ["JiangQi715 <jiangqi.rrt@bytedance.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)