增加模型信息的记录入库字段

This commit is contained in:
zhaoawd
2025-11-14 00:58:29 +08:00
parent a72ca3593e
commit 368ffaaaae
3 changed files with 26 additions and 0 deletions

View File

@ -254,6 +254,18 @@ class TableSnippetUpsertRequest(BaseModel):
callback_url: HttpUrl = Field(..., description="Callback URL associated with the action run.")
table_schema_version_id: int = Field(..., ge=0, description="Identifier for the schema snapshot.")
table_schema: Any = Field(..., description="Schema snapshot payload for the table.")
model: Optional[str] = Field(
None,
description="LLM model identifier (can be provider alias) used for this action, when applicable.",
)
model_provider: Optional[str] = Field(
None,
description="LLM provider responsible for executing the action's model.",
)
model_params: Optional[Dict[str, Any]] = Field(
None,
description="Optional model parameter overrides (e.g., temperature) associated with the action.",
)
llm_usage: Optional[Any] = Field(
None,
description="Optional token usage metrics reported by the LLM provider.",

View File

@ -38,6 +38,13 @@ def _prepare_table_schema(value: Any) -> str:
return json.dumps(value, ensure_ascii=False)
def _prepare_model_params(params: Dict[str, Any] | None) -> str | None:
if not params:
return None
serialized, _ = _serialize_json(params)
return serialized
def _collect_common_columns(request: TableSnippetUpsertRequest) -> Dict[str, Any]:
logger.debug(
"Collecting common columns for table_id=%s version_ts=%s action_type=%s",
@ -53,6 +60,8 @@ def _collect_common_columns(request: TableSnippetUpsertRequest) -> Dict[str, Any
"callback_url": str(request.callback_url),
"table_schema_version_id": request.table_schema_version_id,
"table_schema": _prepare_table_schema(request.table_schema),
"model": request.model,
"model_provider": request.model_provider,
}
payload.update(
@ -72,6 +81,8 @@ def _collect_common_columns(request: TableSnippetUpsertRequest) -> Dict[str, Any
}
)
payload["model_params"] = _prepare_model_params(request.model_params)
if request.llm_usage is not None:
llm_usage_json, _ = _serialize_json(request.llm_usage)
if llm_usage_json is not None:

View File

@ -4,6 +4,9 @@ CREATE TABLE `action_results` (
`version_ts` bigint NOT NULL COMMENT '版本时间戳(版本号)',
`action_type` enum('ge_profiling','ge_result_desc','snippet','snippet_alias') COLLATE utf8mb4_bin NOT NULL COMMENT '动作类型',
`status` enum('pending','running','success','failed','partial') COLLATE utf8mb4_bin NOT NULL DEFAULT 'pending' COMMENT '执行状态',
`model` varchar(100) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '模型名称',
`model_provider` varchar(100) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '模型渠道',
`model_params` varchar(100) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '模型参数,如温度',
`llm_usage` json DEFAULT NULL COMMENT 'LLM token usage统计',
`error_code` varchar(128) COLLATE utf8mb4_bin DEFAULT NULL,
`error_message` text COLLATE utf8mb4_bin,