diff --git a/app/models.py b/app/models.py index 9bae3d0..4cf2c6d 100644 --- a/app/models.py +++ b/app/models.py @@ -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.", diff --git a/app/services/table_snippet.py b/app/services/table_snippet.py index be72b0e..a97436d 100644 --- a/app/services/table_snippet.py +++ b/app/services/table_snippet.py @@ -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: diff --git a/table_snippet.sql b/table_snippet.sql index a4540ea..fcd3cbf 100644 --- a/table_snippet.sql +++ b/table_snippet.sql @@ -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,