Skip to content

Commit c874c9b

Browse files
committed
test
1 parent 93b7c4c commit c874c9b

File tree

4 files changed

+26
-45
lines changed

4 files changed

+26
-45
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Github Checks](https://img.shields.io/github/check-runs/wandb/weave/master
77
)](https://github.com/wandb/weave)
88

9-
Weave is a toolkit for developing Generative AI applications, built by [Weights & Biases](https://wandb.ai/)!
9+
Weave is a toolkit for developing Generative AI applications, built by [Weights & Biases](https://wandb.ai/).
1010

1111
---
1212

docs/docs/guides/tracking/redact-pii.md

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Redact PII from Traces
22

3-
:::important
4-
This feature is only available for Enterprise users, and is only accessible via the Python SDK.
5-
:::
6-
73
Some organizations process Personally Identifiable Information (PII) such as names, phone numbers, and email addresses in their Large Language Model (LLM) workflows. Storing this data in Weights & Biases (W&B) Weave poses compliance and security risks.
84

95
The _Sensitive Data Protection_ feature allows you to automatically redact Personally Identifiable Information (PII) from a [trace](../tracking/index.md) before it is sent to Weave servers. This feature integrates [Microsoft Presidio](https://microsoft.github.io/presidio/) into the Weave Python SDK, which means that you can control redaction settings at the SDK level.

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ huggingface = ["huggingface-hub>=0.28.1"]
7676
instructor = [
7777
"instructor>=1.4.3,<1.7.0; python_version <= '3.9'",
7878
"instructor>=1.4.3; python_version > '3.9'",
79+
"google-genai>=1.5.0"
7980
]
8081
langchain = [
8182
"langchain-core>=0.2.1",

weave/trace/op.py

+24-40
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,6 @@
4040
from weave.trace.refs import ObjectRef
4141
from weave.trace.util import log_once
4242

43-
logger = logging.getLogger(__name__)
44-
45-
S = TypeVar("S")
46-
V = TypeVar("V")
47-
48-
49-
if sys.version_info < (3, 10):
50-
51-
def aiter(obj: AsyncIterator[V]) -> AsyncIterator[V]:
52-
return obj.__aiter__()
53-
54-
async def anext(obj: AsyncIterator[V], default: Optional[V] = None) -> V: # noqa: UP007
55-
try:
56-
return await obj.__anext__()
57-
except StopAsyncIteration:
58-
if default is not None:
59-
return default
60-
else:
61-
raise
62-
63-
6443
if TYPE_CHECKING:
6544
from weave.trace.weave_client import Call, CallsIter
6645

@@ -84,6 +63,29 @@ async def anext(obj: AsyncIterator[V], default: Optional[V] = None) -> V: # noq
8463
except ImportError:
8564
CEREBRAS_NOT_GIVEN = None
8665

66+
67+
S = TypeVar("S")
68+
V = TypeVar("V")
69+
70+
71+
if sys.version_info < (3, 10):
72+
73+
def aiter(obj: AsyncIterator[V]) -> AsyncIterator[V]:
74+
return obj.__aiter__()
75+
76+
async def anext(obj: AsyncIterator[V], default: Optional[V] = None) -> V: # noqa: UP007,UP045
77+
try:
78+
return await obj.__anext__()
79+
except StopAsyncIteration:
80+
if default is not None:
81+
return default
82+
else:
83+
raise
84+
85+
86+
logger = logging.getLogger(__name__)
87+
88+
8789
CALL_CREATE_MSG = "Error creating call:\n{}"
8890
ASYNC_CALL_CREATE_MSG = "Error creating async call:\n{}"
8991
ON_OUTPUT_MSG = "Error capturing call output:\n{}"
@@ -614,7 +616,6 @@ def op(
614616
postprocess_inputs: PostprocessInputsFunc | None = None,
615617
postprocess_output: PostprocessOutputFunc | None = None,
616618
tracing_sample_rate: float = 1.0,
617-
accumulator: Callable | None = None,
618619
) -> Callable[[Callable], Op] | Op:
619620
"""
620621
A decorator to weave op-ify a function or method. Works for both sync and async.
@@ -632,9 +633,6 @@ def op_deco(func: Callable) -> Op:
632633
is_generator = inspect.isgeneratorfunction(func)
633634
is_async_generator = inspect.isasyncgenfunction(func)
634635

635-
# Detect if this is an iterator function
636-
is_iterator = is_generator or is_async_generator
637-
638636
# Create the appropriate wrapper based on function type
639637
def create_wrapper(func: Callable) -> Op:
640638
if is_async:
@@ -700,27 +698,13 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
700698

701699
# Mark what type of function this is for runtime type checking
702700
wrapper._is_async = is_async # type: ignore
703-
wrapper._is_iterator = is_iterator # type: ignore
704701
wrapper._is_generator = is_generator # type: ignore
705702
wrapper._is_async_generator = is_async_generator # type: ignore
706703

707704
return cast(Op, wrapper)
708705

709706
# Create the wrapper
710-
wrapped_op = create_wrapper(func)
711-
712-
# Apply accumulator if this is an iterator and accumulator was provided
713-
if is_iterator and accumulator is not None:
714-
# Create an appropriate make_accumulator function
715-
def make_accumulator(inputs: dict) -> Callable:
716-
if accumulator is None:
717-
return lambda acc, value: value # Default accumulator if None
718-
return accumulator
719-
720-
# Apply the accumulator
721-
_add_accumulator(wrapped_op, make_accumulator)
722-
723-
return wrapped_op
707+
return create_wrapper(func)
724708

725709
if func is None:
726710
return op_deco

0 commit comments

Comments
 (0)