Skip to content

Commit c76b63e

Browse files
author
潘婉宁
committed
feat: support json schema
1 parent 47bad6f commit c76b63e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
"httpx>=0.23.0, <1",
3030
"anyio>=3.5.0, <5",
3131
"cached-property; python_version < '3.8'",
32-
"cryptography>=43.0.3, <43.0.4",
33-
"jiter>=0.4.0, <1"
32+
"cryptography>=43.0.3, <43.0.4"
3433
]
3534
},
3635
)

volcenginesdkarkruntime/common/streaming/chat/_completions.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,20 @@
1414
)
1515
from typing_extensions import Self, Iterator, assert_never
1616

17-
from jiter import from_json
17+
try:
18+
from jiter import from_json
19+
except ImportError:
20+
import json
21+
from typing import Dict, Any
22+
23+
def from_json(json_str: bytes, partial_mode: bool) -> Dict[str, Any]:
24+
try:
25+
return json.loads(json_str)
26+
except json.JSONDecodeError as e:
27+
if partial_mode:
28+
return {}
29+
raise e
30+
1831

1932
from ._types import (
2033
ParsedChoiceSnapshot,

0 commit comments

Comments
 (0)