diff --git a/docs/docs/guides/tracking/tracing.mdx b/docs/docs/guides/tracking/tracing.mdx index 4ced9240c61..2a2b81e4576 100644 --- a/docs/docs/guides/tracking/tracing.mdx +++ b/docs/docs/guides/tracking/tracing.mdx @@ -76,13 +76,48 @@ def my_function(name: str): return f"Hello, {name}!" # Call your function -- Weave will automatically track inputs and outputs -print(my_function.call("World")) +print(my_function("World")) ``` +This works for both functions as well as methods on classes: + + +```python showLineNumbers +import weave + +# Initialize Weave Tracing +weave.init("intro-example") + +class MyClass: + # Decorate your method + @weave.op + def my_method(self, name: str): + return f"Hello, {name}!" + +instance = MyClass() + +# Call your method -- Weave will automatically track inputs and outputs +print(instance.my_method("World")) +``` + +Sometimes it is useful to get a handle to the `Call` object itself. You can do this by calling the `op.call` method, which returns both the result and the `Call` object. For example: + +```python showLineNumbers +result, call = my_function.call("World") +``` + +Then, `call` can be used to set / update / fetch additional properties (most commonly used to get the ID of the call to be used for feedback). + :::note If your op is a method on a class, you need to pass the instance as the first argument to the op (see example below). ::: +```python showLineNumbers +# Notice that we pass the `instance` as the first argument. +# highlight-next-line +print(instance.my_method.call(instance, "World")) +``` + ```python showLineNumbers import weave @@ -106,7 +141,7 @@ instance.my_method.call(instance, "World") Sometimes you may want to override the display name of a call. You can achieve this in one of four ways: -0. Change the display name at the time of calling the op: +1. Change the display name at the time of calling the op: ```python showLineNumbers result = my_function("World", __weave={"display_name": "My Custom Display Name"}) @@ -118,13 +153,13 @@ Using the `__weave` dictionary sets the call display name which will take preced ::: -1. Change the display name on a per-call basis. This uses the [`Op.call`](../../reference/python-sdk/weave/trace/weave.trace.op.md#function-call) method to return a `Call` object, which you can then use to set the display name using [`Call.set_display_name`](../../reference/python-sdk/weave/trace/weave.trace.weave_client.md#method-set_display_name). +2. Change the display name on a per-call basis. This uses the [`Op.call`](../../reference/python-sdk/weave/trace/weave.trace.op.md#function-call) method to return a `Call` object, which you can then use to set the display name using [`Call.set_display_name`](../../reference/python-sdk/weave/trace/weave.trace.weave_client.md#method-set_display_name). ```python showLineNumbers result, call = my_function.call("World") call.set_display_name("My Custom Display Name") ``` -2. Change the display name for all Calls of a given Op: +3. Change the display name for all Calls of a given Op: ```python showLineNumbers @weave.op(call_display_name="My Custom Display Name") @@ -132,7 +167,7 @@ def my_function(name: str): return f"Hello, {name}!" ``` -3. The `call_display_name` can also be a function that takes in a `Call` object and returns a string. The `Call` object will be passed automatically when the function is called, so you can use it to dynamically generate names based on the function's name, call inputs, attributes, etc. +4. The `call_display_name` can also be a function that takes in a `Call` object and returns a string. The `Call` object will be passed automatically when the function is called, so you can use it to dynamically generate names based on the function's name, call inputs, attributes, etc. 1. One common use case is just appending a timestamp to the function's name. diff --git a/docs/docs/reference/gen_notebooks/01-intro_notebook.md b/docs/docs/reference/gen_notebooks/01-intro_notebook.md index 20639f24fd7..19e49c027bf 100644 --- a/docs/docs/reference/gen_notebooks/01-intro_notebook.md +++ b/docs/docs/reference/gen_notebooks/01-intro_notebook.md @@ -13,7 +13,6 @@ title: Introduction Notebook -Weights & Biases # 🏃‍♀️ Quickstart diff --git a/docs/docs/reference/gen_notebooks/chain_of_density.md b/docs/docs/reference/gen_notebooks/chain_of_density.md index 9e9205e1d72..753b0f585ba 100644 --- a/docs/docs/reference/gen_notebooks/chain_of_density.md +++ b/docs/docs/reference/gen_notebooks/chain_of_density.md @@ -13,7 +13,6 @@ title: Chain of Density Summarization -Weights & Biases # Summarization using Chain of Density diff --git a/docs/docs/reference/gen_notebooks/custom_model_cost.md b/docs/docs/reference/gen_notebooks/custom_model_cost.md index 34fda9edbe4..fc7bf819c2a 100644 --- a/docs/docs/reference/gen_notebooks/custom_model_cost.md +++ b/docs/docs/reference/gen_notebooks/custom_model_cost.md @@ -13,7 +13,6 @@ title: Custom Model Cost -Weights & Biases # Setting up a custom cost model diff --git a/docs/docs/reference/gen_notebooks/dspy_prompt_optimization.md b/docs/docs/reference/gen_notebooks/dspy_prompt_optimization.md index 878d7c2dac8..5c7f7ca194a 100644 --- a/docs/docs/reference/gen_notebooks/dspy_prompt_optimization.md +++ b/docs/docs/reference/gen_notebooks/dspy_prompt_optimization.md @@ -13,7 +13,6 @@ title: Prompt Optimization -Weights & Biases # Optimizing LLM Workflows Using DSPy and Weave diff --git a/docs/docs/reference/gen_notebooks/feedback_prod.md b/docs/docs/reference/gen_notebooks/feedback_prod.md index d95c44777f5..9a55d833fe9 100644 --- a/docs/docs/reference/gen_notebooks/feedback_prod.md +++ b/docs/docs/reference/gen_notebooks/feedback_prod.md @@ -13,7 +13,6 @@ title: Log Feedback from Production -Weights & Biases diff --git a/docs/docs/reference/gen_notebooks/import_from_csv.md b/docs/docs/reference/gen_notebooks/import_from_csv.md index 58375ba87d2..26566835538 100644 --- a/docs/docs/reference/gen_notebooks/import_from_csv.md +++ b/docs/docs/reference/gen_notebooks/import_from_csv.md @@ -13,7 +13,6 @@ title: Log Calls from Existing CSV -Weights & Biases # Import Traces from 3rd Party Systems diff --git a/docs/docs/reference/gen_notebooks/online_monitoring.md b/docs/docs/reference/gen_notebooks/online_monitoring.md index bfe048de9bb..4f50c51e3a5 100644 --- a/docs/docs/reference/gen_notebooks/online_monitoring.md +++ b/docs/docs/reference/gen_notebooks/online_monitoring.md @@ -13,7 +13,6 @@ title: Integrating with Weave - Production Dashboard -Weights & Biases # Integrating with Weave: Production Dashboard diff --git a/docs/docs/reference/gen_notebooks/pii.md b/docs/docs/reference/gen_notebooks/pii.md index e042d0ea738..001aca82a61 100644 --- a/docs/docs/reference/gen_notebooks/pii.md +++ b/docs/docs/reference/gen_notebooks/pii.md @@ -13,7 +13,6 @@ title: Handling and Redacting PII -Weights & Biases # How to use Weave with PII data: diff --git a/docs/intro_notebook.ipynb b/docs/intro_notebook.ipynb index c491787657f..042d1a79ba0 100644 --- a/docs/intro_notebook.ipynb +++ b/docs/intro_notebook.ipynb @@ -11,7 +11,7 @@ "---\n", "docusaurus_head_meta::end -->\n", "\n", - "\"Weights\n", + "" ] }, diff --git a/docs/notebooks/chain_of_density.ipynb b/docs/notebooks/chain_of_density.ipynb index c7bc1136325..9b6869d8c3a 100644 --- a/docs/notebooks/chain_of_density.ipynb +++ b/docs/notebooks/chain_of_density.ipynb @@ -10,7 +10,7 @@ "---\n", "docusaurus_head_meta::end -->\n", "\n", - "\"Weights\n", + "" ] }, diff --git a/docs/notebooks/custom_model_cost.ipynb b/docs/notebooks/custom_model_cost.ipynb index 42f5e9007a1..87b0187593d 100644 --- a/docs/notebooks/custom_model_cost.ipynb +++ b/docs/notebooks/custom_model_cost.ipynb @@ -12,7 +12,7 @@ "---\n", "docusaurus_head_meta::end -->\n", "\n", - "\"Weights\n", + "" ] }, diff --git a/docs/notebooks/dspy_prompt_optimization.ipynb b/docs/notebooks/dspy_prompt_optimization.ipynb index e2da185e2ad..74eba9f390f 100644 --- a/docs/notebooks/dspy_prompt_optimization.ipynb +++ b/docs/notebooks/dspy_prompt_optimization.ipynb @@ -10,7 +10,7 @@ "---\n", "docusaurus_head_meta::end -->\n", "\n", - "\"Weights\n", + "" ] }, diff --git a/docs/notebooks/feedback_prod.ipynb b/docs/notebooks/feedback_prod.ipynb index b1b7f312dbd..fad44ddd310 100644 --- a/docs/notebooks/feedback_prod.ipynb +++ b/docs/notebooks/feedback_prod.ipynb @@ -10,7 +10,7 @@ "---\n", "docusaurus_head_meta::end -->\n", "\n", - "\"Weights\n", + "" ] }, diff --git a/docs/notebooks/import_from_csv.ipynb b/docs/notebooks/import_from_csv.ipynb index dd7114d006c..1811ef62259 100644 --- a/docs/notebooks/import_from_csv.ipynb +++ b/docs/notebooks/import_from_csv.ipynb @@ -10,7 +10,7 @@ "---\n", "docusaurus_head_meta::end -->\n", "\n", - "\"Weights\n", + "" ] }, diff --git a/docs/notebooks/online_monitoring.ipynb b/docs/notebooks/online_monitoring.ipynb index e743c23d648..937a23dd641 100644 --- a/docs/notebooks/online_monitoring.ipynb +++ b/docs/notebooks/online_monitoring.ipynb @@ -10,7 +10,7 @@ "---\n", "docusaurus_head_meta::end -->\n", "\n", - "\"Weights\n", + "" ] }, diff --git a/docs/notebooks/pii.ipynb b/docs/notebooks/pii.ipynb index 7d89df49828..ad4650105f9 100644 --- a/docs/notebooks/pii.ipynb +++ b/docs/notebooks/pii.ipynb @@ -10,7 +10,7 @@ "---\n", "docusaurus_head_meta::end -->\n", "\n", - "\"Weights\n", + "" ] }, diff --git a/weave_query/examples/experimental/prompts_dev/generate_synth_mon_board.ipynb b/weave_query/examples/experimental/prompts_dev/generate_synth_mon_board.ipynb index f653846de52..000e2b1eb42 100644 --- a/weave_query/examples/experimental/prompts_dev/generate_synth_mon_board.ipynb +++ b/weave_query/examples/experimental/prompts_dev/generate_synth_mon_board.ipynb @@ -5,7 +5,7 @@ "id": "4549831c", "metadata": {}, "source": [ - "\"Weights\n", + "\n", "\n", "\n", diff --git a/weave_query/examples/experimental/prompts_dev/synthetic_openai_data.ipynb b/weave_query/examples/experimental/prompts_dev/synthetic_openai_data.ipynb index be116be6d49..884d602b0ae 100644 --- a/weave_query/examples/experimental/prompts_dev/synthetic_openai_data.ipynb +++ b/weave_query/examples/experimental/prompts_dev/synthetic_openai_data.ipynb @@ -5,7 +5,7 @@ "id": "4549831c", "metadata": {}, "source": [ - "\"Weights\n", + "\n", "# Generate Synthetic Trace Data\n", "\n", diff --git a/weave_query/examples/prompts/llm_monitoring/openai_client_quickstart.ipynb b/weave_query/examples/prompts/llm_monitoring/openai_client_quickstart.ipynb index f0fc64bdceb..c245a806e97 100644 --- a/weave_query/examples/prompts/llm_monitoring/openai_client_quickstart.ipynb +++ b/weave_query/examples/prompts/llm_monitoring/openai_client_quickstart.ipynb @@ -5,7 +5,7 @@ "id": "30ccfdbc", "metadata": {}, "source": [ - "\"Weights\n", + "\n", "\n", "
\n", diff --git a/weave_query/examples/prompts/llm_monitoring/openai_proxy_quickstart.ipynb b/weave_query/examples/prompts/llm_monitoring/openai_proxy_quickstart.ipynb index c959bea9e7d..9effcdb7817 100644 --- a/weave_query/examples/prompts/llm_monitoring/openai_proxy_quickstart.ipynb +++ b/weave_query/examples/prompts/llm_monitoring/openai_proxy_quickstart.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\"Weights\n", + "
\n", "
\n", "\n", diff --git a/weave_query/examples/prompts/trace_debugging/dev/synthetic_trace_data.ipynb b/weave_query/examples/prompts/trace_debugging/dev/synthetic_trace_data.ipynb index be0eae16ac5..2c08982cf1e 100644 --- a/weave_query/examples/prompts/trace_debugging/dev/synthetic_trace_data.ipynb +++ b/weave_query/examples/prompts/trace_debugging/dev/synthetic_trace_data.ipynb @@ -5,7 +5,7 @@ "id": "7aaafefa-ec2f-4feb-ad07-e7f2df83f3ea", "metadata": {}, "source": [ - "\"Weights\n", + "\n", "
\n", "
\n", diff --git a/weave_query/examples/prompts/trace_debugging/trace_quickstart_langchain.ipynb b/weave_query/examples/prompts/trace_debugging/trace_quickstart_langchain.ipynb index 72c3257f562..6d4e6815cfd 100644 --- a/weave_query/examples/prompts/trace_debugging/trace_quickstart_langchain.ipynb +++ b/weave_query/examples/prompts/trace_debugging/trace_quickstart_langchain.ipynb @@ -5,7 +5,7 @@ "id": "957b839e-ae72-4608-8f17-454e95c6c76c", "metadata": {}, "source": [ - "\"Weights\n", + "\n", "
\n", " \"Open\n",