LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
  • RemoteGraph
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDKRemoteGraph
Language
Theme
Pythonlangsmithrun_helperstraceable
Function●Since v0.0

traceable

Trace a function with langsmith.

Copy
traceable(
  *args: Any = (),
  **kwargs: Any = {}
) -> Union[Callable, Callable[[Callable], Callable]]

Requires that LANGSMITH_TRACING_V2 be set to 'true' in the environment.

Used in Docs

  • Access the current run (span) within a traced function
  • Conditional tracing
  • Configure threads
  • Cost tracking
  • Custom instrumentation
(6 more not shown)

Parameters

NameTypeDescription
run_type*unknown

The type of run (span) to create.

Examples: llm, chain, tool, prompt, retriever, etc.

Defaults to "chain".

name*unknown

The name of the run. Defaults to the function name.

metadata*unknown

The metadata to add to the run. Defaults to None.

tags*unknown

The tags to add to the run. Defaults to None.

client*unknown

The client to use for logging the run to LangSmith. Defaults to None, which will use the default client.

reduce_fn*unknown

A function to reduce the output of the function if the function returns a generator.

Defaults to None, which means the values will be logged as a list.

Note

If the iterator is never exhausted (e.g. the function returns an infinite generator), this will never be called, and the run itself will be stuck in a pending state.

project_name*unknown

The name of the project to log the run to.

Defaults to None, which will use the default project.

process_inputs*unknown

Custom serialization / processing function for inputs.

Defaults to None.

process_outputs*unknown

Custom serialization / processing function for outputs.

Defaults to None.

dangerously_allow_filesystem*unknown

Whether to allow filesystem access for attachments.

Defaults to False.

Traces that reference local filepaths will be uploaded to LangSmith. In general, network-hosted applications should not be using this because referenced files are usually on the user's machine, not the host machine.

enabled*unknown

Whether tracing is enabled for this function.

Defaults to None, which will use the default value from the current context.

exceptions_to_handle*unknown

Exception types to ignore when logging errors.

If an exception of one of these types is raised, the run will still be recorded but the error field will be None instead of containing the full traceback.

Defaults to None.

View source on GitHub