运行#
- class langsmith.schemas.Run(
- _host_url: str | None = None,
- *,
- id: UUID,
- name: str,
- start_time: datetime,
- run_type: str,
- end_time: datetime | None = None,
- extra: dict | None = None,
- error: str | None = None,
- serialized: dict | None = None,
- events: list[dict] | None = 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,
- session_id: UUID | None = None,
- child_run_ids: list[UUID] | None = None,
- child_runs: list[Run] | None = None,
- feedback_stats: dict[str, Any] | None = None,
- app_path: str | None = None,
- manifest_id: UUID | None = None,
- status: str | None = None,
- prompt_tokens: int | None = None,
- completion_tokens: int | None = None,
- total_tokens: int | None = None,
- prompt_token_details: dict[str, int] | None = None,
- completion_token_details: dict[str, int] | None = None,
- first_token_time: datetime | None = None,
- total_cost: Decimal | None = None,
- prompt_cost: Decimal | None = None,
- completion_cost: Decimal | None = None,
- prompt_cost_details: dict[str, Decimal] | None = None,
- completion_cost_details: dict[str, Decimal] | None = None,
- parent_run_ids: list[UUID] | None = None,
- trace_id: UUID,
- dotted_order: str = '',
- in_dataset: bool | None = None,
从数据库加载时的运行模式。
初始化 Run 对象。
属性
input_cost
prompt_cost 的别名。
input_cost_details
prompt_cost_details 的别名。
input_token_details
prompt_token_details 的别名。
input_tokens
prompt_tokens 的别名。
metadata
检索元数据(如果有)。
output_cost
completion_cost 的别名。
output_cost_details
completion_cost_details 的别名。
output_token_details
output_token_details 的别名。
output_tokens
completion_tokens 的别名。
revision_id
检索修订 ID(如果有)。
url
此运行在应用程序中的 URL。
方法
__init__
([_host_url])初始化 Run 对象。
construct
([_fields_set])从受信任或预验证的数据创建新模型,设置 __dict__ 和 __fields_set__。
copy
(*[, include, exclude, update, deep])复制模型,可选地选择要包含、排除和更改的字段。
dict
(*[, include, exclude, by_alias, ...])生成模型的字典表示,可选地指定要包含或排除的字段。
from_orm
(obj)json
(*[, include, exclude, by_alias, ...])生成模型的 JSON 表示,include 和 exclude 参数与 dict() 相同。
parse_file
(path, *[, content_type, ...])parse_obj
(obj)parse_raw
(b, *[, content_type, encoding, ...])schema
([by_alias, ref_template])schema_json
(*[, by_alias, ref_template])update_forward_refs
(**localns)尝试根据此模型、全局命名空间和本地命名空间更新字段上的 ForwardRefs。
validate
(value)- 参数:
_host_url (str | None)
id (UUID)
name (str)
start_time (datetime)
run_type (str)
end_time (datetime | None)
extra (dict | None)
error (str | None)
serialized (dict | None)
events (list[dict] | None)
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])
session_id (UUID | None)
child_run_ids (list[UUID] | None)
child_runs (list[Run] | None)
feedback_stats (dict[str, Any] | None)
app_path (str | None)
manifest_id (UUID | None)
status (str | None)
prompt_tokens (int | None)
completion_tokens (int | None)
total_tokens (int | None)
prompt_token_details (dict[str, int] | None)
completion_token_details (dict[str, int] | None)
first_token_time (datetime | None)
total_cost (Decimal | None)
prompt_cost (Decimal | None)
completion_cost (Decimal | None)
prompt_cost_details (dict[str, Decimal] | None)
completion_cost_details (dict[str, Decimal] | None)
parent_run_ids (list[UUID] | None)
trace_id (UUID)
dotted_order (str)
in_dataset (bool | None)
- __init__(
- _host_url: str | None = None,
- **kwargs: Any,
初始化 Run 对象。
- 参数:
_host_url (str | None)
kwargs (Any)
- 返回类型:
None
- classmethod construct(
- _fields_set: SetStr | None = None,
- **values: Any,
从受信任或预验证的数据创建新模型,设置 __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,
复制模型,可选地选择要包含、排除和更改的字段。
- 参数:
include (AbstractSetIntStr | MappingIntStrAny | None) – 要包含在新模型中的字段
exclude (AbstractSetIntStr | MappingIntStrAny | None) – 要从新模型中排除的字段,与 values 一样,这优先于 include
update (DictStrAny | None) – 新模型中要更改/添加的值。注意:在创建新模型之前,数据未经验证:您应该信任此数据
deep (bool) – 设置为 True 以深度复制模型
self (Model)
- 返回:
新模型实例
- 返回类型:
Model
- 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,
生成模型的字典表示,可选地指定要包含或排除的字段。
- 参数:
include (AbstractSetIntStr | MappingIntStrAny | None)
exclude (AbstractSetIntStr | MappingIntStrAny | None)
by_alias (bool)
skip_defaults (bool | None)
exclude_unset (bool)
exclude_defaults (bool)
exclude_none (bool)
- 返回类型:
DictStrAny
- classmethod from_orm(obj: Any) Model #
- 参数:
obj (Any)
- 返回类型:
Model
- 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,
生成模型的 JSON 表示,include 和 exclude 参数与 dict() 相同。
encoder 是一个可选函数,作为 json.dumps() 的 default 参数提供,其他参数与 json.dumps() 相同。
- 参数:
include (AbstractSetIntStr | MappingIntStrAny | None)
exclude (AbstractSetIntStr | MappingIntStrAny | None)
by_alias (bool)
skip_defaults (bool | None)
exclude_unset (bool)
exclude_defaults (bool)
exclude_none (bool)
encoder (Callable[[Any], Any] | None)
models_as_dict (bool)
dumps_kwargs (Any)
- 返回类型:
str
- classmethod parse_file(
- path: str | Path,
- *,
- content_type: str = None,
- encoding: str = 'utf8',
- proto: Protocol = None,
- allow_pickle: bool = False,
- 参数:
path (str | Path)
content_type (str)
encoding (str)
proto (Protocol)
allow_pickle (bool)
- 返回类型:
Model
- classmethod parse_obj(obj: Any) Model #
- 参数:
obj (Any)
- 返回类型:
Model
- classmethod parse_raw(
- b: str | bytes,
- *,
- content_type: str = None,
- encoding: str = 'utf8',
- proto: Protocol = None,
- allow_pickle: bool = False,
- 参数:
b (str | bytes)
content_type (str)
encoding (str)
proto (Protocol)
allow_pickle (bool)
- 返回类型:
Model
- classmethod schema(
- by_alias: bool = True,
- ref_template: str = '#/definitions/{model}',
- 参数:
by_alias (bool)
ref_template (str)
- 返回类型:
DictStrAny
- classmethod schema_json(
- *,
- by_alias: bool = True,
- ref_template: str = '#/definitions/{model}',
- **dumps_kwargs: Any,
- 参数:
by_alias (bool)
ref_template (str)
dumps_kwargs (Any)
- 返回类型:
str
- classmethod update_forward_refs(**localns: Any) None #
尝试根据此模型、全局命名空间和本地命名空间更新字段上的 ForwardRefs。
- 参数:
localns (Any)
- 返回类型:
None
- classmethod validate(value: Any) Model #
- 参数:
value (Any)
- 返回类型:
Model