mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
chore: add ast-grep rule to convert Optional[T] to T | None (#25560)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from collections.abc import Mapping
|
||||
from datetime import datetime
|
||||
from enum import StrEnum
|
||||
from typing import Any, Optional, Union
|
||||
from typing import Any, Union
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
from pydantic_core.core_schema import ValidationInfo
|
||||
@ -20,36 +20,36 @@ class LangSmithRunType(StrEnum):
|
||||
|
||||
|
||||
class LangSmithTokenUsage(BaseModel):
|
||||
input_tokens: Optional[int] = None
|
||||
output_tokens: Optional[int] = None
|
||||
total_tokens: Optional[int] = None
|
||||
input_tokens: int | None = None
|
||||
output_tokens: int | None = None
|
||||
total_tokens: int | None = None
|
||||
|
||||
|
||||
class LangSmithMultiModel(BaseModel):
|
||||
file_list: Optional[list[str]] = Field(None, description="List of files")
|
||||
file_list: list[str] | None = Field(None, description="List of files")
|
||||
|
||||
|
||||
class LangSmithRunModel(LangSmithTokenUsage, LangSmithMultiModel):
|
||||
name: Optional[str] = Field(..., description="Name of the run")
|
||||
inputs: Optional[Union[str, Mapping[str, Any], list, None]] = Field(None, description="Inputs of the run")
|
||||
outputs: Optional[Union[str, Mapping[str, Any], list, None]] = Field(None, description="Outputs of the run")
|
||||
name: str | None = Field(..., description="Name of the run")
|
||||
inputs: Union[str, Mapping[str, Any], list, None] | None = Field(None, description="Inputs of the run")
|
||||
outputs: Union[str, Mapping[str, Any], list, None] | None = Field(None, description="Outputs of the run")
|
||||
run_type: LangSmithRunType = Field(..., description="Type of the run")
|
||||
start_time: Optional[datetime | str] = Field(None, description="Start time of the run")
|
||||
end_time: Optional[datetime | str] = Field(None, description="End time of the run")
|
||||
extra: Optional[dict[str, Any]] = Field(None, description="Extra information of the run")
|
||||
error: Optional[str] = Field(None, description="Error message of the run")
|
||||
serialized: Optional[dict[str, Any]] = Field(None, description="Serialized data of the run")
|
||||
parent_run_id: Optional[str] = Field(None, description="Parent run ID")
|
||||
events: Optional[list[dict[str, Any]]] = Field(None, description="Events associated with the run")
|
||||
tags: Optional[list[str]] = Field(None, description="Tags associated with the run")
|
||||
trace_id: Optional[str] = Field(None, description="Trace ID associated with the run")
|
||||
dotted_order: Optional[str] = Field(None, description="Dotted order of the run")
|
||||
id: Optional[str] = Field(None, description="ID of the run")
|
||||
session_id: Optional[str] = Field(None, description="Session ID associated with the run")
|
||||
session_name: Optional[str] = Field(None, description="Session name associated with the run")
|
||||
reference_example_id: Optional[str] = Field(None, description="Reference example ID associated with the run")
|
||||
input_attachments: Optional[dict[str, Any]] = Field(None, description="Input attachments of the run")
|
||||
output_attachments: Optional[dict[str, Any]] = Field(None, description="Output attachments of the run")
|
||||
start_time: datetime | str | None = Field(None, description="Start time of the run")
|
||||
end_time: datetime | str | None = Field(None, description="End time of the run")
|
||||
extra: dict[str, Any] | None = Field(None, description="Extra information of the run")
|
||||
error: str | None = Field(None, description="Error message of the run")
|
||||
serialized: dict[str, Any] | None = Field(None, description="Serialized data of the run")
|
||||
parent_run_id: str | None = Field(None, description="Parent run ID")
|
||||
events: list[dict[str, Any]] | None = Field(None, description="Events associated with the run")
|
||||
tags: list[str] | None = Field(None, description="Tags associated with the run")
|
||||
trace_id: str | None = Field(None, description="Trace ID associated with the run")
|
||||
dotted_order: str | None = Field(None, description="Dotted order of the run")
|
||||
id: str | None = Field(None, description="ID of the run")
|
||||
session_id: str | None = Field(None, description="Session ID associated with the run")
|
||||
session_name: str | None = Field(None, description="Session name associated with the run")
|
||||
reference_example_id: str | None = Field(None, description="Reference example ID associated with the run")
|
||||
input_attachments: dict[str, Any] | None = Field(None, description="Input attachments of the run")
|
||||
output_attachments: dict[str, Any] | None = Field(None, description="Output attachments of the run")
|
||||
|
||||
@field_validator("inputs", "outputs")
|
||||
@classmethod
|
||||
@ -128,15 +128,15 @@ class LangSmithRunModel(LangSmithTokenUsage, LangSmithMultiModel):
|
||||
|
||||
class LangSmithRunUpdateModel(BaseModel):
|
||||
run_id: str = Field(..., description="ID of the run")
|
||||
trace_id: Optional[str] = Field(None, description="Trace ID associated with the run")
|
||||
dotted_order: Optional[str] = Field(None, description="Dotted order of the run")
|
||||
parent_run_id: Optional[str] = Field(None, description="Parent run ID")
|
||||
end_time: Optional[datetime | str] = Field(None, description="End time of the run")
|
||||
error: Optional[str] = Field(None, description="Error message of the run")
|
||||
inputs: Optional[dict[str, Any]] = Field(None, description="Inputs of the run")
|
||||
outputs: Optional[dict[str, Any]] = Field(None, description="Outputs of the run")
|
||||
events: Optional[list[dict[str, Any]]] = Field(None, description="Events associated with the run")
|
||||
tags: Optional[list[str]] = Field(None, description="Tags associated with the run")
|
||||
extra: Optional[dict[str, Any]] = Field(None, description="Extra information of the run")
|
||||
input_attachments: Optional[dict[str, Any]] = Field(None, description="Input attachments of the run")
|
||||
output_attachments: Optional[dict[str, Any]] = Field(None, description="Output attachments of the run")
|
||||
trace_id: str | None = Field(None, description="Trace ID associated with the run")
|
||||
dotted_order: str | None = Field(None, description="Dotted order of the run")
|
||||
parent_run_id: str | None = Field(None, description="Parent run ID")
|
||||
end_time: datetime | str | None = Field(None, description="End time of the run")
|
||||
error: str | None = Field(None, description="Error message of the run")
|
||||
inputs: dict[str, Any] | None = Field(None, description="Inputs of the run")
|
||||
outputs: dict[str, Any] | None = Field(None, description="Outputs of the run")
|
||||
events: list[dict[str, Any]] | None = Field(None, description="Events associated with the run")
|
||||
tags: list[str] | None = Field(None, description="Tags associated with the run")
|
||||
extra: dict[str, Any] | None = Field(None, description="Extra information of the run")
|
||||
input_attachments: dict[str, Any] | None = Field(None, description="Input attachments of the run")
|
||||
output_attachments: dict[str, Any] | None = Field(None, description="Output attachments of the run")
|
||||
|
||||
Reference in New Issue
Block a user