From cf32a67e00a630744c8b1e48c9758da8fdefcd5e Mon Sep 17 00:00:00 2001 From: Hai The Dude Date: Mon, 19 Aug 2024 21:39:19 -0400 Subject: [PATCH 1/4] docs: explanation and steps for tracing schema-based tool calls --- .../tracing/log_tool_call_traces.mdx | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx diff --git a/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx b/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx new file mode 100644 index 00000000..c1f2cf83 --- /dev/null +++ b/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx @@ -0,0 +1,48 @@ +--- +sidebar_position: 9 +--- + +import { + CodeTabs, + PythonBlock, +} from "@site/src/components/InstructionsWithCode"; + +# Log schema-based tool call traces + +If you want to log tool calls but your tools are function names in a schema dictionary or JSON, then manually trace it with `langsmith.trace` at the point where your tool is executed or chosen. + +Wrap the tool call result (or tool execution part) with `async with langsmith.trace(name=chosen_tool, inputs=chosen_tool["args"], run_type="tool"):`. + +The following code snippets show how to log a schema-based tool call in Python. You'd add `langsmith.trace` right when the tool is chosen / executed. + +Here's an example of a schema-based tool definition, and logging the tool trace when the tool is executed. + + + +Because these are just schemas for tools and not real functions, we log the result of a tool call after the tool is chosen / executed. + + + From 2eb3af984d47f141415d28cfecced488dc204a0c Mon Sep 17 00:00:00 2001 From: Hai The Dude Date: Mon, 19 Aug 2024 21:40:47 -0400 Subject: [PATCH 2/4] docs: removed redundant sentences --- .../how_to_guides/tracing/log_tool_call_traces.mdx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx b/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx index c1f2cf83..62c21ce1 100644 --- a/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx +++ b/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx @@ -9,13 +9,11 @@ import { # Log schema-based tool call traces -If you want to log tool calls but your tools are function names in a schema dictionary or JSON, then manually trace it with `langsmith.trace` at the point where your tool is executed or chosen. +If you want to log tool calls but your tools are not real functions but tool names in a schema dictionary or JSON, then trace it with `langsmith.trace` at the point where your tool is executed or chosen. Wrap the tool call result (or tool execution part) with `async with langsmith.trace(name=chosen_tool, inputs=chosen_tool["args"], run_type="tool"):`. -The following code snippets show how to log a schema-based tool call in Python. You'd add `langsmith.trace` right when the tool is chosen / executed. - -Here's an example of a schema-based tool definition, and logging the tool trace when the tool is executed. +The following code snippets show how to log a schema-based tool call in Python. Date: Mon, 19 Aug 2024 21:44:43 -0400 Subject: [PATCH 3/4] docs: removed property name that wasn't generic --- .../version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx b/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx index 62c21ce1..a5406bad 100644 --- a/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx +++ b/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx @@ -24,7 +24,6 @@ The following code snippets show how to log a schema-based tool call in Python. "name": "get_weather_in_ottawa", "description": "Get the weather in Ottawa, Canada in Celsius.", }, - "is_frontend": False, }, { "icon": "replace", From 498bbc8564fa5f6a1caa52235510905660b36380 Mon Sep 17 00:00:00 2001 From: Hai The Dude Date: Mon, 19 Aug 2024 21:45:15 -0400 Subject: [PATCH 4/4] refactor --- .../version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx | 2 -- 1 file changed, 2 deletions(-) diff --git a/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx b/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx index a5406bad..3e39585d 100644 --- a/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx +++ b/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx @@ -18,7 +18,6 @@ The following code snippets show how to log a schema-based tool call in Python.