Fix: safe defaults for BaseModel dict fields (#24098)
Co-authored-by: Yongtao Huang <99629139+hyongtao-db@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -167,7 +167,7 @@ class ModelConfig(BaseModel):
|
|||||||
provider: str
|
provider: str
|
||||||
name: str
|
name: str
|
||||||
mode: LLMMode
|
mode: LLMMode
|
||||||
completion_params: dict[str, Any] = {}
|
completion_params: dict[str, Any] = Field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
class Condition(BaseModel):
|
class Condition(BaseModel):
|
||||||
|
@@ -142,7 +142,7 @@ class MessageEndStreamResponse(StreamResponse):
|
|||||||
|
|
||||||
event: StreamEvent = StreamEvent.MESSAGE_END
|
event: StreamEvent = StreamEvent.MESSAGE_END
|
||||||
id: str
|
id: str
|
||||||
metadata: dict = {}
|
metadata: dict = Field(default_factory=dict)
|
||||||
files: Optional[Sequence[Mapping[str, Any]]] = None
|
files: Optional[Sequence[Mapping[str, Any]]] = None
|
||||||
|
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ class NodeStartStreamResponse(StreamResponse):
|
|||||||
predecessor_node_id: Optional[str] = None
|
predecessor_node_id: Optional[str] = None
|
||||||
inputs: Optional[Mapping[str, Any]] = None
|
inputs: Optional[Mapping[str, Any]] = None
|
||||||
created_at: int
|
created_at: int
|
||||||
extras: dict = {}
|
extras: dict = Field(default_factory=dict)
|
||||||
parallel_id: Optional[str] = None
|
parallel_id: Optional[str] = None
|
||||||
parallel_start_node_id: Optional[str] = None
|
parallel_start_node_id: Optional[str] = None
|
||||||
parent_parallel_id: Optional[str] = None
|
parent_parallel_id: Optional[str] = None
|
||||||
@@ -503,7 +503,7 @@ class IterationNodeStartStreamResponse(StreamResponse):
|
|||||||
node_type: str
|
node_type: str
|
||||||
title: str
|
title: str
|
||||||
created_at: int
|
created_at: int
|
||||||
extras: dict = {}
|
extras: dict = Field(default_factory=dict)
|
||||||
metadata: Mapping = {}
|
metadata: Mapping = {}
|
||||||
inputs: Mapping = {}
|
inputs: Mapping = {}
|
||||||
parallel_id: Optional[str] = None
|
parallel_id: Optional[str] = None
|
||||||
@@ -531,7 +531,7 @@ class IterationNodeNextStreamResponse(StreamResponse):
|
|||||||
index: int
|
index: int
|
||||||
created_at: int
|
created_at: int
|
||||||
pre_iteration_output: Optional[Any] = None
|
pre_iteration_output: Optional[Any] = None
|
||||||
extras: dict = {}
|
extras: dict = Field(default_factory=dict)
|
||||||
parallel_id: Optional[str] = None
|
parallel_id: Optional[str] = None
|
||||||
parallel_start_node_id: Optional[str] = None
|
parallel_start_node_id: Optional[str] = None
|
||||||
parallel_mode_run_id: Optional[str] = None
|
parallel_mode_run_id: Optional[str] = None
|
||||||
@@ -590,7 +590,7 @@ class LoopNodeStartStreamResponse(StreamResponse):
|
|||||||
node_type: str
|
node_type: str
|
||||||
title: str
|
title: str
|
||||||
created_at: int
|
created_at: int
|
||||||
extras: dict = {}
|
extras: dict = Field(default_factory=dict)
|
||||||
metadata: Mapping = {}
|
metadata: Mapping = {}
|
||||||
inputs: Mapping = {}
|
inputs: Mapping = {}
|
||||||
parallel_id: Optional[str] = None
|
parallel_id: Optional[str] = None
|
||||||
@@ -618,7 +618,7 @@ class LoopNodeNextStreamResponse(StreamResponse):
|
|||||||
index: int
|
index: int
|
||||||
created_at: int
|
created_at: int
|
||||||
pre_loop_output: Optional[Any] = None
|
pre_loop_output: Optional[Any] = None
|
||||||
extras: dict = {}
|
extras: dict = Field(default_factory=dict)
|
||||||
parallel_id: Optional[str] = None
|
parallel_id: Optional[str] = None
|
||||||
parallel_start_node_id: Optional[str] = None
|
parallel_start_node_id: Optional[str] = None
|
||||||
parallel_mode_run_id: Optional[str] = None
|
parallel_mode_run_id: Optional[str] = None
|
||||||
@@ -764,7 +764,7 @@ class ChatbotAppBlockingResponse(AppBlockingResponse):
|
|||||||
conversation_id: str
|
conversation_id: str
|
||||||
message_id: str
|
message_id: str
|
||||||
answer: str
|
answer: str
|
||||||
metadata: dict = {}
|
metadata: dict = Field(default_factory=dict)
|
||||||
created_at: int
|
created_at: int
|
||||||
|
|
||||||
data: Data
|
data: Data
|
||||||
@@ -784,7 +784,7 @@ class CompletionAppBlockingResponse(AppBlockingResponse):
|
|||||||
mode: str
|
mode: str
|
||||||
message_id: str
|
message_id: str
|
||||||
answer: str
|
answer: str
|
||||||
metadata: dict = {}
|
metadata: dict = Field(default_factory=dict)
|
||||||
created_at: int
|
created_at: int
|
||||||
|
|
||||||
data: Data
|
data: Data
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from core.extension.api_based_extension_requestor import APIBasedExtensionPoint, APIBasedExtensionRequestor
|
from core.extension.api_based_extension_requestor import APIBasedExtensionPoint, APIBasedExtensionRequestor
|
||||||
from core.helper.encrypter import decrypt_token
|
from core.helper.encrypter import decrypt_token
|
||||||
@@ -11,7 +11,7 @@ from models.api_based_extension import APIBasedExtension
|
|||||||
|
|
||||||
class ModerationInputParams(BaseModel):
|
class ModerationInputParams(BaseModel):
|
||||||
app_id: str = ""
|
app_id: str = ""
|
||||||
inputs: dict = {}
|
inputs: dict = Field(default_factory=dict)
|
||||||
query: str = ""
|
query: str = ""
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from core.extension.extensible import Extensible, ExtensionModule
|
from core.extension.extensible import Extensible, ExtensionModule
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ class ModerationInputsResult(BaseModel):
|
|||||||
flagged: bool = False
|
flagged: bool = False
|
||||||
action: ModerationAction
|
action: ModerationAction
|
||||||
preset_response: str = ""
|
preset_response: str = ""
|
||||||
inputs: dict = {}
|
inputs: dict = Field(default_factory=dict)
|
||||||
query: str = ""
|
query: str = ""
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
|
|||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
class ChildDocument(BaseModel):
|
class ChildDocument(BaseModel):
|
||||||
@@ -15,7 +15,7 @@ class ChildDocument(BaseModel):
|
|||||||
"""Arbitrary metadata about the page content (e.g., source, relationships to other
|
"""Arbitrary metadata about the page content (e.g., source, relationships to other
|
||||||
documents, etc.).
|
documents, etc.).
|
||||||
"""
|
"""
|
||||||
metadata: dict = {}
|
metadata: dict = Field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
class Document(BaseModel):
|
class Document(BaseModel):
|
||||||
@@ -28,7 +28,7 @@ class Document(BaseModel):
|
|||||||
"""Arbitrary metadata about the page content (e.g., source, relationships to other
|
"""Arbitrary metadata about the page content (e.g., source, relationships to other
|
||||||
documents, etc.).
|
documents, etc.).
|
||||||
"""
|
"""
|
||||||
metadata: dict = {}
|
metadata: dict = Field(default_factory=dict)
|
||||||
|
|
||||||
provider: Optional[str] = "dify"
|
provider: Optional[str] = "dify"
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ class GraphRuntimeState(BaseModel):
|
|||||||
#
|
#
|
||||||
# Note: Since the type of this field is `dict[str, Any]`, its values may not remain consistent
|
# Note: Since the type of this field is `dict[str, Any]`, its values may not remain consistent
|
||||||
# after a serialization and deserialization round trip.
|
# after a serialization and deserialization round trip.
|
||||||
outputs: dict[str, Any] = {}
|
outputs: dict[str, Any] = Field(default_factory=dict)
|
||||||
|
|
||||||
node_run_steps: int = 0
|
node_run_steps: int = 0
|
||||||
"""node run steps"""
|
"""node run steps"""
|
||||||
|
@@ -13,7 +13,7 @@ class ModelConfig(BaseModel):
|
|||||||
provider: str
|
provider: str
|
||||||
name: str
|
name: str
|
||||||
mode: LLMMode
|
mode: LLMMode
|
||||||
completion_params: dict[str, Any] = {}
|
completion_params: dict[str, Any] = Field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
class ContextConfig(BaseModel):
|
class ContextConfig(BaseModel):
|
||||||
|
Reference in New Issue
Block a user