API Overview
class WeaveClient
method __init__
property num_outstanding_jobs
Returns the total number of pending jobs across all executors and the server. This property can be used to check the progress of background tasks without blocking the main thread. Returns:int
: The total number of pending jobs
method add_cost
llm_id
: The ID of the LLM. eg “gpt-4o-mini-2024-07-18”prompt_token_cost
: The cost per prompt token. eg .0005completion_token_cost
: The cost per completion token. eg .0015effective_date
: Defaults to the current date. A datetime.datetime object.provider_id
: The provider of the LLM. Defaults to “default”. eg “openai”prompt_token_cost_unit
: The unit of the cost for the prompt tokens. Defaults to “USD”. (Currently unused, will be used in the future to specify the currency type for the cost eg “tokens” or “time”)completion_token_cost_unit
: The unit of the cost for the completion tokens. Defaults to “USD”. (Currently unused, will be used in the future to specify the currency type for the cost eg “tokens” or “time”) Returns: A CostCreateRes object. Which has one field called a list of tuples called ids. Each tuple contains the llm_id and the id of the created cost object.
method call
method calls
method create_call
op
: The operation producing the call, or the name of an anonymous operation.inputs
: The inputs to the operation.parent
: The parent call. If parent is not provided, the current run is used as the parent.display_name
: The display name for the call. Defaults to None.attributes
: The attributes for the call. Defaults to None.use_stack
: Whether to push the call onto the runtime stack. Defaults to True. Returns: The created Call object.
method delete_all_object_versions
object_name
: The name of the object whose versions should be deleted. Returns: The number of versions deleted.
method delete_all_op_versions
op_name
: The name of the op whose versions should be deleted. Returns: The number of versions deleted.
method delete_call
method delete_calls
method delete_object_version
method delete_object_versions
-
call_ids
: A list of call IDs to delete. Ex: [“2F0193e107-8fcf-7630-b576-977cc3062e2e”] Args: -
object_name
: The name of the object whose versions should be deleted. -
digests
: List of digests to delete. Can include aliases like “latest” or “v0”. Returns: The number of versions deleted.
method delete_op_version
method fail_call
method feedback
method finish
method finish_call
call.summary
are deep-merged with computed summary statistics (e.g. usage and status counts) before being written to the database.
method flush
method get
method get_call
-
use_progress_bar
: Whether to display a progress bar during flush. Set to False for environments where a progress bar would not render well (e.g., CI environments). -
callback
: Optional callback function that receives status updates. Overrides use_progress_bar. Args: -
call_id
: The ID of the call to get. -
include_costs
: If true, cost info is included at summary.weave -
include_feedback
: If true, feedback info is included at summary.weave.feedback -
columns
: A list of columns to include in the response. If None, all columns are included. Specifying fewer columns may be more performant. Some columns are always included id, project_id, trace_id, op_name, started_at Returns: A call object.
method get_calls
columns
and use filter
or query
to reduce result size.
Args:
filter
: High-level filter for narrowing results by fields likeop_name
,parent_ids
, etc.limit
: Maximum number of calls to return.offset
: Number of calls to skip before returning results (used for pagination).sort_by
: List of fields to sort the results by (e.g.,started_at desc
).query
: A mongo-like expression for advanced filtering. Not all Mongo operators are supported.include_costs
: If True, includes token/cost info insummary.weave
.include_feedback
: If True, includes feedback insummary.weave.feedback
.columns
: List of fields to return per call. Reducing this can significantly improve performance. (Some fields likeid
,trace_id
,op_name
, andstarted_at
are always included.)scored_by
: Filter by one or more scorers (name or ref URI). Multiple scorers are AND-ed.page_size
: Number of calls fetched per page. Tune this for performance in large queries.
CallsIter
: An iterator overCall
objects. Supports slicing, iteration, and.to_pandas()
.
method get_evaluation
weave:///entity/project/object/Evaluation:version
You can also get the evaluation by its “friendly” name: get_evaluation(“Evaluation:v1”)
Args:
uri
(str): The unique resource identifier of the evaluation to retrieve.
Evaluation
: The Evaluation object corresponding to the provided URI.
TypeError
: If the object at the URI is not an Evaluation instance.ValueError
: If the URI is invalid or the object cannot be found.
method get_evaluations
list[Evaluation]
: A list of all Evaluation objects in the current project. Empty list if no evaluations are found or if all conversions fail.
method get_feedback
query
: A mongo-style query expression. For convenience, also accepts a feedback UUID string.reaction
: For convenience, filter by a particular reaction emoji.offset
: The offset to start fetching feedback objects from.limit
: The maximum number of feedback objects to fetch. Returns: A FeedbackQuery object.
method purge_costs
method query_costs
ids
: The cost IDs to purge. Can be a single ID or a list of IDs. Examples:
query
: A mongo-style query expression. For convenience, also accepts a cost UUID string.llm_ids
: For convenience, filter for a set of llm_ids.offset
: The offset to start fetching cost objects from.limit
: The maximum number of cost objects to fetch. Returns: A CostQuery object.
method save
val
: The object to save.name
: The name to save the object under.branch
: The branch to save the object under. Defaults to “latest”. Returns: A deserialized version of the saved object.
class Call
A Call represents a single operation executed as part of a trace.
attributes
are frozen once the call is created. Use :func:weave.attributes
or create_call(..., attributes=...)
to populate metadata beforehand. The summary
dictionary may be modified while the call is running; its contents are deep-merged with computed summary values when :meth:WeaveClient.finish_call
is invoked.
method __init__
property display_name
property feedback
property func_name
The decorated function’s name that produced this call. This is different fromop_name
which is usually the ref of the op.
property op_name
property ref
property ui_url
method apply_scorer
apply_scorer
is a method that applies a Scorer to a Call. This is useful for guarding application logic with a scorer and/or monitoring the quality of critical ops. Scorers are automatically logged to Weave as Feedback and can be used in queries & analysis.
Args:
scorer
: The Scorer to apply.additional_scorer_kwargs
: Additional kwargs to pass to the scorer. This is useful for passing in additional context that is not part of the call inputs.useful for passing in additional context that is not part of the call inputs. Returns: The result of the scorer application in the form of anApplyScorerResult
.
method children
page_size
: Tune performance by changing the number of calls fetched at a time. Returns: An iterator of calls.
method delete
method remove_display_name
method set_display_name
name
: The display name to set for the call. Example: