RunTree#
- class langsmith.run_trees.RunTree(*, id: UUID = None, name: str, start_time: datetime = None, run_type: str = 'chain', end_time: datetime | None = None, extra: Dict = None, error: str | None = None, serialized: dict | None = None, events: List[Dict] = None, inputs: dict = None, outputs: dict | None = None, reference_example_id: UUID | None = None, parent_run_id: UUID | None = None, tags: List[str] | None = None, attachments: Dict[str, Tuple[str, bytes] | Attachment | Tuple[str, Path]] | Dict[str, AttachmentInfo] = None, parent_run: RunTree | None = None, parent_dotted_order: str | None = None, child_runs: List[RunTree] = None, project_name: str = None, project_id: UUID | None = None, ls_client: Any | None = None, dotted_order: str = '', trace_id: UUID = '', dangerously_allow_filesystem: bool | None = False)[source]#
用于发布运行的带反向引用的运行模式。
通过解析和验证来自关键字参数的输入数据来创建新模型。
如果输入数据无法解析为有效模型,则引发 ValidationError。
属性
client
返回客户端。
metadata
检索元数据(如果有)。
revision_id
检索修订 ID(如果有)。
方法
__init__
(**data)通过解析和验证来自关键字参数的输入数据来创建新模型。
add_event
(events)向事件列表中添加一个事件。
add_inputs
(inputs)将给定的输出更新插入到运行中。
add_metadata
(metadata)向运行添加元数据。
add_outputs
(outputs)将给定的输出更新插入到运行中。
add_tags
(tags)向运行添加标签。
construct
([_fields_set])从受信任或预验证的数据创建新的模型设置 __dict__ 和 __fields_set__。
copy
(*[, include, exclude, update, deep])复制模型,可以选择包含、排除和更改哪些字段。
create_child
(name[, run_type, run_id, ...])向运行树添加一个子运行。
dict
(*[, include, exclude, by_alias, ...])生成模型的字典表示形式,可以选择指定要包含或排除的字段。
end
(*[, outputs, error, end_time, events, ...])设置运行和所有子运行的结束时间。
ensure_dotted_order
(values)确保运行的点状顺序。
from_dotted_order
(dotted_order, **kwargs)从提供的点状顺序创建新的“子” span。
from_headers
(headers, **kwargs)从提供的标头创建新的“父” span。
from_orm
(obj)from_runnable_config
(config, **kwargs)从提供的可运行配置创建新的“子” span。
get_url
()返回运行的 URL。
infer_defaults
(values)为运行分配名称。
json
(*[, include, exclude, by_alias, ...])生成模型的 JSON 表示形式,include 和 exclude 参数与 dict() 相同。
parse_file
(path, *[, content_type, ...])parse_obj
(obj)parse_raw
(b, *[, content_type, encoding, ...])patch
()在后台线程中将运行树修补到 API。
post
([exclude_child_runs])异步将运行树发布到 API。
schema
([by_alias, ref_template])schema_json
(*[, by_alias, ref_template])将 RunTree 作为标头的字典返回。
update_forward_refs
(**localns)尝试基于此模型、globalns 和 localns 更新字段上的 ForwardRefs。
validate
(value)wait
()等待所有 _futures 完成。
- 参数:
id (UUID)
name (str)
start_time (datetime)
run_type (str)
end_time (datetime | None)
extra (Dict)
error (str | None)
serialized (dict | None)
events (List[Dict])
inputs (dict)
outputs (dict | None)
reference_example_id (UUID | None)
parent_run_id (UUID | None)
tags (List[str] | None)
attachments (Dict[str, Tuple[str, bytes] | Attachment | Tuple[str, Path]] | Dict[str, AttachmentInfo])
parent_run (RunTree | None)
parent_dotted_order (str | None)
child_runs (List[RunTree])
project_name (str)
project_id (UUID | None)
ls_client (Any | None)
dotted_order (str)
trace_id (UUID)
dangerously_allow_filesystem (bool | None)
- __init__(**data: Any) None #
通过解析和验证来自关键字参数的输入数据来创建新模型。
如果输入数据无法解析为有效模型,则引发 ValidationError。
- 参数:
data (Any)
- 返回类型:
None
- add_event(events: RunEvent | Sequence[RunEvent] | Sequence[dict] | dict | str) None [source]#
向事件列表中添加一个事件。
- 参数:
- 返回类型:
None
- :paramSequence[dict], dict, str]):
要添加的事件。它可以是单个事件、事件序列、字典序列、字典或字符串。
- add_inputs(inputs: Dict[str, Any]) None [source]#
将给定的输出更新插入到运行中。
- 参数:
outputs (Dict[str, Any]) – 包含要添加的输出的字典。
inputs (Dict[str, Any])
- 返回:
None
- 返回类型:
None
- add_metadata(metadata: Dict[str, Any]) None [source]#
向运行添加元数据。
- 参数:
metadata (Dict[str, Any])
- 返回类型:
None
- add_outputs(outputs: Dict[str, Any]) None [source]#
将给定的输出更新插入到运行中。
- 参数:
outputs (Dict[str, Any]) – 包含要添加的输出的字典。
- 返回:
None
- 返回类型:
None
- add_tags(tags: Sequence[str] | str) None [source]#
向运行添加标签。
- 参数:
tags (Sequence[str] | str)
- 返回类型:
None
- classmethod construct(_fields_set: SetStr | None = None, **values: Any) Model #
从受信任或预验证的数据创建新的模型设置 __dict__ 和 __fields_set__。默认值会被考虑,但不执行其他验证。 行为就像设置了 Config.extra = ‘allow’,因为它会添加所有传递的值
- 参数:
_fields_set (SetStr | None)
values (Any)
- 返回类型:
Model
- copy(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, update: DictStrAny | None = None, deep: bool = False) Model #
复制模型,可以选择包含、排除和更改哪些字段。
- 参数:
include (AbstractSetIntStr | MappingIntStrAny | None) – 要在新模型中包含的字段
exclude (AbstractSetIntStr | MappingIntStrAny | None) – 要从新模型中排除的字段,与值一样,这优先于 include
update (DictStrAny | None) – 要在新模型中更改/添加的值。注意:数据在创建新模型之前未经过验证:您应该信任此数据
deep (bool) – 设置为 True 以创建模型的深层副本
self (Model)
- 返回:
新模型实例
- 返回类型:
Model
- create_child(name: str, run_type: Literal['tool', 'chain', 'llm', 'retriever', 'embedding', 'prompt', 'parser'] = 'chain', *, run_id: UUID | str | None = None, serialized: Dict | None = None, inputs: Dict | None = None, outputs: Dict | None = None, error: str | None = None, reference_example_id: UUID | None = None, start_time: datetime | None = None, end_time: datetime | None = None, tags: List[str] | None = None, extra: Dict | None = None, attachments: Dict[str, Tuple[str, bytes] | Attachment | Tuple[str, Path]] | None = None) RunTree [source]#
向运行树添加一个子运行。
- 参数:
name (str)
run_type (Literal['tool', 'chain', 'llm', 'retriever', 'embedding', 'prompt', 'parser']) (run_type (字面量['tool', 'chain', 'llm', 'retriever', 'embedding', 'prompt', 'parser']))
run_id (UUID | str | None) (run_id (UUID | 字符串 | None))
serialized (Dict | None) (serialized (字典 | None))
inputs (Dict | None) (inputs (字典 | None))
outputs (Dict | None) (outputs (字典 | None))
error (str | None)
reference_example_id (UUID | None)
start_time (datetime | None) (start_time (datetime | None))
end_time (datetime | None)
tags (List[str] | None)
extra (Dict | None) (extra (字典 | None))
attachments (Dict[str, Tuple[str, bytes] | Attachment | Tuple[str, Path]] | None) (attachments (字典[字符串, 元组[字符串, 字节] | 附件 | 元组[字符串, 路径]] | None))
- 返回类型:
- dict(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny #
生成模型的字典表示形式,可以选择指定要包含或排除的字段。
- 参数:
include (AbstractSetIntStr | MappingIntStrAny | None) (include (AbstractSetIntStr | MappingIntStrAny | None))
exclude (AbstractSetIntStr | MappingIntStrAny | None) (exclude (AbstractSetIntStr | MappingIntStrAny | None))
by_alias (bool) (by_alias (布尔值))
skip_defaults (bool | None) (skip_defaults (布尔值 | None))
exclude_unset (bool) (exclude_unset (布尔值))
exclude_defaults (bool) (exclude_defaults (布尔值))
exclude_none (bool) (exclude_none (布尔值))
- 返回类型:
DictStrAny (DictStrAny)
- end(*, outputs: Dict | None = None, error: str | None = None, end_time: datetime | None = None, events: Sequence[RunEvent] | None = None, metadata: Dict[str, Any] | None = None) None [source]#
设置运行和所有子运行的结束时间。
- classmethod ensure_dotted_order(values: dict) dict [source]# (classmethod ensure_dotted_order(values: dict) dict [source]# (类方法 ensure_dotted_order(values: dict) dict [source]#))
确保运行的点状顺序。
- 参数:
values (dict) (values (字典))
- 返回类型:
dict (字典)
- classmethod from_dotted_order(dotted_order: str, **kwargs: Any) RunTree [source]# (classmethod from_dotted_order(dotted_order: str, **kwargs: Any) RunTree [source]# (类方法 from_dotted_order(dotted_order: str, **kwargs: Any) RunTree [source]#))
Create a new ‘child’ span from the provided dotted order. (从提供的点状顺序创建一个新的“子” span。)
- 返回:
The new span. (新的 span。)
- 返回类型:
- 参数:
dotted_order (str)
kwargs (Any) (kwargs (Any))
- classmethod from_headers(headers: Mapping[str | bytes, str | bytes], **kwargs: Any) RunTree | None [source]# (classmethod from_headers(headers: Mapping[str | bytes, str | bytes], **kwargs: Any) RunTree | None [source]#))
Create a new ‘parent’ span from the provided headers. (从提供的 headers 创建一个新的“父” span。)
Extracts parent span information from the headers and creates a new span. Metadata and tags are extracted from the baggage header. The dotted order and trace id are extracted from the trace header. (从 headers 中提取父 span 信息并创建一个新的 span。元数据和标签从 baggage header 中提取。点状顺序和跟踪 ID 从 trace header 中提取。)
- classmethod from_orm(obj: Any) Model # (classmethod from_orm(obj: Any) Model # (类方法 from_orm(obj: Any) Model #))
- 参数:
obj (Any) (obj (Any))
- 返回类型:
Model
- classmethod from_runnable_config(config: dict | None, **kwargs: Any) RunTree | None [source]# (classmethod from_runnable_config(config: dict | None, **kwargs: Any) RunTree | None [source]# (类方法 from_runnable_config(config: dict | None, **kwargs: Any) RunTree | None [source]#))
Create a new ‘child’ span from the provided runnable config. (从提供的可运行配置创建一个新的“子” span。)
Requires langchain to be installed. (需要安装 langchain。)
- classmethod infer_defaults(values: dict) dict [source]# (classmethod infer_defaults(values: dict) dict [source]# (类方法 infer_defaults(values: dict) dict [source]#))
为运行分配名称。
- 参数:
values (dict) (values (字典))
- 返回类型:
dict (字典)
- json(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Callable[[Any], Any] | None = None, models_as_dict: bool = True, **dumps_kwargs: Any) str # (json(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Callable[[Any], Any] | None = None, models_as_dict: bool = True, **dumps_kwargs: Any) str #)
生成模型的 JSON 表示形式,include 和 exclude 参数与 dict() 相同。
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). (encoder 是一个可选函数,作为 default 提供给 json.dumps(),其他参数与 json.dumps() 相同。)
- 参数:
include (AbstractSetIntStr | MappingIntStrAny | None) (include (AbstractSetIntStr | MappingIntStrAny | None))
exclude (AbstractSetIntStr | MappingIntStrAny | None) (exclude (AbstractSetIntStr | MappingIntStrAny | None))
by_alias (bool) (by_alias (布尔值))
skip_defaults (bool | None) (skip_defaults (布尔值 | None))
exclude_unset (bool) (exclude_unset (布尔值))
exclude_defaults (bool) (exclude_defaults (布尔值))
exclude_none (bool) (exclude_none (布尔值))
encoder (Callable[[Any], Any] | None) (encoder (Callable[[Any], Any] | None))
models_as_dict (bool) (models_as_dict (布尔值))
dumps_kwargs (Any) (dumps_kwargs (Any))
- 返回类型:
str (字符串)
- classmethod parse_file(path: str | Path, *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model # (classmethod parse_file(path: str | Path, *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model # (类方法 parse_file(path: str | Path, *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model #))
- 参数:
path (str | Path) (path (字符串 | 路径))
content_type (str) (content_type (字符串))
encoding (str) (encoding (字符串))
proto (Protocol) (proto (Protocol))
allow_pickle (bool) (allow_pickle (布尔值))
- 返回类型:
Model
- classmethod parse_obj(obj: Any) Model # (classmethod parse_obj(obj: Any) Model # (类方法 parse_obj(obj: Any) Model #))
- 参数:
obj (Any) (obj (Any))
- 返回类型:
Model
- classmethod parse_raw(b: str | bytes, *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model # (classmethod parse_raw(b: str | bytes, *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model # (类方法 parse_raw(b: str | bytes, *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model #))
- 参数:
b (str | bytes) (b (字符串 | 字节))
content_type (str) (content_type (字符串))
encoding (str) (encoding (字符串))
proto (Protocol) (proto (Protocol))
allow_pickle (bool) (allow_pickle (布尔值))
- 返回类型:
Model
- post(exclude_child_runs: bool = True) None [source]# (post(exclude_child_runs: bool = True) None [source]#)
异步将运行树发布到 API。
- 参数:
exclude_child_runs (bool) (exclude_child_runs (布尔值))
- 返回类型:
None
- classmethod schema(by_alias: bool = True, ref_template: str = '#/definitions/{model}') DictStrAny # (classmethod schema(by_alias: bool = True, ref_template: str = '#/definitions/{model}') DictStrAny # (类方法 schema(by_alias: bool = True, ref_template: str = '#/definitions/{model}') DictStrAny #))
- 参数:
by_alias (bool) (by_alias (布尔值))
ref_template (str) (ref_template (字符串))
- 返回类型:
DictStrAny (DictStrAny)
- classmethod schema_json(*, by_alias: bool = True, ref_template: str = '#/definitions/{model}', **dumps_kwargs: Any) str # (classmethod schema_json(*, by_alias: bool = True, ref_template: str = '#/definitions/{model}', **dumps_kwargs: Any) str # (类方法 schema_json(*, by_alias: bool = True, ref_template: str = '#/definitions/{model}', **dumps_kwargs: Any) str #))
- 参数:
by_alias (bool) (by_alias (布尔值))
ref_template (str) (ref_template (字符串))
dumps_kwargs (Any) (dumps_kwargs (Any))
- 返回类型:
str (字符串)
- to_headers() Dict[str, str] [source]# (to_headers() Dict[str, str] [source]#)
将 RunTree 作为标头的字典返回。
- 返回类型:
Dict[str, str] (字典[字符串, 字符串])
- classmethod update_forward_refs(**localns: Any) None #
尝试基于此模型、globalns 和 localns 更新字段上的 ForwardRefs。
- 参数:
localns (Any)
- 返回类型:
None
- classmethod validate(value: Any) Model #
- 参数:
value (Any)
- 返回类型:
Model