langchain_community.callbacks.tracers.wandb.RunProcessor¶
- class langchain_community.callbacks.tracers.wandb.RunProcessor(wandb_module: Any, trace_module: Any)[source]¶
- Handles the conversion of a LangChain Runs into a WBTraceTree. - Methods - __init__(wandb_module, trace_module)- build_tree(runs)- Builds a nested dictionary from a list of runs. :param runs: The list of runs to build the tree from. :return: The nested dictionary representing the langchain Run in a tree structure compatible with WBTraceTree. - flatten_run(run)- Utility to flatten a nest run object into a list of runs. - modify_serialized_iterative(runs[, ...])- Utility to modify the serialized field of a list of runs dictionaries. - process_model(run)- Utility to process a run for wandb model_dict serialization. - process_span(run)- Converts a LangChain Run into a W&B Trace Span. - truncate_run_iterative(runs[, keep_keys])- Utility to truncate a list of runs dictionaries to only keep the specified - build_tree(runs: List[Dict[str, Any]]) Dict[str, Any][source]¶
- Builds a nested dictionary from a list of runs. :param runs: The list of runs to build the tree from. :return: The nested dictionary representing the langchain Run in a tree - structure compatible with WBTraceTree. 
 - flatten_run(run: Dict[str, Any]) List[Dict[str, Any]][source]¶
- Utility to flatten a nest run object into a list of runs. :param run: The base run to flatten. :return: The flattened list of runs. 
 - modify_serialized_iterative(runs: List[Dict[str, Any]], exact_keys: Tuple[str, ...] = (), partial_keys: Tuple[str, ...] = ()) List[Dict[str, Any]][source]¶
- Utility to modify the serialized field of a list of runs dictionaries. removes any keys that match the exact_keys and any keys that contain any of the partial_keys. recursively moves the dictionaries under the kwargs key to the top level. changes the “id” field to a string “_kind” field that tells WBTraceTree how to visualize the run. promotes the “serialized” field to the top level. - Parameters
- runs – The list of runs to modify. 
- exact_keys – A tuple of keys to remove from the serialized field. 
- partial_keys – A tuple of partial keys to remove from the serialized field. 
 
- Returns
- The modified list of runs. 
 
 - process_model(run: Run) Optional[Dict[str, Any]][source]¶
- Utility to process a run for wandb model_dict serialization. :param run: The run to process. :return: The convert model_dict to pass to WBTraceTree. 
 - process_span(run: Run) Optional['Span'][source]¶
- Converts a LangChain Run into a W&B Trace Span. :param run: The LangChain Run to convert. :return: The converted W&B Trace Span. 
 - truncate_run_iterative(runs: List[Dict[str, Any]], keep_keys: Tuple[str, ...] = ()) List[Dict[str, Any]][source]¶
- Utility to truncate a list of runs dictionaries to only keep the specified
- keys in each run. 
 - Parameters
- runs – The list of runs to truncate. 
- keep_keys – The keys to keep in each run. 
 
- Returns
- The truncated list of runs.