Merge remote-tracking branch 'origin/main' into feat/queue-based-graph-engine

This commit is contained in:
-LAN- 2025-09-09 22:16:59 +08:00
commit 1c9f40f92a
No known key found for this signature in database
GPG Key ID: 6BA0D108DED011FF
14 changed files with 63 additions and 43 deletions

View File

@ -95,7 +95,7 @@ class AppGenerateEntity(BaseModel):
task_id: str
# app config
app_config: Any
app_config: Any = None
file_upload_config: Optional[FileUploadConfig] = None
inputs: Mapping[str, Any]

View File

@ -391,8 +391,8 @@ class QueueAgentLogEvent(AppQueueEvent):
id: str
label: str
node_execution_id: str
parent_id: str | None
error: str | None
parent_id: str | None = None
error: str | None = None
status: str
data: Mapping[str, Any]
metadata: Optional[Mapping[str, Any]] = None

View File

@ -768,8 +768,8 @@ class AgentLogStreamResponse(StreamResponse):
node_execution_id: str
id: str
label: str
parent_id: str | None
error: str | None
parent_id: str | None = None
error: str | None = None
status: str
data: Mapping[str, Any]
metadata: Optional[Mapping[str, Any]] = None

View File

@ -107,7 +107,7 @@ class CustomModelConfiguration(BaseModel):
model: str
model_type: ModelType
credentials: dict | None
credentials: dict | None = None
current_credential_id: Optional[str] = None
current_credential_name: Optional[str] = None
available_model_credentials: list[CredentialConfiguration] = []

View File

@ -809,7 +809,7 @@ class LoggingMessageNotificationParams(NotificationParams):
"""The severity of this log message."""
logger: str | None = None
"""An optional name of the logger issuing this message."""
data: Any
data: Any = None
"""
The data to be logged, such as a string message or an object. Any JSON serializable
type is allowed here.

View File

@ -35,7 +35,7 @@ class BaseTraceInfo(BaseModel):
class WorkflowTraceInfo(BaseTraceInfo):
workflow_data: Any
workflow_data: Any = None
conversation_id: Optional[str] = None
workflow_app_log_id: Optional[str] = None
workflow_id: str
@ -89,7 +89,7 @@ class SuggestedQuestionTraceInfo(BaseTraceInfo):
class DatasetRetrievalTraceInfo(BaseTraceInfo):
documents: Any
documents: Any = None
class ToolTraceInfo(BaseTraceInfo):
@ -97,12 +97,12 @@ class ToolTraceInfo(BaseTraceInfo):
tool_inputs: dict[str, Any]
tool_outputs: str
metadata: dict[str, Any]
message_file_data: Any
message_file_data: Any = None
error: Optional[str] = None
tool_config: dict[str, Any]
time_cost: Union[int, float]
tool_parameters: dict[str, Any]
file_url: Union[str, None, list]
file_url: Union[str, None, list] = None
class GenerateNameTraceInfo(BaseTraceInfo):
@ -113,7 +113,7 @@ class GenerateNameTraceInfo(BaseTraceInfo):
class TaskData(BaseModel):
app_id: str
trace_info_type: str
trace_info: Any
trace_info: Any = None
trace_info_info_map = {

View File

@ -24,7 +24,7 @@ class PluginDaemonBasicResponse(BaseModel, Generic[T]):
code: int
message: str
data: Optional[T]
data: Optional[T] = None
class InstallPluginMessage(BaseModel):

View File

@ -28,8 +28,8 @@ def create_ssl_context() -> ssl.SSLContext:
class HuaweiCloudVectorConfig(BaseModel):
hosts: str
username: str | None
password: str | None
username: str | None = None
password: str | None = None
@model_validator(mode="before")
@classmethod

View File

@ -24,10 +24,10 @@ logger = logging.getLogger(__name__)
class TencentConfig(BaseModel):
url: str
api_key: Optional[str]
api_key: Optional[str] = None
timeout: float = 30
username: Optional[str]
database: Optional[str]
username: Optional[str] = None
database: Optional[str] = None
index_type: str = "HNSW"
metric_type: str = "IP"
shard: int = 1

View File

@ -67,22 +67,42 @@ class MCPTool(Tool):
for content in result.content:
if isinstance(content, TextContent):
try:
content_json = json.loads(content.text)
if isinstance(content_json, dict):
yield self.create_json_message(content_json)
elif isinstance(content_json, list):
for item in content_json:
yield self.create_json_message(item)
else:
yield self.create_text_message(content.text)
except json.JSONDecodeError:
yield self.create_text_message(content.text)
yield from self._process_text_content(content)
elif isinstance(content, ImageContent):
yield self.create_blob_message(
blob=base64.b64decode(content.data), meta={"mime_type": content.mimeType}
)
yield self._process_image_content(content)
def _process_text_content(self, content: TextContent) -> Generator[ToolInvokeMessage, None, None]:
"""Process text content and yield appropriate messages."""
try:
content_json = json.loads(content.text)
yield from self._process_json_content(content_json)
except json.JSONDecodeError:
yield self.create_text_message(content.text)
def _process_json_content(self, content_json: Any) -> Generator[ToolInvokeMessage, None, None]:
"""Process JSON content based on its type."""
if isinstance(content_json, dict):
yield self.create_json_message(content_json)
elif isinstance(content_json, list):
yield from self._process_json_list(content_json)
else:
# For primitive types (str, int, bool, etc.), convert to string
yield self.create_text_message(str(content_json))
def _process_json_list(self, json_list: list) -> Generator[ToolInvokeMessage, None, None]:
"""Process a list of JSON items."""
if any(not isinstance(item, dict) for item in json_list):
# If the list contains any non-dict item, treat the entire list as a text message.
yield self.create_text_message(str(json_list))
return
# Otherwise, process each dictionary as a separate JSON message.
for item in json_list:
yield self.create_json_message(item)
def _process_image_content(self, content: ImageContent) -> ToolInvokeMessage:
"""Process image content and return a blob message."""
return self.create_blob_message(blob=base64.b64decode(content.data), meta={"mime_type": content.mimeType})
def fork_tool_runtime(self, runtime: ToolRuntime) -> "MCPTool":
return MCPTool(

View File

@ -19,7 +19,7 @@ class Segment(BaseModel):
model_config = ConfigDict(frozen=True)
value_type: SegmentType
value: Any
value: Any = None
@field_validator("value_type")
@classmethod

View File

@ -45,7 +45,7 @@ class DefaultValueType(StrEnum):
class DefaultValue(BaseModel):
value: Any
value: Any = None
type: DefaultValueType
key: str

View File

@ -16,7 +16,7 @@ class UpdatedVariable(BaseModel):
name: str
selector: Sequence[str]
value_type: SegmentType
new_value: Any
new_value: Any = None
_T = TypeVar("_T", bound=MutableMapping[str, Any])

View File

@ -99,17 +99,17 @@ def _check_version_compatibility(imported_version: str) -> ImportStatus:
class PendingData(BaseModel):
import_mode: str
yaml_content: str
name: str | None
description: str | None
icon_type: str | None
icon: str | None
icon_background: str | None
app_id: str | None
name: str | None = None
description: str | None = None
icon_type: str | None = None
icon: str | None = None
icon_background: str | None = None
app_id: str | None = None
class CheckDependenciesPendingData(BaseModel):
dependencies: list[PluginDependency]
app_id: str | None
app_id: str | None = None
class AppDslService: