Debian Codegraph @

debian/patches/0001-make-jiter-optional.patch

raw
1 From: =?utf-8?q?Antoine_Beaupr=C3=A9?= <[email protected]>
2 Date: Tue, 6 Jan 2026 14:12:20 -0500
3 Subject: make jiter optional
4
5 ---
6 src/anthropic/lib/streaming/_beta_messages.py | 5 ++++-
7 src/anthropic/lib/streaming/_beta_types.py | 7 +++++--
8 src/anthropic/lib/streaming/_messages.py | 5 ++++-
9 3 files changed, 13 insertions(+), 4 deletions(-)
10
11 Index: b/src/anthropic/lib/streaming/_beta_messages.py
12 ===================================================================
13 --- a/src/anthropic/lib/streaming/_beta_messages.py 2026-09-25 22:16:42.322730367 -0400
14 +++ b/src/anthropic/lib/streaming/_beta_messages.py 2026-09-25 22:16:42.314730365 -0400
15 @@ -502,7 +502,10 @@ def accumulate_event(
16 content.text += event.delta.text
17 elif event.delta.type == "input_json_delta":
18 if isinstance(content, TRACKS_TOOL_INPUT):
19 - from jiter import from_json
20 + try:
21 + from jiter import from_json
22 + except ImportError:
23 + from pydantic_core import from_json
24
25 json_buf = json_bufs.get(event.index, b"")
26 json_buf += bytes(event.delta.partial_json, "utf-8")
27 Index: b/src/anthropic/lib/streaming/_beta_types.py
28 ===================================================================
29 --- a/src/anthropic/lib/streaming/_beta_types.py 2026-09-25 22:16:42.322730367 -0400
30 +++ b/src/anthropic/lib/streaming/_beta_types.py 2026-09-25 22:16:42.314730365 -0400
31 @@ -1,7 +1,10 @@
32 from typing import TYPE_CHECKING, Any, Dict, Union, Generic, cast
33 from typing_extensions import List, Literal, Annotated
34
35 -import jiter
36 +try:
37 + from jiter import from_json
38 +except ImportError:
39 + from pydantic_core import from_json
40
41 from ..._models import BaseModel, GenericModel, UnionDiscriminator
42 from ...types.beta import (
43 @@ -27,7 +30,7 @@ class ParsedBetaTextEvent(BaseModel):
44 """The entire accumulated text"""
45
46 def parsed_snapshot(self) -> Dict[str, Any]:
47 - return cast(Dict[str, Any], jiter.from_json(self.snapshot.encode("utf-8"), partial_mode="trailing-strings"))
48 + return cast(Dict[str, Any], from_json(self.snapshot.encode("utf-8"), partial_mode="trailing-strings"))
49
50
51 class BetaCitationEvent(BaseModel):
52 Index: b/src/anthropic/lib/streaming/_messages.py
53 ===================================================================
54 --- a/src/anthropic/lib/streaming/_messages.py 2026-09-25 22:16:42.322730367 -0400
55 +++ b/src/anthropic/lib/streaming/_messages.py 2026-09-25 22:16:42.314730365 -0400
56 @@ -477,7 +477,10 @@ def accumulate_event(
57 content.text += event.delta.text
58 elif event.delta.type == "input_json_delta":
59 if isinstance(content, TRACKS_TOOL_INPUT):
60 - from jiter import from_json
61 + try:
62 + from jiter import from_json
63 + except ImportError:
64 + from pydantic_core import from_json
65
66 json_buf = json_bufs.get(event.index, b"")
67 json_buf += bytes(event.delta.partial_json, "utf-8")
68 Index: b/src/anthropic/lib/streaming/_types.py
69 ===================================================================
70 --- a/src/anthropic/lib/streaming/_types.py 2026-09-25 22:16:42.322730367 -0400
71 +++ b/src/anthropic/lib/streaming/_types.py 2026-09-25 22:16:42.314730365 -0400
72 @@ -1,7 +1,10 @@
73 from typing import TYPE_CHECKING, Any, Dict, Union, Generic, cast
74 from typing_extensions import List, Literal, Annotated
75
76 -import jiter
77 +try:
78 + from jiter import from_json
79 +except ImportError:
80 + from pydantic_core import from_json
81
82 from ...types import (
83 Message,