Skip to content

Commit 3fb6744

Browse files
committed
test
1 parent c115f8f commit 3fb6744

File tree

15 files changed

+38
-38
lines changed

15 files changed

+38
-38
lines changed

weave/integrations/anthropic/anthropic_sdk.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import weave
99
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
1010
from weave.trace.autopatch import IntegrationSettings, OpSettings
11-
from weave.trace.op import _IteratorWrapper, add_accumulator
11+
from weave.trace.op import _add_accumulator, _IteratorWrapper
1212

1313
if TYPE_CHECKING:
1414
from anthropic.lib.streaming import MessageStream
@@ -77,7 +77,7 @@ def wrapper(fn: Callable) -> Callable:
7777
"We need to do this so we can check if `stream` is used"
7878
op_kwargs = settings.model_dump()
7979
op = weave.op(fn, **op_kwargs)
80-
return add_accumulator(
80+
return _add_accumulator(
8181
op, # type: ignore
8282
make_accumulator=lambda inputs: anthropic_accumulator,
8383
should_accumulate=should_use_accumulator,
@@ -101,7 +101,7 @@ async def _async_wrapper(*args: Any, **kwargs: Any) -> Any:
101101
"We need to do this so we can check if `stream` is used"
102102
op_kwargs = settings.model_dump()
103103
op = weave.op(_fn_wrapper(fn), **op_kwargs)
104-
return add_accumulator(
104+
return _add_accumulator(
105105
op, # type: ignore
106106
make_accumulator=lambda inputs: anthropic_accumulator,
107107
should_accumulate=should_use_accumulator,
@@ -170,7 +170,7 @@ def create_stream_wrapper(settings: OpSettings) -> Callable[[Callable], Callable
170170
def wrapper(fn: Callable) -> Callable:
171171
op_kwargs = settings.model_dump()
172172
op = weave.op(fn, **op_kwargs)
173-
return add_accumulator(
173+
return _add_accumulator(
174174
op, # type: ignore
175175
make_accumulator=lambda _: anthropic_stream_accumulator,
176176
should_accumulate=lambda _: True,

weave/integrations/bedrock/bedrock_sdk.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import TYPE_CHECKING, Any, Callable, Optional
22

33
import weave
4-
from weave.trace.op import _IteratorWrapper, add_accumulator
4+
from weave.trace.op import _add_accumulator, _IteratorWrapper
55
from weave.trace.weave_client import Call
66

77
if TYPE_CHECKING:
@@ -133,7 +133,7 @@ def get(self, key: str, default: Any = None) -> Any:
133133
)
134134
return self
135135

136-
return add_accumulator(
136+
return _add_accumulator(
137137
op,
138138
make_accumulator=lambda _: bedrock_stream_accumulator,
139139
should_accumulate=lambda _: True,

weave/integrations/cohere/cohere_sdk.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import weave
88
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
99
from weave.trace.autopatch import IntegrationSettings, OpSettings
10-
from weave.trace.op import add_accumulator
10+
from weave.trace.op import _add_accumulator
1111

1212
if TYPE_CHECKING:
1313
from cohere.types.non_streamed_chat_response import NonStreamedChatResponse
@@ -167,7 +167,7 @@ def cohere_stream_wrapper(settings: OpSettings) -> Callable:
167167
def wrapper(fn: Callable) -> Callable:
168168
op_kwargs = settings.model_dump()
169169
op = weave.op(fn, **op_kwargs)
170-
return add_accumulator(op, lambda inputs: cohere_accumulator)
170+
return _add_accumulator(op, lambda inputs: cohere_accumulator)
171171

172172
return wrapper
173173

@@ -176,7 +176,7 @@ def cohere_stream_wrapper_v2(settings: OpSettings) -> Callable:
176176
def wrapper(fn: Callable) -> Callable:
177177
op_kwargs = settings.model_dump()
178178
op = weave.op(fn, **op_kwargs)
179-
return add_accumulator(op, lambda inputs: cohere_accumulator_v2)
179+
return _add_accumulator(op, lambda inputs: cohere_accumulator_v2)
180180

181181
return wrapper
182182

weave/integrations/google_ai_studio/google_ai_studio_sdk.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import weave
88
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
99
from weave.trace.autopatch import IntegrationSettings, OpSettings
10-
from weave.trace.op import add_accumulator
10+
from weave.trace.op import _add_accumulator
1111
from weave.trace.serialization.serialize import dictify
1212
from weave.trace.weave_client import Call
1313

@@ -100,7 +100,7 @@ def wrapper(fn: Callable) -> Callable:
100100

101101
op = weave.op(fn, **op_kwargs)
102102
op._set_on_finish_handler(gemini_on_finish)
103-
return add_accumulator(
103+
return _add_accumulator(
104104
op, # type: ignore
105105
make_accumulator=lambda inputs: gemini_accumulator,
106106
should_accumulate=lambda inputs: isinstance(inputs, dict)
@@ -125,7 +125,7 @@ async def _async_wrapper(*args: Any, **kwargs: Any) -> Any:
125125

126126
op = weave.op(_fn_wrapper(fn), **op_kwargs)
127127
op._set_on_finish_handler(gemini_on_finish)
128-
return add_accumulator(
128+
return _add_accumulator(
129129
op, # type: ignore
130130
make_accumulator=lambda inputs: gemini_accumulator,
131131
should_accumulate=lambda inputs: isinstance(inputs, dict)

weave/integrations/groq/groq_sdk.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import weave
77
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
88
from weave.trace.autopatch import IntegrationSettings, OpSettings
9-
from weave.trace.op import add_accumulator
9+
from weave.trace.op import _add_accumulator
1010

1111
if TYPE_CHECKING:
1212
from groq.types.chat import ChatCompletion, ChatCompletionChunk
@@ -93,7 +93,7 @@ def groq_wrapper(settings: OpSettings) -> Callable[[Callable], Callable]:
9393
def wrapper(fn: Callable) -> Callable:
9494
op_kwargs = settings.model_dump()
9595
op = weave.op(fn, **op_kwargs)
96-
return add_accumulator(
96+
return _add_accumulator(
9797
op, # type: ignore
9898
make_accumulator=lambda inputs: groq_accumulator,
9999
should_accumulate=should_use_accumulator,

weave/integrations/huggingface/huggingface_inference_client_sdk.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import weave
66
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
77
from weave.trace.autopatch import IntegrationSettings, OpSettings
8-
from weave.trace.op import add_accumulator
8+
from weave.trace.op import _add_accumulator
99
from weave.trace.serialization.serialize import dictify
1010

1111
if TYPE_CHECKING:
@@ -79,7 +79,7 @@ def wrapper(fn: Callable) -> Callable:
7979
op_kwargs["postprocess_inputs"] = huggingface_postprocess_inputs
8080

8181
op = weave.op(fn, **op_kwargs)
82-
return add_accumulator(
82+
return _add_accumulator(
8383
op, # type: ignore
8484
make_accumulator=lambda inputs: huggingface_accumulator,
8585
should_accumulate=lambda inputs: isinstance(inputs, dict)
@@ -103,7 +103,7 @@ async def _async_wrapper(*args: Any, **kwargs: Any) -> Any:
103103
op_kwargs["postprocess_inputs"] = huggingface_postprocess_inputs
104104

105105
op = weave.op(_fn_wrapper(fn), **op_kwargs)
106-
return add_accumulator(
106+
return _add_accumulator(
107107
op, # type: ignore
108108
make_accumulator=lambda inputs: huggingface_accumulator,
109109
should_accumulate=lambda inputs: isinstance(inputs, dict)

weave/integrations/instructor/instructor_iterable_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import weave
77
from weave.trace.autopatch import OpSettings
8-
from weave.trace.op import add_accumulator
8+
from weave.trace.op import _add_accumulator
99

1010

1111
def instructor_iterable_accumulator(
@@ -32,7 +32,7 @@ def instructor_wrapper_sync(settings: OpSettings) -> Callable[[Callable], Callab
3232
def wrapper(fn: Callable) -> Callable:
3333
op_kwargs = settings.model_dump()
3434
op = weave.op(fn, **op_kwargs)
35-
return add_accumulator(
35+
return _add_accumulator(
3636
op, # type: ignore
3737
make_accumulator=lambda inputs: instructor_iterable_accumulator,
3838
should_accumulate=should_accumulate_iterable,
@@ -52,7 +52,7 @@ async def _async_wrapper(*args: Any, **kwargs: Any) -> Any:
5252

5353
op_kwargs = settings.model_dump()
5454
op = weave.op(_fn_wrapper(fn), **op_kwargs)
55-
return add_accumulator(
55+
return _add_accumulator(
5656
op, # type: ignore
5757
make_accumulator=lambda inputs: instructor_iterable_accumulator,
5858
should_accumulate=should_accumulate_iterable,

weave/integrations/instructor/instructor_partial_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import weave
66
from weave.trace.autopatch import OpSettings
7-
from weave.trace.op import add_accumulator
7+
from weave.trace.op import _add_accumulator
88

99

1010
def instructor_partial_accumulator(
@@ -19,7 +19,7 @@ def instructor_wrapper_partial(settings: OpSettings) -> Callable[[Callable], Cal
1919
def wrapper(fn: Callable) -> Callable:
2020
op_kwargs = settings.model_dump()
2121
op = weave.op(fn, **op_kwargs)
22-
return add_accumulator(
22+
return _add_accumulator(
2323
op, # type: ignore
2424
make_accumulator=lambda inputs: instructor_partial_accumulator,
2525
should_accumulate=lambda inputs: True,

weave/integrations/langchain_nvidia_ai_endpoints/langchain_nv_ai_endpoints.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import weave
1515
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
1616
from weave.trace.autopatch import IntegrationSettings, OpSettings
17-
from weave.trace.op import Op, ProcessedInputs, add_accumulator
17+
from weave.trace.op import Op, ProcessedInputs, _add_accumulator
1818

1919
_lc_nvidia_patcher: MultiPatcher | None = None
2020

@@ -161,7 +161,7 @@ def wrapper(fn: Callable) -> Callable:
161161
op_kwargs = settings.model_dump()
162162
op = weave.op(fn, **op_kwargs)
163163
op._set_on_input_handler(postprocess_inputs_to_openai_format)
164-
return add_accumulator(
164+
return _add_accumulator(
165165
op,
166166
make_accumulator=lambda inputs: nvidia_accumulator,
167167
should_accumulate=should_use_accumulator,

weave/integrations/litellm/litellm.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import weave
77
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
88
from weave.trace.autopatch import IntegrationSettings, OpSettings
9-
from weave.trace.op import add_accumulator
9+
from weave.trace.op import _add_accumulator
1010

1111
if TYPE_CHECKING:
1212
from litellm.utils import ModelResponse
@@ -91,7 +91,7 @@ def make_wrapper(settings: OpSettings) -> Callable:
9191
def litellm_wrapper(fn: Callable) -> Callable:
9292
op_kwargs = settings.model_dump()
9393
op = weave.op(fn, **op_kwargs)
94-
return add_accumulator(
94+
return _add_accumulator(
9595
op, # type: ignore
9696
make_accumulator=lambda inputs: litellm_accumulator,
9797
should_accumulate=should_use_accumulator,

weave/integrations/mistral/v0/mistral.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import weave
77
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
88
from weave.trace.autopatch import IntegrationSettings, OpSettings
9-
from weave.trace.op import add_accumulator
9+
from weave.trace.op import _add_accumulator
1010

1111
if TYPE_CHECKING:
1212
from mistralai.models.chat_completion import (
@@ -81,7 +81,7 @@ def mistral_stream_wrapper(settings: OpSettings) -> Callable:
8181
def wrapper(fn: Callable) -> Callable:
8282
op_kwargs = settings.model_dump()
8383
op = weave.op(fn, **op_kwargs)
84-
acc_op = add_accumulator(op, lambda inputs: mistral_accumulator) # type: ignore
84+
acc_op = _add_accumulator(op, lambda inputs: mistral_accumulator) # type: ignore
8585
return acc_op
8686

8787
return wrapper

weave/integrations/mistral/v1/mistral.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import weave
77
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
88
from weave.trace.autopatch import IntegrationSettings, OpSettings
9-
from weave.trace.op import add_accumulator
9+
from weave.trace.op import _add_accumulator
1010

1111
if TYPE_CHECKING:
1212
from mistralai.models import (
@@ -88,7 +88,7 @@ def mistral_stream_wrapper(settings: OpSettings) -> Callable:
8888
def wrapper(fn: Callable) -> Callable:
8989
op_kwargs = settings.model_dump()
9090
op = weave.op(fn, **op_kwargs)
91-
acc_op = add_accumulator(op, lambda inputs: mistral_accumulator) # type: ignore
91+
acc_op = _add_accumulator(op, lambda inputs: mistral_accumulator) # type: ignore
9292
return acc_op
9393

9494
return wrapper

weave/integrations/openai/openai_sdk.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import weave
88
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
99
from weave.trace.autopatch import IntegrationSettings, OpSettings
10-
from weave.trace.op import Op, ProcessedInputs, add_accumulator
10+
from weave.trace.op import Op, ProcessedInputs, _add_accumulator
1111

1212
if TYPE_CHECKING:
1313
from openai.types.chat import ChatCompletionChunk
@@ -331,7 +331,7 @@ def _openai_stream_options_is_set(inputs: dict) -> bool:
331331
op_kwargs = settings.model_dump()
332332
op = weave.op(_add_stream_options(fn), **op_kwargs)
333333
op._set_on_input_handler(openai_on_input_handler)
334-
return add_accumulator(
334+
return _add_accumulator(
335335
op, # type: ignore
336336
make_accumulator=lambda inputs: lambda acc, value: openai_accumulator(
337337
acc, value, skip_last=not _openai_stream_options_is_set(inputs)
@@ -367,7 +367,7 @@ def _openai_stream_options_is_set(inputs: dict) -> bool:
367367
op_kwargs = settings.model_dump()
368368
op = weave.op(_add_stream_options(fn), **op_kwargs)
369369
op._set_on_input_handler(openai_on_input_handler)
370-
return add_accumulator(
370+
return _add_accumulator(
371371
op, # type: ignore
372372
make_accumulator=lambda inputs: lambda acc, value: openai_accumulator(
373373
acc, value, skip_last=not _openai_stream_options_is_set(inputs)

weave/integrations/vertexai/vertexai_sdk.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import weave
88
from weave.integrations.patcher import MultiPatcher, NoOpPatcher, SymbolPatcher
99
from weave.trace.autopatch import IntegrationSettings, OpSettings
10-
from weave.trace.op import add_accumulator
10+
from weave.trace.op import _add_accumulator
1111
from weave.trace.serialization.serialize import dictify
1212
from weave.trace.weave_client import Call
1313

@@ -95,7 +95,7 @@ def wrapper(fn: Callable) -> Callable:
9595

9696
op = weave.op(fn, **op_kwargs)
9797
op._set_on_finish_handler(vertexai_on_finish)
98-
return add_accumulator(
98+
return _add_accumulator(
9999
op, # type: ignore
100100
make_accumulator=lambda inputs: vertexai_accumulator,
101101
should_accumulate=lambda inputs: isinstance(inputs, dict)
@@ -120,7 +120,7 @@ async def _async_wrapper(*args: Any, **kwargs: Any) -> Any:
120120

121121
op = weave.op(_fn_wrapper(fn), **op_kwargs)
122122
op._set_on_finish_handler(vertexai_on_finish)
123-
return add_accumulator(
123+
return _add_accumulator(
124124
op, # type: ignore
125125
make_accumulator=lambda inputs: vertexai_accumulator,
126126
should_accumulate=lambda inputs: isinstance(inputs, dict)

weave/trace/op.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ def make_accumulator(inputs: dict) -> Callable:
718718
return accumulator
719719

720720
# Apply the accumulator
721-
add_accumulator(wrapped_op, make_accumulator)
721+
_add_accumulator(wrapped_op, make_accumulator)
722722

723723
return wrapped_op
724724

@@ -1034,7 +1034,7 @@ def on_close() -> None:
10341034
return iterator_wrapper(value, on_yield, on_error, on_close)
10351035

10361036

1037-
def add_accumulator(
1037+
def _add_accumulator(
10381038
op: Op,
10391039
make_accumulator: Callable[[dict], Callable[[S, V], S]],
10401040
*,

0 commit comments

Comments
 (0)