> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-docs-1778-mysql-updates.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# weave

> Python SDK reference for weave

# API Overview

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/api.py#L45">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>function</kbd> `init`

```python theme={null}
init(
    project_name: 'str',
    settings: 'UserSettings | dict[str, Any] | None' = None,
    autopatch_settings: 'AutopatchSettings | None' = None,
    global_postprocess_inputs: 'PostprocessInputsFunc | None' = None,
    global_postprocess_output: 'PostprocessOutputFunc | None' = None,
    global_attributes: 'dict[str, Any] | None' = None
) → WeaveClient
```

Initialize weave tracking, logging to a wandb project.

Logging is initialized globally, so you do not need to keep a reference to the return value of init.

Following init, calls of weave.op() decorated functions will be logged to the specified project.

**Args:**

NOTE: Global postprocessing settings are applied to all ops after each op's own postprocessing.  The order is always: 1. Op-specific postprocessing 2. Global postprocessing

* <b>`project_name`</b>: The name of the Weights & Biases team and project to log to. If you don't  specify a team, your default entity is used. To find or update your default entity, refer to [User Settings](https://docs.wandb.ai/guides/models/app/settings-page/user-settings/#default-team) in the W\&B Models documentation.
* <b>`settings`</b>: Configuration for the Weave client generally.
* <b>`autopatch_settings`</b>: (Deprecated) Configuration for autopatch integrations. Use explicit patching instead.
* <b>`global_postprocess_inputs`</b>: A function that will be applied to all inputs of all ops.
* <b>`global_postprocess_output`</b>: A function that will be applied to all outputs of all ops.
* <b>`global_attributes`</b>: A dictionary of attributes that will be applied to all traces.
  **Returns:**
  A Weave client.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/api.py#L127">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>function</kbd> `publish`

```python theme={null}
publish(obj: 'Any', name: 'str | None' = None) → ObjectRef
```

Save and version a Python object.

Weave creates a new version of the object if the object's name already exists and its content hash does not match the latest version of that object.

**Args:**

* <b>`obj`</b>: The object to save and version.
* <b>`name`</b>: The name to save the object under.
  **Returns:**
  A Weave Ref to the saved object.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/api.py#L179">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>function</kbd> `ref`

```python theme={null}
ref(location: 'str') → ObjectRef
```

Creates a Ref to an existing Weave object. This does not directly retrieve the object but allows you to pass it to other Weave API functions.

**Args:**

* <b>`location`</b>: A Weave Ref URI, or if `weave.init()` has been called, `name:version` or `name`. If no version is provided, `latest` is used.
  **Returns:**
  A Weave Ref to the object.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/api.py#L208">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>function</kbd> `get`

```python theme={null}
get(uri: 'str | ObjectRef') → Any
```

A convenience function for getting an object from a URI.

Many objects logged by Weave are automatically registered with the Weave server. This function allows you to retrieve those objects by their URI.

**Args:**

* <b>`uri`</b>: A fully-qualified weave ref URI.
  **Returns:**
  The object.

**Example:**

```python theme={null}
weave.init("weave_get_example")
dataset = weave.Dataset(rows=[{"a": 1, "b": 2}])
ref = weave.publish(dataset)

dataset2 = weave.get(ref)  # same as dataset!
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/context/call_context.py#L76">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>function</kbd> `require_current_call`

```python theme={null}
require_current_call() → Call
```

Get the Call object for the currently executing Op, within that Op.

This allows you to access attributes of the Call such as its id or feedback while it is running.

```python theme={null}
@weave.op
def hello(name: str) -> None:
     print(f"Hello {name}!")
     current_call = weave.require_current_call()
     print(current_call.id)
```

It is also possible to access a Call after the Op has returned.

If you have the Call's id, perhaps from the UI, you can use the `get_call` method on the `WeaveClient` returned from `weave.init` to retrieve the Call object.

```python theme={null}
client = weave.init("<project>")
mycall = client.get_call("<call_id>")
```

Alternately, after defining your Op you can use its `call` method. For example:

```python theme={null}
@weave.op
def add(a: int, b: int) -> int:
     return a + b

result, call = add.call(1, 2)
print(call.id)
```

**Returns:**
The Call object for the currently executing Op

**Raises:**

* <b>`NoCurrentCallError`</b>:  If tracking has not been initialized or this method is  invoked outside an Op.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/context/call_context.py#L125">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>function</kbd> `get_current_call`

```python theme={null}
get_current_call() → Call | None
```

Get the Call object for the currently executing Op, within that Op.

**Returns:**
The Call object for the currently executing Op, or  None if tracking has not been initialized or this method is  invoked outside an Op.

**Note:**

> The returned Call's `attributes` dictionary becomes immutable once the call starts. Use :func:`weave.attributes` to set call metadata before invoking an Op. The `summary` field may be updated while the Op executes and will be merged with computed summary information when the call finishes.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/api.py#L384">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>function</kbd> `finish`

```python theme={null}
finish() → None
```

Stops logging to weave.

Following finish, calls of weave.op() decorated functions will no longer be logged. You will need to run weave.init() again to resume logging.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/op.py#L1194">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>function</kbd> `op`

```python theme={null}
op(
    func: 'Callable[P, R] | None' = None,
    name: 'str | None' = None,
    call_display_name: 'str | CallDisplayNameFunc | None' = None,
    postprocess_inputs: 'PostprocessInputsFunc | None' = None,
    postprocess_output: 'PostprocessOutputFunc | None' = None,
    tracing_sample_rate: 'float' = 1.0,
    enable_code_capture: 'bool' = True,
    accumulator: 'Callable[[Any | None, Any], Any] | None' = None
) → Callable[[Callable[P, R]], Op[P, R]] | Op[P, R]
```

A decorator to weave op-ify a function or method. Works for both sync and async. Automatically detects iterator functions and applies appropriate behavior.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/../../../../weave/trace/api/attributes#L234">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>function</kbd> `attributes`

```python theme={null}
attributes(attributes: 'dict[str, Any]') → Iterator
```

Context manager for setting attributes on a call.

**Example:**

```python theme={null}
with weave.attributes({'env': 'production'}):
     print(my_function.call("World"))
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/../../../../weave/trace/api/thread#L337">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>function</kbd> `thread`

```python theme={null}
thread(
    thread_id: 'str | None | object' = <object object at 0x7f126ec3ce50>
) → Iterator[ThreadContext]
```

Context manager for setting thread\_id on calls within the context.

**Examples:**

```python theme={null}
# Auto-generate thread_id
with weave.thread() as t:
     print(f"Thread ID: {t.thread_id}")
     result = my_function("input")  # This call will have the auto-generated thread_id
     print(f"Current turn: {t.turn_id}")

# Explicit thread_id
with weave.thread("custom_thread") as t:
     result = my_function("input")  # This call will have thread_id="custom_thread"

# Disable threading
with weave.thread(None) as t:
     result = my_function("input")  # This call will have thread_id=None
```

**Args:**

* <b>`thread_id`</b>: The thread identifier to associate with calls in this context.  If not provided, a UUID v7 will be auto-generated.  If None, thread tracking will be disabled.
  **Yields:**

* <b>`ThreadContext`</b>:  An object providing access to thread\_id and current turn\_id.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/object/obj.py#L74">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `Object`

Base class for Weave objects that can be tracked and versioned.

This class extends Pydantic's BaseModel to provide Weave-specific functionality for object tracking, referencing, and serialization. Objects can have names, descriptions, and references that allow them to be stored and retrieved from the Weave system.

**Attributes:**

* <b>`name`</b> (Optional\[str]):  A human-readable name for the object.
* <b>`description`</b> (Optional\[str]):  A description of what the object represents.
* <b>`ref`</b> (Optional\[ObjectRef]):  A reference to the object in the Weave system.

**Examples:**

```python theme={null}
# Create a simple object
obj = Object(name="my_object", description="A test object")

# Create an object from a URI
obj = Object.from_uri("weave:///entity/project/object:digest")
```

**Pydantic Fields:**

* `name`: `typing.Optional[str]`
* `description`: `typing.Optional[str]`
* `ref`: `typing.Optional[trace.refs.ObjectRef]`

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/object/obj.py#L113">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_uri`

```python theme={null}
from_uri(uri: str, objectify: bool = True) → Self
```

Create an object instance from a Weave URI.

**Args:**

* <b>`uri`</b> (str):  The Weave URI pointing to the object.
* <b>`objectify`</b> (bool):  Whether to objectify the result. Defaults to True.

**Returns:**

* <b>`Self`</b>:  An instance of the class created from the URI.

**Raises:**

* <b>`NotImplementedError`</b>:  If the class doesn't implement the required  methods for deserialization.

**Examples:**

```python theme={null}
obj = MyObject.from_uri("weave:///entity/project/object:digest")
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/object/obj.py#L139">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `handle_relocatable_object`

```python theme={null}
handle_relocatable_object(
    v: Any,
    handler: ValidatorFunctionWrapHandler,
    info: ValidationInfo
) → Any
```

Handle validation of relocatable objects including ObjectRef and WeaveObject.

This validator handles special cases where the input is an ObjectRef or WeaveObject that needs to be properly converted to a standard Object instance. It ensures that references are preserved and that ignored types are handled correctly during the validation process.

**Args:**

* <b>`v`</b> (Any):  The value to validate.
* <b>`handler`</b> (ValidatorFunctionWrapHandler):  The standard pydantic validation handler.
* <b>`info`</b> (ValidationInfo):  Validation context information.

**Returns:**

* <b>`Any`</b>:  The validated object instance.

**Examples:**
This method is called automatically during object creation and validation. It handles cases like: \`\`\`python

# When an ObjectRef is passed

obj = MyObject(some\_object\_ref)

# When a WeaveObject is passed

obj = MyObject(some\_weave\_object)

````

---

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/dataset/dataset.py#L26"><img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" /></a>

## <kbd>class</kbd> `Dataset`
Dataset object with easy saving and automatic versioning. 

**Examples:**
```python
# Create a dataset
dataset = Dataset(name='grammar', rows=[
 {'id': '0', 'sentence': "He no likes ice cream.", 'correction': "He doesn't like ice cream."},
 {'id': '1', 'sentence': "She goed to the store.", 'correction': "She went to the store."},
 {'id': '2', 'sentence': "They plays video games all day.", 'correction': "They play video games all day."}
])

# Publish the dataset
weave.publish(dataset)

# Retrieve the dataset
dataset_ref = weave.ref('grammar').get()

# Access a specific example
example_label = dataset_ref.rows[2]['sentence']
````

**Pydantic Fields:**

* `name`: `typing.Optional[str]`
* `description`: `typing.Optional[str]`
* `ref`: `typing.Optional[trace.refs.ObjectRef]`
* `rows`: `typing.Union[trace.table.Table, trace.vals.WeaveTable]`

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/dataset/dataset.py#L129">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `add_rows`

```python theme={null}
add_rows(rows: Iterable[dict]) → Dataset
```

Create a new dataset version by appending rows to the existing dataset.

This is useful for adding examples to large datasets without having to load the entire dataset into memory.

**Args:**

* <b>`rows`</b>: The rows to add to the dataset.
  **Returns:**
  The updated dataset.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/dataset/dataset.py#L173">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `convert_to_table`

```python theme={null}
convert_to_table(rows: Any) → Union[Table, WeaveTable]
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/dataset/dataset.py#L61">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_calls`

```python theme={null}
from_calls(calls: Iterable[Call]) → Self
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/dataset/dataset.py#L71">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_hf`

```python theme={null}
from_hf(
    hf_dataset: Union[ForwardRef('HFDataset'), ForwardRef('HFDatasetDict')]
) → Self
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/dataset/dataset.py#L52">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_obj`

```python theme={null}
from_obj(obj: WeaveObject) → Self
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/dataset/dataset.py#L66">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_pandas`

```python theme={null}
from_pandas(df: 'DataFrame') → Self
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/dataset/dataset.py#L220">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `select`

```python theme={null}
select(indices: Iterable[int]) → Self
```

Select rows from the dataset based on the provided indices.

**Args:**

* <b>`indices`</b>: An iterable of integer indices specifying which rows to select.
  **Returns:**
  A new Dataset object containing only the selected rows.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/dataset/dataset.py#L115">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `to_hf`

```python theme={null}
to_hf() → HFDataset
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/dataset/dataset.py#L107">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `to_pandas`

```python theme={null}
to_pandas() → DataFrame
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/model.py#L24">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `Model`

Intended to capture a combination of code and data the operates on an input. For example it might call an LLM with a prompt to make a prediction or generate text.

When you change the attributes or the code that defines your model, these changes will be logged and the version will be updated. This ensures that you can compare the predictions across different versions of your model. Use this to iterate on prompts or to try the latest LLM and compare predictions across different settings

**Examples:**

```python theme={null}
class YourModel(Model):
     attribute1: str
     attribute2: int

     @weave.op()
     def predict(self, input_data: str) -> dict:
         # Model logic goes here
         prediction = self.attribute1 + ' ' + input_data
         return {'pred': prediction}
```

**Pydantic Fields:**

* `name`: `typing.Optional[str]`
* `description`: `typing.Optional[str]`
* `ref`: `typing.Optional[trace.refs.ObjectRef]`

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/model.py#L50">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `get_infer_method`

```python theme={null}
get_infer_method() → Callable
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L77">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `Prompt`

**Pydantic Fields:**

* `name`: `typing.Optional[str]`
* `description`: `typing.Optional[str]`
* `ref`: `typing.Optional[trace.refs.ObjectRef]`

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L78">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `format`

```python theme={null}
format(**kwargs: Any) → Any
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L82">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `StringPrompt`

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L86">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `__init__`

```python theme={null}
__init__(content: str)
```

**Pydantic Fields:**

* `name`: `typing.Optional[str]`
* `description`: `typing.Optional[str]`
* `ref`: `typing.Optional[trace.refs.ObjectRef]`
* `content`: `<class 'str'>`

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L90">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `format`

```python theme={null}
format(**kwargs: Any) → str
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L93">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_obj`

```python theme={null}
from_obj(obj: WeaveObject) → Self
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L102">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `MessagesPrompt`

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L106">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `__init__`

```python theme={null}
__init__(messages: list[dict])
```

**Pydantic Fields:**

* `name`: `typing.Optional[str]`
* `description`: `typing.Optional[str]`
* `ref`: `typing.Optional[trace.refs.ObjectRef]`
* `messages`: `list[dict]`

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L121">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `format`

```python theme={null}
format(**kwargs: Any) → list
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L110">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `format_message`

```python theme={null}
format_message(message: dict, **kwargs: Any) → dict
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/prompt/prompt.py#L124">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_obj`

```python theme={null}
from_obj(obj: WeaveObject) → Self
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval.py#L59">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `Evaluation`

Sets up an evaluation which includes a set of scorers and a dataset.

Calling evaluation.evaluate(model) will pass in rows from a dataset into a model matching  the names of the columns of the dataset to the argument names in model.predict.

Then it will call all of the scorers and save the results in weave.

If you want to preprocess the rows from the dataset you can pass in a function to preprocess\_model\_input.

**Examples:**

```python theme={null}
# Collect your examples
examples = [
     {"question": "What is the capital of France?", "expected": "Paris"},
     {"question": "Who wrote 'To Kill a Mockingbird'?", "expected": "Harper Lee"},
     {"question": "What is the square root of 64?", "expected": "8"},
]

# Define any custom scoring function
@weave.op()
def match_score1(expected: str, model_output: dict) -> dict:
     # Here is where you'd define the logic to score the model output
     return {'match': expected == model_output['generated_text']}

@weave.op()
def function_to_evaluate(question: str):
     # here's where you would add your LLM call and return the output
     return  {'generated_text': 'Paris'}

# Score your examples using scoring functions
evaluation = Evaluation(
     dataset=examples, scorers=[match_score1]
)

# Start tracking the evaluation
weave.init('intro-example')
# Run the evaluation
asyncio.run(evaluation.evaluate(function_to_evaluate))
```

**Pydantic Fields:**

* `name`: `typing.Optional[str]`
* `description`: `typing.Optional[str]`
* `ref`: `typing.Optional[trace.refs.ObjectRef]`
* `dataset`: `<class 'dataset.dataset.Dataset'>`
* `scorers`: `typing.Optional[list[typing.Annotated[typing.Union[trace.op_protocol.Op, flow.scorer.Scorer], BeforeValidator(func=<function cast_to_scorer at 0x7f126eaa0040>, json_schema_input_type=PydanticUndefined)]]]`
* `preprocess_model_input`: `typing.Optional[typing.Callable[[dict], dict]]`
* `trials`: `<class 'int'>`
* `metadata`: `typing.Optional[dict[str, typing.Any]]`
* `evaluation_name`: `typing.Union[str, typing.Callable[[trace.call.Call], str], NoneType]`

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/op.py#L278">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `evaluate`

```python theme={null}
evaluate(model: Union[Op, Model]) → dict
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval.py#L117">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_obj`

```python theme={null}
from_obj(obj: WeaveObject) → Self
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval.py#L236">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `get_eval_results`

```python theme={null}
get_eval_results(model: Union[Op, Model]) → EvaluationResults
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval.py#L289">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `get_evaluate_calls`

```python theme={null}
get_evaluate_calls() → PaginatedIterator[CallSchema, WeaveObject]
```

Retrieve all evaluation calls that used this Evaluation object.

Note that this returns a CallsIter instead of a single call because it's possible to have multiple evaluation calls for a single evaluation (e.g. if you run the same evaluation multiple times).

**Returns:**

* <b>`CallsIter`</b>:  An iterator over Call objects representing evaluation runs.

**Raises:**

* <b>`ValueError`</b>:  If the evaluation has no ref (hasn't been saved/run yet).

**Examples:**

```python theme={null}
evaluation = Evaluation(dataset=examples, scorers=[scorer])
await evaluation.evaluate(model)  # Run evaluation first
calls = evaluation.get_evaluate_calls()
for call in calls:
     print(f"Evaluation run: {call.id} at {call.started_at}")
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval.py#L325">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `get_score_calls`

```python theme={null}
get_score_calls() → dict[str, list[Call]]
```

Retrieve scorer calls for each evaluation run, grouped by trace ID.

**Returns:**

* <b>`dict[str, list[Call]]`</b>:  A dictionary mapping trace IDs to lists of scorer Call objects.  Each trace ID represents one evaluation run, and the list contains all scorer  calls executed during that run.

**Examples:**

```python theme={null}
evaluation = Evaluation(dataset=examples, scorers=[accuracy_scorer, f1_scorer])
await evaluation.evaluate(model)
score_calls = evaluation.get_score_calls()
for trace_id, calls in score_calls.items():
     print(f"Trace {trace_id}: {len(calls)} scorer calls")
     for call in calls:
         scorer_name = call.summary.get("weave", {}).get("trace_name")
         print(f"  Scorer: {scorer_name}, Output: {call.output}")
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval.py#L364">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `get_scores`

```python theme={null}
get_scores() → dict[str, dict[str, list[Any]]]
```

Extract and organize scorer outputs from evaluation runs.

**Returns:**

* <b>`dict[str, dict[str, list[Any]]]`</b>:  A nested dictionary structure where:
  * First level keys are trace IDs (evaluation runs)
  * Second level keys are scorer names
  * Values are lists of scorer outputs for that run and scorer

**Examples:**

```python theme={null}
evaluation = Evaluation(dataset=examples, scorers=[accuracy_scorer, f1_scorer])
await evaluation.evaluate(model)
scores = evaluation.get_scores()
# Access scores by trace and scorer
for trace_id, trace_scores in scores.items():
         print(f"Evaluation run {trace_id}:")
         for scorer_name, outputs in trace_scores.items():
             print(f"  {scorer_name}: {outputs}")
```

Expected output:

```
{
     "trace_123": {
     "accuracy_scorer": [{"accuracy": 0.85}],
     "f1_scorer": [{"f1": 0.78}]
     }
}
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/pydantic/_internal/_model_construction.py#L158">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `model_post_init`

```python theme={null}
model_post_init(_Evaluation__context: Any) → None
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/op.py#L175">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `predict_and_score`

```python theme={null}
predict_and_score(model: Union[Op, Model], example: dict) → dict
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/op.py#L213">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `summarize`

```python theme={null}
summarize(eval_table: EvaluationResults) → dict
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval_imperative.py#L633">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `EvaluationLogger`

This class provides an imperative interface for logging evaluations.

An evaluation is started automatically when the first prediction is logged using the `log_prediction` method, and finished when the `log_summary` method is called.

Each time you log a prediction, you will get back a `ScoreLogger` object. You can use this object to log scores and metadata for that specific prediction. For more information, see the `ScoreLogger` class.

Basic usage - log predictions with inputs and outputs directly:

```python theme={null}
ev = EvaluationLogger()

# Log predictions with known inputs/outputs
pred = ev.log_prediction(inputs={'q': 'Hello'}, outputs={'a': 'Hi there!'})
pred.log_score("correctness", 0.9)

# Finish the evaluation
ev.log_summary({"avg_score": 0.9})
```

Advanced usage - use context manager for dynamic outputs and nested operations:

```python theme={null}
ev = EvaluationLogger()

# Use context manager when you need to capture nested operations
with ev.log_prediction(inputs={'q': 'Hello'}) as pred:
     # Any operations here (like LLM calls) automatically become
     # children of the predict call
     response = your_llm_call(...)
     pred.output = response.content
     pred.log_score("correctness", 0.9)

# Finish the evaluation
ev.log_summary({"avg_score": 0.9})
```

**Pydantic Fields:**

* `name`: `str | None`
* `model`: `flow.model.Model | dict | str`
* `dataset`: `dataset.dataset.Dataset | list[dict] | str`
* `eval_attributes`: `dict[str, typing.Any]`
* `scorers`: `list[str] | None`

***

#### <kbd>property</kbd> attributes

***

#### <kbd>property</kbd> ui\_url

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval_imperative.py#L1086">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `fail`

```python theme={null}
fail(exception: 'BaseException') → None
```

Convenience method to fail the evaluation with an exception.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval_imperative.py#L1070">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `finish`

```python theme={null}
finish(exception: 'BaseException | None' = None) → None
```

Clean up the evaluation resources explicitly without logging a summary.

Ensures all prediction calls and the main evaluation call are finalized. This is automatically called if the logger is used as a context manager.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval_imperative.py#L883">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `log_prediction`

```python theme={null}
log_prediction(
    inputs: 'dict[str, Any]',
    output: 'Any | _NotSetType' = <NOT_SET>
) → ScoreLogger | _LogPredictionContext
```

Log a prediction to the Evaluation.

If output is provided, returns a ScoreLogger for direct use. If output is not provided, returns a PredictionContext for use as a context manager.

**Args:**

* <b>`inputs`</b>: The input data for the prediction
* <b>`output`</b>: The output value. If not provided, use as context manager to set later.
  **Returns:**
  ScoreLogger if output provided, PredictionContext if not.

Example (direct):

* <b>`pred = ev.log_prediction({'q'`</b>:  '...'}, output="answer") pred.log\_score("correctness", 0.9) pred.finish()

Example (context manager):

* <b>`with ev.log_prediction({'q'`</b>:  '...'}) as pred:  response = model(...)  pred.output = response  pred.log\_score("correctness", 0.9)

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval_imperative.py#L964">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `log_summary`

```python theme={null}
log_summary(summary: 'dict | None' = None, auto_summarize: 'bool' = True) → None
```

Log a summary dict to the Evaluation.

This will calculate the summary, call the summarize op, and then finalize the evaluation, meaning no more predictions or scores can be logged.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/pydantic/_internal/_model_construction.py#L746">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `model_post_init`

```python theme={null}
model_post_init(_EvaluationLogger__context: 'Any') → None
```

Initialize the pseudo evaluation with the dataset from the model.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/evaluation/eval_imperative.py#L1013">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `set_view`

```python theme={null}
set_view(
    name: 'str',
    content: 'Content | str',
    extension: 'str | None' = None,
    mimetype: 'str | None' = None,
    metadata: 'dict[str, Any] | None' = None,
    encoding: 'str' = 'utf-8'
) → None
```

Attach a view to the evaluation's main call summary under `weave.views`.

Saves the provided content as an object in the project and writes its reference URI under `summary.weave.views.<name>` for the evaluation's `evaluate` call. String inputs are wrapped as text content using `Content.from_text` with the provided extension or mimetype.

**Args:**

* <b>`name`</b>: The view name to display, used as the key under `summary.weave.views`.
* <b>`content`</b>: A `weave.Content` instance or string to serialize.
* <b>`extension`</b>: Optional file extension for string content inputs.
* <b>`mimetype`</b>: Optional MIME type for string content inputs.
* <b>`metadata`</b>: Optional metadata attached to newly created `Content`.
* <b>`encoding`</b>: Text encoding for string content inputs.
  **Returns:**
  None

**Examples:**
` import weave`

> > > ev = weave.EvaluationLogger()
> > > ev.set\_view("report", "# Report", extension="md")

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/scorer.py#L30">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `Scorer`

**Pydantic Fields:**

* `name`: `typing.Optional[str]`
* `description`: `typing.Optional[str]`
* `ref`: `typing.Optional[trace.refs.ObjectRef]`
* `column_map`: `typing.Optional[dict[str, str]]`

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/scorer.py#L48">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_obj`

```python theme={null}
from_obj(obj: WeaveObject) → Self
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/scorer.py#L36">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `model_post_init`

```python theme={null}
model_post_init(_Scorer__context: Any) → None
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/op.py#L40">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `score`

```python theme={null}
score(output: Any, **kwargs: Any) → Any
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace/op.py#L44">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `summarize`

```python theme={null}
summarize(score_rows: list) → Optional[dict]
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace_server/interface/builtin_object_classes/annotation_spec.py#L12">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `AnnotationSpec`

**Pydantic Fields:**

* `name`: `typing.Optional[str]`
* `description`: `typing.Optional[str]`
* `field_schema`: `dict[str, typing.Any]`
* `unique_among_creators`: `<class 'bool'>`
* `op_scope`: `typing.Optional[list[str]]`

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace_server/interface/builtin_object_classes/annotation_spec.py#L47">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `preprocess_field_schema`

```python theme={null}
preprocess_field_schema(data: dict[str, Any]) → dict[str, Any]
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace_server/interface/builtin_object_classes/annotation_spec.py#L92">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `validate_field_schema`

```python theme={null}
validate_field_schema(schema: dict[str, Any]) → dict[str, Any]
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/trace_server/interface/builtin_object_classes/annotation_spec.py#L103">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `value_is_valid`

```python theme={null}
value_is_valid(payload: Any) → bool
```

Validates a payload against this annotation spec's schema.

**Args:**

* <b>`payload`</b>: The data to validate against the schema
  **Returns:**

* <b>`bool`</b>:  True if validation succeeds, False otherwise

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_handlers/File/file.py#L29">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `File`

A class representing a file with path, mimetype, and size information.

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_handlers/File/file.py#L33">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `__init__`

```python theme={null}
__init__(path: 'str | Path', mimetype: 'str | None' = None)
```

Initialize a File object.

**Args:**

***

#### <kbd>property</kbd> filename

Get the filename of the file.

* <b>`path`</b>: Path to the file (string or pathlib.Path)

* <b>`mimetype`</b>: Optional MIME type of the file - will be inferred from extension if not provided
  **Returns:**

* <b>`str`</b>:  The name of the file without the directory path.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_handlers/File/file.py#L59">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `open`

```python theme={null}
open() → bool
```

Open the file using the operating system's default application.

This method uses the platform-specific mechanism to open the file with the default application associated with the file's type.

**Returns:**

* <b>`bool`</b>:  True if the file was successfully opened, False otherwise.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_handlers/File/file.py#L80">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `save`

```python theme={null}
save(dest: 'str | Path') → None
```

Copy the file to the specified destination path.

**Args:**

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L42">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `Content`

A class to represent content from various sources, resolving them to a unified byte-oriented representation with associated metadata.

This class must be instantiated using one of its classmethods:

* from\_path()
* from\_bytes()
* from\_text()
* from\_url()
* from\_base64()
* from\_data\_url()

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L87">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `__init__`

```python theme={null}
__init__(*args: 'Any', **kwargs: 'Any') → None
```

Direct initialization is disabled. Please use a classmethod like `Content.from_path()` to create an instance.

* <b>`dest`</b>: Destination path where the file will be copied to (string or pathlib.Path)  The destination path can be a file or a directory.
  **Pydantic Fields:**

* `data`: `<class 'bytes'>`

* `size`: `<class 'int'>`

* `mimetype`: `<class 'str'>`

* `digest`: `<class 'str'>`

* `filename`: `<class 'str'>`

* `content_type`: `typing.Literal['bytes', 'text', 'base64', 'file', 'url', 'data_url', 'data_url:base64', 'data_url:encoding', 'data_url:encoding:base64']`

* `input_type`: `<class 'str'>`

* `encoding`: `<class 'str'>`

* `metadata`: `dict[str, typing.Any] | None`

* `extension`: `str | None`

***

#### <kbd>property</kbd> art

***

#### <kbd>property</kbd> ref

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L531">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `as_string`

```python theme={null}
as_string() → str
```

Display the data as a string. Bytes are decoded using the `encoding` attribute If base64, the data will be re-encoded to base64 bytes then decoded to an ASCII string

**Returns:**
str.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L246">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_base64`

```python theme={null}
from_base64(
    b64_data: 'str | bytes',
    extension: 'str | None' = None,
    mimetype: 'str | None' = None,
    metadata: 'dict[str, Any] | None' = None
) → Self
```

Initializes Content from a base64 encoded string or bytes.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L156">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_bytes`

```python theme={null}
from_bytes(
    data: 'bytes',
    extension: 'str | None' = None,
    mimetype: 'str | None' = None,
    metadata: 'dict[str, Any] | None' = None,
    encoding: 'str' = 'utf-8'
) → Self
```

Initializes Content from raw bytes.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L345">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_data_url`

```python theme={null}
from_data_url(url: 'str', metadata: 'dict[str, Any] | None' = None) → Self
```

Initializes Content from a data URL.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L297">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_path`

```python theme={null}
from_path(
    path: 'str | Path',
    encoding: 'str' = 'utf-8',
    mimetype: 'str | None' = None,
    metadata: 'dict[str, Any] | None' = None
) → Self
```

Initializes Content from a local file path.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L197">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_text`

```python theme={null}
from_text(
    text: 'str',
    extension: 'str | None' = None,
    mimetype: 'str | None' = None,
    metadata: 'dict[str, Any] | None' = None,
    encoding: 'str' = 'utf-8'
) → Self
```

Initializes Content from a string of text.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L387">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_url`

```python theme={null}
from_url(
    url: 'str',
    headers: 'dict[str, Any] | None' = None,
    timeout: 'int | None' = 30,
    metadata: 'dict[str, Any] | None' = None
) → Self
```

Initializes Content by fetching bytes from an HTTP(S) URL.

Downloads the content, infers mimetype/extension from headers, URL path, and data, and constructs a Content object from the resulting bytes.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L97">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `model_validate`

```python theme={null}
model_validate(
    obj: 'Any',
    strict: 'bool | None' = None,
    from_attributes: 'bool | None' = None,
    context: 'dict[str, Any] | None' = None
) → Self
```

Override model\_validate to handle Content reconstruction from dict.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L139">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `model_validate_json`

```python theme={null}
model_validate_json(
    json_data: 'str | bytes | bytearray',
    strict: 'bool | None' = None,
    context: 'dict[str, Any] | None' = None
) → Self
```

Override model\_validate\_json to handle Content reconstruction from JSON.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L541">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `open`

```python theme={null}
open() → bool
```

Open the file using the operating system's default application.

This method uses the platform-specific mechanism to open the file with the default application associated with the file's type.

**Returns:**

* <b>`bool`</b>:  True if the file was successfully opened, False otherwise.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L571">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `save`

```python theme={null}
save(dest: 'str | Path') → None
```

Copy the file to the specified destination path. Updates the filename and the path of the content to reflect the last saved copy.

**Args:**

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L523">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `serialize_data`

```python theme={null}
serialize_data(data: 'bytes') → str
```

When dumping model in json mode

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_wrappers/Content/content.py#L498">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `to_data_url`

```python theme={null}
to_data_url(use_base64: 'bool' = True) → str
```

Constructs a data URL from the content.

* <b>`dest`</b>: Destination path where the file will be copied to (string or pathlib.Path)  The destination path can be a file or a directory.  If dest has no file extension (e.g. .txt), destination will be considered a directory.
  **Args:**

* <b>`use_base64`</b>: If True, the data will be base64 encoded.  Otherwise, it will be percent-encoded. Defaults to True.
  **Returns:**
  A data URL string.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/rich/markdown.py#L498">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `Markdown`

A Markdown renderable.

**Args:**

* <b>`markup`</b> (str):  A string containing markdown.
* <b>`code_theme`</b> (str, optional):  Pygments theme for code blocks. Defaults to "monokai". See [https://pygments.org/styles/](https://pygments.org/styles/) for code themes.
* <b>`justify`</b> (JustifyMethod, optional):  Justify value for paragraphs. Defaults to None.
* <b>`style`</b> (Union\[str, Style], optional):  Optional style to apply to markdown.
* <b>`hyperlinks`</b> (bool, optional):  Enable hyperlinks. Defaults to `True`.

<a href="https://github.com/wandb/weave/blob/0.52.10/rich/markdown.py#L534">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `__init__`

```python theme={null}
__init__(
    markup: 'str',
    code_theme: 'str' = 'monokai',
    justify: 'JustifyMethod | None' = None,
    style: 'str | Style' = 'none',
    hyperlinks: 'bool' = True,
    inline_code_lexer: 'str | None' = None,
    inline_code_theme: 'str | None' = None
) → None
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/monitor.py#L14">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `Monitor`

Sets up a monitor to score incoming calls automatically.

* <b>`inline_code_lexer`</b>: (str, optional): Lexer to use if inline code highlighting is  enabled. Defaults to None.
* <b>`inline_code_theme`</b>: (Optional\[str], optional): Pygments theme for inline code  highlighting, or None for no highlighting. Defaults to None.
  **Examples:**

```python theme={null}
import weave
from weave.scorers import ValidJSONScorer

json_scorer = ValidJSONScorer()

my_monitor = weave.Monitor(
     name="my-monitor",
     description="This is a test monitor",
     sampling_rate=0.5,
     op_names=["my_op"],
     query={
         "$expr": {
             "$gt": [
                 {
                         "$getField": "started_at"
                     },
                     {
                         "$literal": 1742540400
                     }
                 ]
             }
         }
     },
     scorers=[json_scorer],
)

my_monitor.activate()
```

**Pydantic Fields:**

* `name`: `typing.Optional[str]`
* `description`: `typing.Optional[str]`
* `ref`: `typing.Optional[trace.refs.ObjectRef]`
* `sampling_rate`: `<class 'float'>`
* `scorers`: `list[flow.scorer.Scorer]`
* `op_names`: `list[str]`
* `query`: `typing.Optional[trace_server.interface.query.Query]`
* `active`: `<class 'bool'>`

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/monitor.py#L56">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `activate`

```python theme={null}
activate() → ObjectRef
```

Activates the monitor.

**Returns:**
The ref to the monitor.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/monitor.py#L66">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `deactivate`

```python theme={null}
deactivate() → ObjectRef
```

Deactivates the monitor.

**Returns:**
The ref to the monitor.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/monitor.py#L76">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_obj`

```python theme={null}
from_obj(obj: WeaveObject) → Self
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L491">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `SavedView`

A fluent-style class for working with SavedView objects.

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L497">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `__init__`

```python theme={null}
__init__(view_type: 'str' = 'traces', label: 'str' = 'SavedView') → None
```

***

#### <kbd>property</kbd> entity

***

#### <kbd>property</kbd> label

***

#### <kbd>property</kbd> project

***

#### <kbd>property</kbd> view\_type

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L621">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `add_column`

```python theme={null}
add_column(path: 'str | ObjectPath', label: 'str | None' = None) → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L630">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `add_columns`

```python theme={null}
add_columns(*columns: 'str') → SavedView
```

Convenience method for adding multiple columns to the grid.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L522">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `add_filter`

```python theme={null}
add_filter(
    field: 'str',
    operator: 'str',
    value: 'Any | None' = None
) → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L596">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `add_sort`

```python theme={null}
add_sort(field: 'str', direction: 'SortDirection') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L661">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `column_index`

```python theme={null}
column_index(path: 'int | str | ObjectPath') → int
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L576">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `filter_op`

```python theme={null}
filter_op(op_name: 'str | None') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L846">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `get_calls`

```python theme={null}
get_calls(
    limit: 'int | None' = None,
    offset: 'int | None' = None,
    include_costs: 'bool' = False,
    include_feedback: 'bool' = False,
    all_columns: 'bool' = False
) → CallsIter
```

Get calls matching this saved view's filters and settings.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L904">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `get_known_columns`

```python theme={null}
get_known_columns(num_calls_to_query: 'int | None' = None) → list[str]
```

Get the set of columns that are known to exist.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L914">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `get_table_columns`

```python theme={null}
get_table_columns() → list[TableColumn]
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L615">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `hide_column`

```python theme={null}
hide_column(col_name: 'str') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L636">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `insert_column`

```python theme={null}
insert_column(
    idx: 'int',
    path: 'str | ObjectPath',
    label: 'str | None' = None
) → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L974">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `load`

```python theme={null}
load(ref: 'str') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L739">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `page_size`

```python theme={null}
page_size(page_size: 'int') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L709">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `pin_column_left`

```python theme={null}
pin_column_left(col_name: 'str') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L719">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `pin_column_right`

```python theme={null}
pin_column_right(col_name: 'str') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L681">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `remove_column`

```python theme={null}
remove_column(path: 'int | str | ObjectPath') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L700">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `remove_columns`

```python theme={null}
remove_columns(*columns: 'str') → SavedView
```

Remove columns from the saved view.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L545">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `remove_filter`

```python theme={null}
remove_filter(index_or_field: 'int | str') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L560">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `remove_filters`

```python theme={null}
remove_filters() → SavedView
```

Remove all filters from the saved view.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L518">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `rename`

```python theme={null}
rename(label: 'str') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L675">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `rename_column`

```python theme={null}
rename_column(path: 'int | str | ObjectPath', label: 'str') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L831">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `save`

```python theme={null}
save() → SavedView
```

Publish the saved view to the server.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L655">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `set_columns`

```python theme={null}
set_columns(*columns: 'str') → SavedView
```

Set the columns to be displayed in the grid.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L609">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `show_column`

```python theme={null}
show_column(col_name: 'str') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L603">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `sort_by`

```python theme={null}
sort_by(field: 'str', direction: 'SortDirection') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L887">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `to_grid`

```python theme={null}
to_grid(limit: 'int | None' = None) → Grid
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L768">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `to_rich_table_str`

```python theme={null}
to_rich_table_str() → str
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L751">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `ui_url`

```python theme={null}
ui_url() → str | None
```

URL to show this saved view in the UI.

Note this is the "result" page with traces etc, not the URL for the view object.

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/flow/saved_view.py#L729">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `unpin_column`

```python theme={null}
unpin_column(col_name: 'str') → SavedView
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_handlers/Audio/audio.py#L79">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

## <kbd>class</kbd> `Audio`

A class representing audio data in a supported format (wav or mp3).

This class handles audio data storage and provides methods for loading from different sources and exporting to files.

**Attributes:**

* <b>`format`</b>:  The audio format (currently supports 'wav' or 'mp3')
* <b>`data`</b>:  The raw audio data as bytes

**Args:**

* <b>`data`</b>: The audio data (bytes or base64 encoded string)

* <b>`format`</b>: The audio format ('wav' or 'mp3')

* <b>`validate_base64`</b>: Whether to attempt base64 decoding of the input data
  **Raises:**

* <b>`ValueError`</b>:  If audio data is empty or format is not supported

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_handlers/Audio/audio.py#L104">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `__init__`

```python theme={null}
__init__(
    data: 'bytes',
    format: 'SUPPORTED_FORMATS_TYPE',
    validate_base64: 'bool' = True
) → None
```

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_handlers/Audio/audio.py#L172">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>method</kbd> `export`

```python theme={null}
export(path: 'str | bytes | Path | PathLike') → None
```

Export audio data to a file.

**Args:**

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_handlers/Audio/audio.py#L119">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_data`

```python theme={null}
from_data(data: 'str | bytes', format: 'str') → Audio
```

Create an Audio object from raw data and specified format.

* <b>`path`</b>: Path where the audio file should be written
  **Args:**

* <b>`data`</b>: Audio data as bytes or base64 encoded string

* <b>`format`</b>: Audio format ('wav' or 'mp3')
  **Returns:**

* <b>`Audio`</b>:  A new Audio instance

**Raises:**

* <b>`ValueError`</b>:  If format is not supported

***

<a href="https://github.com/wandb/weave/blob/0.52.10/weave/type_handlers/Audio/audio.py#L144">
  <img align="right" src="https://img.shields.io/badge/-source-cccccc?style=flat-square" />
</a>

### <kbd>classmethod</kbd> `from_path`

```python theme={null}
from_path(path: 'str | bytes | Path | PathLike') → Audio
```

Create an Audio object from a file path.

**Args:**

* <b>`path`</b>: Path to an audio file (must have .wav or .mp3 extension)
  **Returns:**

* <b>`Audio`</b>:  A new Audio instance loaded from the file

**Raises:**

* <b>`ValueError`</b>:  If file doesn't exist or has unsupported extension
