From 77dfbcc145bb83c895b5f33363a21293b693ce17 Mon Sep 17 00:00:00 2001 From: tpfz Date: Tue, 30 Sep 2025 15:19:47 +0800 Subject: [PATCH 1/9] feat: [Coda] Add ClickHouse DAO support for BatchGetExperimentResult with expt_turn_result_filter_local table (LogID: 20250930145642010091110134764A37C) Co-Authored-By: Coda --- .../evaluation/domain/component/conf.go | 3 +- .../experiment/ck/expt_turn_result_filter.go | 14 ++++++-- backend/modules/evaluation/pkg/conf/expt.go | 14 ++++++++ .../clickhouse-init/init-sql/evaluation.sql | 32 +++++++++++++++++++ .../docker-compose/conf/evaluation.yaml | 4 +++ .../init/clickhouse/init-sql/evaluation.sql | 32 +++++++++++++++++++ .../helm-chart/umbrella/conf/evaluation.yaml | 4 +++ 7 files changed, 99 insertions(+), 4 deletions(-) create mode 100755 release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql create mode 100755 release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql diff --git a/backend/modules/evaluation/domain/component/conf.go b/backend/modules/evaluation/domain/component/conf.go index cde437b52..2d641f3d1 100644 --- a/backend/modules/evaluation/domain/component/conf.go +++ b/backend/modules/evaluation/domain/component/conf.go @@ -18,4 +18,5 @@ type IConfiger interface { GetExptTurnResultFilterBmqProducerCfg(ctx context.Context) *entity.BmqProducerCfg GetCKDBName(ctx context.Context) *entity.CKDBConfig GetExptExportWhiteList(ctx context.Context) *entity.ExptExportWhiteList -} + GetExptTurnResultFilterTableName(ctx context.Context) string +} \ No newline at end of file diff --git a/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go b/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go index ebe74150b..c1c1936de 100644 --- a/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go +++ b/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go @@ -523,7 +523,11 @@ func (d *exptTurnResultFilterDAOImpl) buildKeywordSearchConditions(ctx context.C // buildBaseSQL 构建基础SQL语句 func (d *exptTurnResultFilterDAOImpl) buildBaseSQL(ctx context.Context, joinSQL, whereSQL, keywordCond, evalSetSyncCkDate string, args *[]interface{}) string { - sql := "SELECT etrf.item_id, etrf.status FROM " + d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName + ".expt_turn_result_filter etrf" + tableName := d.configer.GetExptTurnResultFilterTableName(ctx) + if tableName == "" { + tableName = "expt_turn_result_filter" + } + sql := "SELECT etrf.item_id, etrf.status FROM " + d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName + "." + tableName + " etrf" if joinSQL != "" || keywordCond != "" { sql += " INNER JOIN " + d.configer.GetCKDBName(ctx).DatasetItemsSnapshotDBName + ".dataset_item_snapshot dis ON etrf.eval_set_version_id = dis.version_id AND etrf.item_id = dis.item_id" } @@ -651,6 +655,10 @@ func (d *exptTurnResultFilterDAOImpl) GetByExptIDItemIDs(ctx context.Context, sp } func (d *exptTurnResultFilterDAOImpl) buildGetByExptIDItemIDsSQL(ctx context.Context, spaceID, exptID, createdDate string, itemIDs []string) (string, []interface{}) { + tableName := d.configer.GetExptTurnResultFilterTableName(ctx) + if tableName == "" { + tableName = "expt_turn_result_filter" + } sql := "SELECT " + "etrf.space_id, " + "etrf.expt_id, " + @@ -672,7 +680,7 @@ func (d *exptTurnResultFilterDAOImpl) buildGetByExptIDItemIDsSQL(ctx context.Con "etrf.evaluator_score{'key9'} as evaluator_score_key_9, " + "etrf.evaluator_score{'key10'} as evaluator_score_key_10, " + "etrf.evaluator_score_corrected " + - "FROM " + d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName + ".expt_turn_result_filter etrf " + + "FROM " + d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName + "." + tableName + " etrf " + "WHERE etrf.space_id = ? AND etrf.expt_id = ? AND etrf.created_date =?" if len(itemIDs) > 0 { sql += " AND etrf.item_id IN (?)" @@ -681,4 +689,4 @@ func (d *exptTurnResultFilterDAOImpl) buildGetByExptIDItemIDsSQL(ctx context.Con args := []interface{}{spaceID, exptID, createdDate, itemIDs} logs.CtxInfo(ctx, "GetByExptID sql: %v, args: %v", sql, args) return sql, args -} +} \ No newline at end of file diff --git a/backend/modules/evaluation/pkg/conf/expt.go b/backend/modules/evaluation/pkg/conf/expt.go index 7d317424f..ef8f50523 100644 --- a/backend/modules/evaluation/pkg/conf/expt.go +++ b/backend/modules/evaluation/pkg/conf/expt.go @@ -61,3 +61,17 @@ func (c *configer) GetExptExportWhiteList(ctx context.Context) (eec *entity.Expt const key = "expt_export_white_list" return lo.Ternary(c.loader.UnmarshalKey(ctx, key, &eec) == nil, eec, entity.DefaultExptExportWhiteList()) } + +func (c *configer) GetExptTurnResultFilterTableName(ctx context.Context) string { + type ClickHouseTableConfig struct { + ExptTurnResultFilterTableName string `json:"expt_turn_result_filter_table_name" mapstructure:"expt_turn_result_filter_table_name"` + } + + var config ClickHouseTableConfig + const key = "clickhouse_table_config" + if c.loader.UnmarshalKey(ctx, key, &config) == nil && config.ExptTurnResultFilterTableName != "" { + return config.ExptTurnResultFilterTableName + } + // 返回默认表名 + return "expt_turn_result_filter" +} \ No newline at end of file diff --git a/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql b/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql new file mode 100755 index 000000000..70ffc07e1 --- /dev/null +++ b/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql @@ -0,0 +1,32 @@ +-- Copyright (c) 2025 coze-dev Authors +-- SPDX-License-Identifier: Apache-2.0 + +-- Create database if not exists +CREATE DATABASE IF NOT EXISTS cozeloop_evaluation; + +-- Create expt_turn_result_filter_local table for docker environment +CREATE TABLE IF NOT EXISTS cozeloop_evaluation.expt_turn_result_filter_local +( + `space_id` String, + `expt_id` String, + `item_id` String, + `item_idx` Int32, + `turn_id` String, + `status` Int32, + `eval_target_data` Map(String, String), + `evaluator_score` Map(String, Float64), + `annotation_float` Map(String, Float64), + `annotation_bool` Map(String, Int8), + `annotation_string` Map(String, String), + `evaluator_score_corrected` Int32, + `eval_set_version_id` String, + `created_date` Date, + `created_at` DateTime, + `updated_at` DateTime, + INDEX inv_eval_target_data_actual_output eval_target_data TYPE inverted GRANULARITY 1 +) +ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{database}/{table}', '{replica}') +PARTITION BY created_date +ORDER BY (expt_id, cityHash64(item_id), turn_id) +SAMPLE BY cityHash64(item_id) +SETTINGS index_granularity = 8192; \ No newline at end of file diff --git a/release/deployment/docker-compose/conf/evaluation.yaml b/release/deployment/docker-compose/conf/evaluation.yaml index b9bc0dc1a..8bcec9af0 100644 --- a/release/deployment/docker-compose/conf/evaluation.yaml +++ b/release/deployment/docker-compose/conf/evaluation.yaml @@ -47,6 +47,10 @@ expt_export_csv_event_rmq: consumer_group: 'expt_export_csv_event_cg' producer_group: 'expt_export_csv_event_pg' +# ClickHouse table configuration +clickhouse_table_config: + expt_turn_result_filter_table_name: 'expt_turn_result_filter_local' + rate_limiter_conf: - key_expr: biz_key + string(space_id) limit: diff --git a/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql b/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql new file mode 100755 index 000000000..453a1500f --- /dev/null +++ b/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql @@ -0,0 +1,32 @@ +-- Copyright (c) 2025 coze-dev Authors +-- SPDX-License-Identifier: Apache-2.0 + +-- Create database if not exists +CREATE DATABASE IF NOT EXISTS cozeloop_evaluation; + +-- Create expt_turn_result_filter_local table for kubernetes environment +CREATE TABLE IF NOT EXISTS cozeloop_evaluation.expt_turn_result_filter_local +( + `space_id` String, + `expt_id` String, + `item_id` String, + `item_idx` Int32, + `turn_id` String, + `status` Int32, + `eval_target_data` Map(String, String), + `evaluator_score` Map(String, Float64), + `annotation_float` Map(String, Float64), + `annotation_bool` Map(String, Int8), + `annotation_string` Map(String, String), + `evaluator_score_corrected` Int32, + `eval_set_version_id` String, + `created_date` Date, + `created_at` DateTime, + `updated_at` DateTime, + INDEX inv_eval_target_data_actual_output eval_target_data TYPE inverted GRANULARITY 1 +) +ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{database}/{table}', '{replica}') +PARTITION BY created_date +ORDER BY (expt_id, cityHash64(item_id), turn_id) +SAMPLE BY cityHash64(item_id) +SETTINGS index_granularity = 8192; \ No newline at end of file diff --git a/release/deployment/helm-chart/umbrella/conf/evaluation.yaml b/release/deployment/helm-chart/umbrella/conf/evaluation.yaml index 23f0483a4..2658539a2 100644 --- a/release/deployment/helm-chart/umbrella/conf/evaluation.yaml +++ b/release/deployment/helm-chart/umbrella/conf/evaluation.yaml @@ -47,6 +47,10 @@ expt_export_csv_event_rmq: consumer_group: 'expt_export_csv_event_cg' producer_group: 'expt_export_csv_event_pg' +# ClickHouse table configuration +clickhouse_table_config: + expt_turn_result_filter_table_name: 'expt_turn_result_filter_local' + rate_limiter_conf: - key_expr: biz_key + string(space_id) limit: From 4736db796a04fd562575b99395e98a03c0ea36dc Mon Sep 17 00:00:00 2001 From: tpfz Date: Tue, 30 Sep 2025 15:24:02 +0800 Subject: [PATCH 2/9] refactor: [Coda] Use existing config interface for ClickHouse table name instead of adding new interface (LogID: 20250930145642010091110134764A37C) Co-Authored-By: Coda --- .../modules/evaluation/domain/component/conf.go | 1 - .../repo/experiment/ck/expt_turn_result_filter.go | 10 ++-------- backend/modules/evaluation/pkg/conf/expt.go | 14 -------------- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/backend/modules/evaluation/domain/component/conf.go b/backend/modules/evaluation/domain/component/conf.go index 2d641f3d1..be5675eda 100644 --- a/backend/modules/evaluation/domain/component/conf.go +++ b/backend/modules/evaluation/domain/component/conf.go @@ -18,5 +18,4 @@ type IConfiger interface { GetExptTurnResultFilterBmqProducerCfg(ctx context.Context) *entity.BmqProducerCfg GetCKDBName(ctx context.Context) *entity.CKDBConfig GetExptExportWhiteList(ctx context.Context) *entity.ExptExportWhiteList - GetExptTurnResultFilterTableName(ctx context.Context) string } \ No newline at end of file diff --git a/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go b/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go index c1c1936de..9fd00755a 100644 --- a/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go +++ b/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go @@ -523,10 +523,7 @@ func (d *exptTurnResultFilterDAOImpl) buildKeywordSearchConditions(ctx context.C // buildBaseSQL 构建基础SQL语句 func (d *exptTurnResultFilterDAOImpl) buildBaseSQL(ctx context.Context, joinSQL, whereSQL, keywordCond, evalSetSyncCkDate string, args *[]interface{}) string { - tableName := d.configer.GetExptTurnResultFilterTableName(ctx) - if tableName == "" { - tableName = "expt_turn_result_filter" - } + tableName := d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName sql := "SELECT etrf.item_id, etrf.status FROM " + d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName + "." + tableName + " etrf" if joinSQL != "" || keywordCond != "" { sql += " INNER JOIN " + d.configer.GetCKDBName(ctx).DatasetItemsSnapshotDBName + ".dataset_item_snapshot dis ON etrf.eval_set_version_id = dis.version_id AND etrf.item_id = dis.item_id" @@ -655,10 +652,7 @@ func (d *exptTurnResultFilterDAOImpl) GetByExptIDItemIDs(ctx context.Context, sp } func (d *exptTurnResultFilterDAOImpl) buildGetByExptIDItemIDsSQL(ctx context.Context, spaceID, exptID, createdDate string, itemIDs []string) (string, []interface{}) { - tableName := d.configer.GetExptTurnResultFilterTableName(ctx) - if tableName == "" { - tableName = "expt_turn_result_filter" - } + tableName := d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName sql := "SELECT " + "etrf.space_id, " + "etrf.expt_id, " + diff --git a/backend/modules/evaluation/pkg/conf/expt.go b/backend/modules/evaluation/pkg/conf/expt.go index ef8f50523..7d317424f 100644 --- a/backend/modules/evaluation/pkg/conf/expt.go +++ b/backend/modules/evaluation/pkg/conf/expt.go @@ -61,17 +61,3 @@ func (c *configer) GetExptExportWhiteList(ctx context.Context) (eec *entity.Expt const key = "expt_export_white_list" return lo.Ternary(c.loader.UnmarshalKey(ctx, key, &eec) == nil, eec, entity.DefaultExptExportWhiteList()) } - -func (c *configer) GetExptTurnResultFilterTableName(ctx context.Context) string { - type ClickHouseTableConfig struct { - ExptTurnResultFilterTableName string `json:"expt_turn_result_filter_table_name" mapstructure:"expt_turn_result_filter_table_name"` - } - - var config ClickHouseTableConfig - const key = "clickhouse_table_config" - if c.loader.UnmarshalKey(ctx, key, &config) == nil && config.ExptTurnResultFilterTableName != "" { - return config.ExptTurnResultFilterTableName - } - // 返回默认表名 - return "expt_turn_result_filter" -} \ No newline at end of file From 71152ab6511e4f1b8929a370480b8b155fc6adbc Mon Sep 17 00:00:00 2001 From: tpfz Date: Tue, 30 Sep 2025 15:27:13 +0800 Subject: [PATCH 3/9] fix: [Coda] Add missing UNIQUE KEY index to expt_turn_result_filter_local table creation (LogID: 20250930145642010091110134764A37C) Co-Authored-By: Coda --- .../bootstrap/clickhouse-init/init-sql/evaluation.sql | 1 + .../charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql b/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql index 70ffc07e1..536bf9931 100755 --- a/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql +++ b/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql @@ -28,5 +28,6 @@ CREATE TABLE IF NOT EXISTS cozeloop_evaluation.expt_turn_result_filter_local ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{database}/{table}', '{replica}') PARTITION BY created_date ORDER BY (expt_id, cityHash64(item_id), turn_id) +UNIQUE KEY (sipHash64(expt_id), sipHash64(item_id), sipHash64(turn_id)) SAMPLE BY cityHash64(item_id) SETTINGS index_granularity = 8192; \ No newline at end of file diff --git a/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql b/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql index 453a1500f..cfa78dfe8 100755 --- a/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql +++ b/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql @@ -28,5 +28,6 @@ CREATE TABLE IF NOT EXISTS cozeloop_evaluation.expt_turn_result_filter_local ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{database}/{table}', '{replica}') PARTITION BY created_date ORDER BY (expt_id, cityHash64(item_id), turn_id) +UNIQUE KEY (sipHash64(expt_id), sipHash64(item_id), sipHash64(turn_id)) SAMPLE BY cityHash64(item_id) SETTINGS index_granularity = 8192; \ No newline at end of file From 145a7b0491d2579dcda443db2fba139f0a60e411 Mon Sep 17 00:00:00 2001 From: tpfz Date: Tue, 30 Sep 2025 15:48:27 +0800 Subject: [PATCH 4/9] fix: [Coda] Fix ClickHouse table creation syntax errors for expt_turn_result_filter_local (LogID: 20250930145642010091110134764A37C) Co-Authored-By: Coda --- .../bootstrap/clickhouse-init/init-sql/evaluation.sql | 8 +++++--- .../app/bootstrap/init/clickhouse/init-sql/evaluation.sql | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql b/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql index 536bf9931..f72756ac1 100755 --- a/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql +++ b/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql @@ -23,11 +23,13 @@ CREATE TABLE IF NOT EXISTS cozeloop_evaluation.expt_turn_result_filter_local `created_date` Date, `created_at` DateTime, `updated_at` DateTime, - INDEX inv_eval_target_data_actual_output eval_target_data TYPE inverted GRANULARITY 1 + INDEX idx_space_id space_id TYPE bloom_filter() GRANULARITY 1, + INDEX idx_expt_id expt_id TYPE bloom_filter() GRANULARITY 1, + INDEX idx_item_id item_id TYPE bloom_filter() GRANULARITY 1, + INDEX idx_turn_id turn_id TYPE bloom_filter() GRANULARITY 1 ) -ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{database}/{table}', '{replica}') +ENGINE = MergeTree() PARTITION BY created_date ORDER BY (expt_id, cityHash64(item_id), turn_id) -UNIQUE KEY (sipHash64(expt_id), sipHash64(item_id), sipHash64(turn_id)) SAMPLE BY cityHash64(item_id) SETTINGS index_granularity = 8192; \ No newline at end of file diff --git a/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql b/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql index cfa78dfe8..f1f584b4b 100755 --- a/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql +++ b/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql @@ -23,11 +23,13 @@ CREATE TABLE IF NOT EXISTS cozeloop_evaluation.expt_turn_result_filter_local `created_date` Date, `created_at` DateTime, `updated_at` DateTime, - INDEX inv_eval_target_data_actual_output eval_target_data TYPE inverted GRANULARITY 1 + INDEX idx_space_id space_id TYPE bloom_filter() GRANULARITY 1, + INDEX idx_expt_id expt_id TYPE bloom_filter() GRANULARITY 1, + INDEX idx_item_id item_id TYPE bloom_filter() GRANULARITY 1, + INDEX idx_turn_id turn_id TYPE bloom_filter() GRANULARITY 1 ) -ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{database}/{table}', '{replica}') +ENGINE = ReplicatedReplacingMergeTree('/clickhouse/stone_dataengine_commercial/cozeloop_evaluation/{shard}', '{replica}') PARTITION BY created_date ORDER BY (expt_id, cityHash64(item_id), turn_id) -UNIQUE KEY (sipHash64(expt_id), sipHash64(item_id), sipHash64(turn_id)) SAMPLE BY cityHash64(item_id) SETTINGS index_granularity = 8192; \ No newline at end of file From 61f94da57c57a2d640f8a6a1a44355d95389ff8f Mon Sep 17 00:00:00 2001 From: tpfz Date: Mon, 20 Oct 2025 21:14:21 +0800 Subject: [PATCH 5/9] ck draft MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit chore: 展示筛选 ck draft ck draft 单测 draft --- .../ck/convertor/expt_turn_result_filter.go | 14 +- .../experiment/ck/expt_turn_result_filter.go | 262 ++++-------------- .../ck/expt_turn_result_filter_test.go | 46 ++- .../expt_turn_result_filter_repo_impl.go | 2 + backend/modules/evaluation/pkg/conf/expt.go | 4 +- .../experiment-detail-table/index.tsx | 8 +- .../clickhouse-init/init-sql/evaluation.sql | 12 +- .../docker-compose/conf/evaluation.yaml | 7 +- .../init/clickhouse/init-sql/evaluation.sql | 18 +- .../helm-chart/umbrella/conf/evaluation.yaml | 7 +- 10 files changed, 103 insertions(+), 277 deletions(-) diff --git a/backend/modules/evaluation/infra/repo/experiment/ck/convertor/expt_turn_result_filter.go b/backend/modules/evaluation/infra/repo/experiment/ck/convertor/expt_turn_result_filter.go index 637dee928..842a9853b 100644 --- a/backend/modules/evaluation/infra/repo/experiment/ck/convertor/expt_turn_result_filter.go +++ b/backend/modules/evaluation/infra/repo/experiment/ck/convertor/expt_turn_result_filter.go @@ -26,11 +26,11 @@ func ExptTurnResultFilterEntity2PO(filterEntity *entity.ExptTurnResultFilterEnti } return &model.ExptTurnResultFilter{ - SpaceID: stringifyInt64(filterEntity.SpaceID), - ExptID: stringifyInt64(filterEntity.ExptID), - ItemID: stringifyInt64(filterEntity.ItemID), + SpaceID: strconv.FormatInt(filterEntity.SpaceID, 10), + ExptID: strconv.FormatInt(filterEntity.ExptID, 10), + ItemID: strconv.FormatInt(filterEntity.ItemID, 10), ItemIdx: filterEntity.ItemIdx, - TurnID: stringifyInt64(filterEntity.TurnID), + TurnID: strconv.FormatInt(filterEntity.TurnID, 10), Status: int32(filterEntity.Status), EvalTargetData: filterEntity.EvalTargetData, EvaluatorScore: filterEntity.EvaluatorScore, @@ -39,6 +39,7 @@ func ExptTurnResultFilterEntity2PO(filterEntity *entity.ExptTurnResultFilterEnti AnnotationString: filterEntity.AnnotationString, CreatedDate: filterEntity.CreatedDate, EvalSetVersionID: strconv.FormatInt(filterEntity.EvalSetVersionID, 10), + UpdatedAt: filterEntity.UpdatedAt, } } @@ -70,11 +71,6 @@ func ExptTurnResultFilterPO2Entity(filterPO *model.ExptTurnResultFilter) *entity } } -// stringifyInt64 将 int64 转换为 string -func stringifyInt64(i int64) string { - return string(rune(i)) -} - // ParseStringToInt64 将 string 转换为 int64 func ParseStringToInt64(s string) int64 { if s == "" { diff --git a/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go b/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go index 9fd00755a..43052f83c 100644 --- a/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go +++ b/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter.go @@ -6,6 +6,7 @@ package ck import ( "context" "fmt" + "os" "strconv" "strings" "time" @@ -116,9 +117,19 @@ func (d *exptTurnResultFilterDAOImpl) Save(ctx context.Context, filter []*model. // 定义浮点数比较的精度 const floatEpsilon = 1e-8 +// getClickHouseDatabaseName 从环境变量获取ClickHouse数据库名 +func getClickHouseDatabaseName() string { + dbName := os.Getenv("COZE_LOOP_CLICKHOUSE_DATABASE") + if dbName == "" { + // 默认值,保持向后兼容 + dbName = "cozeloop-clickhouse" + } + return "`" + dbName + "`" +} + func (d *exptTurnResultFilterDAOImpl) QueryItemIDStates(ctx context.Context, cond *ExptTurnResultFilterQueryCond) (map[string]int32, int64, error) { - joinSQL, whereSQL, keywordCond, args := d.buildQueryConditions(ctx, cond) - sql := d.buildBaseSQL(ctx, joinSQL, whereSQL, keywordCond, cond.EvalSetSyncCkDate, &args) + whereSQL, keywordCond, args := d.buildQueryConditions(ctx, cond) + sql := d.buildBaseSQL(ctx, whereSQL, keywordCond, &args) total, err := d.getTotalCount(ctx, sql, args) if err != nil { return nil, total, err @@ -129,18 +140,16 @@ func (d *exptTurnResultFilterDAOImpl) QueryItemIDStates(ctx context.Context, con } // buildQueryConditions 构建查询条件 -func (d *exptTurnResultFilterDAOImpl) buildQueryConditions(ctx context.Context, cond *ExptTurnResultFilterQueryCond) (string, string, string, []interface{}) { - joinSQL := "" +func (d *exptTurnResultFilterDAOImpl) buildQueryConditions(ctx context.Context, cond *ExptTurnResultFilterQueryCond) (string, string, []interface{}) { whereSQL := "" keywordCond := "" args := []interface{}{} d.buildMainTableConditions(cond, &whereSQL, &args) d.buildMapFieldConditions(cond, &whereSQL, &args) - d.buildItemSnapshotConditions(cond, &joinSQL, &args) d.buildKeywordSearchConditions(ctx, cond, &keywordCond, &args) - return joinSQL, whereSQL, keywordCond, args + return whereSQL, keywordCond, args } // buildMainTableConditions 构建主表字段条件 @@ -226,19 +235,19 @@ func (d *exptTurnResultFilterDAOImpl) buildMapFieldConditions(cond *ExptTurnResu switch f.Op { case "=": // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.eval_target_data{'%s'} = ?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.eval_target_data['%s'] = ?", f.Key) *args = append(*args, f.Values[0]) case "LIKE": // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.eval_target_data{'%s'} LIKE ?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.eval_target_data['%s'] LIKE ?", f.Key) *args = append(*args, "%"+escapeSpecialChars(fmt.Sprintf("%v", f.Values[0]))+"%") case "NOT LIKE": // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.eval_target_data{'%s'} NOT LIKE ?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.eval_target_data['%s'] NOT LIKE ?", f.Key) *args = append(*args, "%"+escapeSpecialChars(fmt.Sprintf("%v", f.Values[0]))+"%") case "!=": // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.eval_target_data{'%s'}!=?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.eval_target_data['%s']!=?", f.Key) *args = append(*args, f.Values[0]) } } @@ -251,7 +260,7 @@ func (d *exptTurnResultFilterDAOImpl) buildMapFieldConditions(cond *ExptTurnResu continue } // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND abs(etrf.evaluator_score{'%s'} - ?) < %g", f.Key, floatEpsilon) + *whereSQL += fmt.Sprintf(" AND abs(etrf.evaluator_score['%s'] - ?) < %g", f.Key, floatEpsilon) *args = append(*args, floatValue) case ">", ">=", "<", "<=", "!=": floatValue, err := strconv.ParseFloat(fmt.Sprintf("%v", f.Values[0]), 64) @@ -260,7 +269,7 @@ func (d *exptTurnResultFilterDAOImpl) buildMapFieldConditions(cond *ExptTurnResu continue } // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.evaluator_score{'%s'} %s ?", f.Key, f.Op) + *whereSQL += fmt.Sprintf(" AND etrf.evaluator_score['%s'] %s ?", f.Key, f.Op) *args = append(*args, floatValue) case "BETWEEN": floatValue1, err1 := strconv.ParseFloat(fmt.Sprintf("%v", f.Values[0]), 64) @@ -270,7 +279,7 @@ func (d *exptTurnResultFilterDAOImpl) buildMapFieldConditions(cond *ExptTurnResu continue } // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.evaluator_score{'%s'} BETWEEN ? AND ?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.evaluator_score['%s'] BETWEEN ? AND ?", f.Key) *args = append(*args, floatValue1, floatValue2) } } @@ -283,7 +292,7 @@ func (d *exptTurnResultFilterDAOImpl) buildMapFieldConditions(cond *ExptTurnResu continue } // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND abs(etrf.annotation_float{'%s'} - ?) < %g", f.Key, floatEpsilon) + *whereSQL += fmt.Sprintf(" AND abs(etrf.annotation_float['%s'] - ?) < %g", f.Key, floatEpsilon) *args = append(*args, floatValue) case ">", ">=", "<", "<=", "!=": floatValue, err := strconv.ParseFloat(fmt.Sprintf("%v", f.Values[0]), 64) @@ -292,7 +301,7 @@ func (d *exptTurnResultFilterDAOImpl) buildMapFieldConditions(cond *ExptTurnResu continue } // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.annotation_float{'%s'} %s ?", f.Key, f.Op) + *whereSQL += fmt.Sprintf(" AND etrf.annotation_float['%s'] %s ?", f.Key, f.Op) *args = append(*args, floatValue) case "BETWEEN": floatValue1, err1 := strconv.ParseFloat(fmt.Sprintf("%v", f.Values[0]), 64) @@ -302,7 +311,7 @@ func (d *exptTurnResultFilterDAOImpl) buildMapFieldConditions(cond *ExptTurnResu continue } // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.annotation_float{'%s'} BETWEEN ? AND ?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.annotation_float['%s'] BETWEEN ? AND ?", f.Key) *args = append(*args, floatValue1, floatValue2) } } @@ -311,141 +320,34 @@ func (d *exptTurnResultFilterDAOImpl) buildMapFieldConditions(cond *ExptTurnResu switch f.Op { case "=": // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.annotation_string{'%s'} = ?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.annotation_string['%s'] = ?", f.Key) *args = append(*args, f.Values[0]) case "LIKE": // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.annotation_string{'%s'} LIKE ?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.annotation_string['%s'] LIKE ?", f.Key) *args = append(*args, "%"+escapeSpecialChars(fmt.Sprintf("%v", f.Values[0]))+"%") case "NOT LIKE": // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.annotation_string{'%s'} NOT LIKE ?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.annotation_string['%s'] NOT LIKE ?", f.Key) *args = append(*args, "%"+escapeSpecialChars(fmt.Sprintf("%v", f.Values[0]))+"%") case "!=": // 删除 mapContains 条件 - *whereSQL += fmt.Sprintf(" AND etrf.annotation_string{'%s'}!=?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.annotation_string['%s']!=?", f.Key) *args = append(*args, f.Values[0]) // tag_value_id case "in", "IN": //*whereSQL += " AND etrf.annotation_string IN ?" - *whereSQL += fmt.Sprintf(" AND etrf.annotation_string{'%s'} IN ?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.annotation_string['%s'] IN ?", f.Key) *args = append(*args, f.Values) case "NOT IN": //*whereSQL += " AND etrf.annotation_string NOT IN?" - *whereSQL += fmt.Sprintf(" AND etrf.annotation_string{'%s'} NOT IN ?", f.Key) + *whereSQL += fmt.Sprintf(" AND etrf.annotation_string['%s'] NOT IN ?", f.Key) *args = append(*args, f.Values) } } } -// buildItemSnapshotConditions 构建联表条件 -func (d *exptTurnResultFilterDAOImpl) buildItemSnapshotConditions(cond *ExptTurnResultFilterQueryCond, joinSQL *string, args *[]interface{}) { - if cond.ItemSnapshotCond == nil { - return - } - for _, f := range cond.ItemSnapshotCond.FloatMapFilters { - switch f.Op { - case "=": - floatValue, err := strconv.ParseFloat(fmt.Sprintf("%v", f.Values[0]), 64) - if err != nil { - logs.CtxError(context.Background(), "Parse float value failed: %v", err) - continue - } - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND abs(dis.float_map{'%s'} - ?) < %g", f.Key, floatEpsilon) - *args = append(*args, floatValue) - case ">", ">=", "<", "<=", "!=": - floatValue, err := strconv.ParseFloat(fmt.Sprintf("%v", f.Values[0]), 64) - if err != nil { - logs.CtxError(context.Background(), "Parse float value failed: %v", err) - continue - } - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND dis.float_map{'%s'} %s ?", f.Key, f.Op) - *args = append(*args, floatValue) - case "BETWEEN": - floatValue1, err1 := strconv.ParseFloat(fmt.Sprintf("%v", f.Values[0]), 64) - floatValue2, err2 := strconv.ParseFloat(fmt.Sprintf("%v", f.Values[1]), 64) - if err1 != nil || err2 != nil { - logs.CtxError(context.Background(), "Parse float value failed: %v, %v", err1, err2) - continue - } - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND dis.float_map{'%s'} BETWEEN ? AND ?", f.Key) - *args = append(*args, floatValue1, floatValue2) - } - } - // int_map - for _, f := range cond.ItemSnapshotCond.IntMapFilters { - switch f.Op { - case "=", ">", ">=", "<", "<=", "!=": - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND dis.int_map{'%s'} %s ?", f.Key, f.Op) - *args = append(*args, f.Values[0]) - case "BETWEEN": - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND dis.int_map{'%s'} BETWEEN ? AND ?", f.Key) - *args = append(*args, f.Values[0], f.Values[1]) - } - } - // 处理 BoolMapFilters - for _, f := range cond.ItemSnapshotCond.BoolMapFilters { - switch f.Op { - case "=": - boolValue, err := strconv.ParseBool(fmt.Sprintf("%v", f.Values[0])) - if err != nil { - logs.CtxError(context.Background(), "Parse bool value failed: %v", err) - continue - } - intBoolValue := 0 - if boolValue { - intBoolValue = 1 - } - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND dis.bool_map{'%s'} = ?", f.Key) - *args = append(*args, intBoolValue) - case "!=": - boolValue, err := strconv.ParseBool(fmt.Sprintf("%v", f.Values[0])) - if err != nil { - logs.CtxError(context.Background(), "Parse bool value failed: %v", err) - continue - } - intBoolValue := 0 - if boolValue { - intBoolValue = 1 - } - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND dis.bool_map{'%s'} != ?", f.Key) - *args = append(*args, intBoolValue) - default: - logs.CtxWarn(context.Background(), "Unsupported operator %s for BoolMapFilters", f.Op) - } - } - - // string_map - for _, f := range cond.ItemSnapshotCond.StringMapFilters { - switch f.Op { - case "LIKE": - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND dis.string_map{'%s'} LIKE ?", f.Key) - *args = append(*args, "%"+escapeSpecialChars(fmt.Sprintf("%v", f.Values[0]))+"%") - case "=": - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND dis.string_map{'%s'} = ?", f.Key) - *args = append(*args, f.Values[0]) - case "NOT LIKE": - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND dis.string_map{'%s'} NOT LIKE ?", f.Key) - *args = append(*args, "%"+escapeSpecialChars(fmt.Sprintf("%v", f.Values[0]))+"%") - case "!=": - // 删除 mapContains 条件 - *joinSQL += fmt.Sprintf(" AND dis.string_map{'%s'}!=?", f.Key) - *args = append(*args, f.Values[0]) - } - } -} - // buildKeywordSearchConditions 构建全文搜索条件 func (d *exptTurnResultFilterDAOImpl) buildKeywordSearchConditions(ctx context.Context, cond *ExptTurnResultFilterQueryCond, keywordCond *string, args *[]interface{}) { if cond.KeywordSearch == nil || cond.KeywordSearch.Keyword == nil { @@ -463,88 +365,27 @@ func (d *exptTurnResultFilterDAOImpl) buildKeywordSearchConditions(ctx context.C for _, f := range cond.KeywordSearch.EvalTargetDataFilters { *keywordCond += " OR " // 删除 mapContains 条件 - *keywordCond += fmt.Sprintf("etrf.eval_target_data{'%s'} LIKE ?", f.Key) + *keywordCond += fmt.Sprintf("etrf.eval_target_data['%s'] LIKE ?", f.Key) *args = append(*args, "%"+escapeSpecialChars(kw)+"%") } } - // 处理 ItemSnapshotFilter - if cond.KeywordSearch.ItemSnapshotFilter != nil { - // float_map - for _, f := range cond.KeywordSearch.ItemSnapshotFilter.FloatMapFilters { - floatValue, err := strconv.ParseFloat(kw, 64) - if err != nil { - logs.CtxInfo(ctx, "Parse float value failed in keyword search: %v", err) - continue - } - // 删除 mapContains 条件 - *keywordCond += " OR " - *keywordCond += fmt.Sprintf("abs(dis.float_map{'%s'} - ?) < %g", f.Key, floatEpsilon) - *args = append(*args, floatValue) - } - // int_map - for _, f := range cond.KeywordSearch.ItemSnapshotFilter.IntMapFilters { - intValue, err := strconv.ParseInt(kw, 10, 64) - if err != nil { - logs.CtxInfo(ctx, "Parse int value failed in keyword search: %v", err) - continue - } - // 删除 mapContains 条件 - *keywordCond += " OR " - *keywordCond += fmt.Sprintf("dis.int_map{'%s'} = ?", f.Key) - *args = append(*args, intValue) - } - // string_map - for _, f := range cond.KeywordSearch.ItemSnapshotFilter.StringMapFilters { - *keywordCond += " OR " - // 删除 mapContains 条件 - *keywordCond += fmt.Sprintf("dis.string_map{'%s'} LIKE ?", f.Key) - *args = append(*args, "%"+escapeSpecialChars(kw)+"%") - } - // bool_map - boolVal := 0 - switch kw { - case "true": - boolVal = 1 - case "false": - boolVal = 0 - } - if kw == "true" || kw == "false" { - for _, f := range cond.KeywordSearch.ItemSnapshotFilter.BoolMapFilters { - *keywordCond += " OR " - // 删除 mapContains 条件 - *keywordCond += fmt.Sprintf("dis.bool_map{'%s'} = %d", f.Key, boolVal) - } - } - } - *keywordCond += ")" } // buildBaseSQL 构建基础SQL语句 -func (d *exptTurnResultFilterDAOImpl) buildBaseSQL(ctx context.Context, joinSQL, whereSQL, keywordCond, evalSetSyncCkDate string, args *[]interface{}) string { - tableName := d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName - sql := "SELECT etrf.item_id, etrf.status FROM " + d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName + "." + tableName + " etrf" - if joinSQL != "" || keywordCond != "" { - sql += " INNER JOIN " + d.configer.GetCKDBName(ctx).DatasetItemsSnapshotDBName + ".dataset_item_snapshot dis ON etrf.eval_set_version_id = dis.version_id AND etrf.item_id = dis.item_id" - } - - sql += " WHERE 1=1" - - if joinSQL != "" || keywordCond != "" { - sql += " And dis.sync_ck_date = ?" +func (d *exptTurnResultFilterDAOImpl) buildBaseSQL(ctx context.Context, whereSQL, keywordCond string, args *[]interface{}) string { + sql := "SELECT etrf.item_id, etrf.status FROM " + getClickHouseDatabaseName() + ".expt_turn_result_filter etrf" + sql += " FINAL WHERE 1=1" + if keywordCond != "" { // 将 evalSetSyncCkDate 插入到 args 切片的第一个位置 - newArgs := make([]interface{}, 0, len(*args)+1) - newArgs = append(newArgs, evalSetSyncCkDate) + newArgs := make([]interface{}, 0, len(*args)) newArgs = append(newArgs, *args...) *args = newArgs } if whereSQL != "" { sql += whereSQL } - if joinSQL != "" { - sql += joinSQL - } if keywordCond != "" { sql += keywordCond } @@ -553,7 +394,7 @@ func (d *exptTurnResultFilterDAOImpl) buildBaseSQL(ctx context.Context, joinSQL, // getTotalCount 获取总记录数 func (d *exptTurnResultFilterDAOImpl) getTotalCount(ctx context.Context, sql string, args []interface{}) (int64, error) { - countSQL := "SELECT COUNT(DISTINCT etrf.item_id) FROM (" + sql + ")" + countSQL := "SELECT COUNT(DISTINCT item_id) FROM (" + sql + ")" var total int64 logs.CtxInfo(ctx, "Query count sql: %v, args: %v", countSQL, args) if err := d.db.NewSession(ctx).Raw(countSQL, args...).Scan(&total).Error; err != nil { @@ -652,7 +493,6 @@ func (d *exptTurnResultFilterDAOImpl) GetByExptIDItemIDs(ctx context.Context, sp } func (d *exptTurnResultFilterDAOImpl) buildGetByExptIDItemIDsSQL(ctx context.Context, spaceID, exptID, createdDate string, itemIDs []string) (string, []interface{}) { - tableName := d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName sql := "SELECT " + "etrf.space_id, " + "etrf.expt_id, " + @@ -662,19 +502,19 @@ func (d *exptTurnResultFilterDAOImpl) buildGetByExptIDItemIDsSQL(ctx context.Con "etrf.status, " + "etrf.eval_set_version_id, " + "etrf.created_date, " + - "etrf.eval_target_data{'actual_output'} as actual_output, " + - "etrf.evaluator_score{'key1'} as evaluator_score_key_1, " + - "etrf.evaluator_score{'key2'} as evaluator_score_key_2, " + - "etrf.evaluator_score{'key3'} as evaluator_score_key_3, " + - "etrf.evaluator_score{'key4'} as evaluator_score_key_4, " + - "etrf.evaluator_score{'key5'} as evaluator_score_key_5, " + - "etrf.evaluator_score{'key6'} as evaluator_score_key_6, " + - "etrf.evaluator_score{'key7'} as evaluator_score_key_7, " + - "etrf.evaluator_score{'key8'} as evaluator_score_key_8, " + - "etrf.evaluator_score{'key9'} as evaluator_score_key_9, " + - "etrf.evaluator_score{'key10'} as evaluator_score_key_10, " + + "etrf.eval_target_data['actual_output'] as actual_output, " + + "etrf.evaluator_score['key1'] as evaluator_score_key_1, " + + "etrf.evaluator_score['key2'] as evaluator_score_key_2, " + + "etrf.evaluator_score['key3'] as evaluator_score_key_3, " + + "etrf.evaluator_score['key4'] as evaluator_score_key_4, " + + "etrf.evaluator_score['key5'] as evaluator_score_key_5, " + + "etrf.evaluator_score['key6'] as evaluator_score_key_6, " + + "etrf.evaluator_score['key7'] as evaluator_score_key_7, " + + "etrf.evaluator_score['key8'] as evaluator_score_key_8, " + + "etrf.evaluator_score['key9'] as evaluator_score_key_9, " + + "etrf.evaluator_score['key10'] as evaluator_score_key_10, " + "etrf.evaluator_score_corrected " + - "FROM " + d.configer.GetCKDBName(ctx).ExptTurnResultFilterDBName + "." + tableName + " etrf " + + "FROM " + getClickHouseDatabaseName() + ".expt_turn_result_filter" + " etrf " + "WHERE etrf.space_id = ? AND etrf.expt_id = ? AND etrf.created_date =?" if len(itemIDs) > 0 { sql += " AND etrf.item_id IN (?)" @@ -683,4 +523,4 @@ func (d *exptTurnResultFilterDAOImpl) buildGetByExptIDItemIDsSQL(ctx context.Con args := []interface{}{spaceID, exptID, createdDate, itemIDs} logs.CtxInfo(ctx, "GetByExptID sql: %v, args: %v", sql, args) return sql, args -} \ No newline at end of file +} diff --git a/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter_test.go b/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter_test.go index 2359b07d4..3ecb98ac7 100644 --- a/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter_test.go +++ b/backend/modules/evaluation/infra/repo/experiment/ck/expt_turn_result_filter_test.go @@ -5,6 +5,7 @@ package ck import ( "context" + "fmt" "testing" "time" @@ -167,10 +168,9 @@ func TestExptTurnResultFilterDAOImpl_buildQueryConditions(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gotSelectClause, gotWhereClause, gotOrderClause, gotArgs := d.buildQueryConditions(ctx, tt.cond) - assert.NotNil(t, gotSelectClause) - assert.NotNil(t, gotWhereClause) - assert.NotNil(t, gotOrderClause) + whereSQL, keywordCond, gotArgs := d.buildQueryConditions(ctx, tt.cond) + assert.NotNil(t, whereSQL) + assert.NotNil(t, keywordCond) assert.NotNil(t, gotArgs) }) } @@ -186,22 +186,18 @@ func TestExptTurnResultFilterDAOImpl_buildBaseSQL(t *testing.T) { ctx := context.Background() tests := []struct { - name string - joinSQL string - whereSQL string - keywordCond string - evalSetSyncCkDate string - args *[]interface{} - want string + name string + whereSQL string + keywordCond string + args *[]interface{} + want string }{ { - name: "empty_conditions", - joinSQL: "1", - whereSQL: "2", - keywordCond: "3", - evalSetSyncCkDate: "4", - args: &[]interface{}{}, - want: "生成的基础 SQL 预期值,需根据实际实现修改", + name: "empty_conditions", + whereSQL: "2", + keywordCond: "3", + args: &[]interface{}{}, + want: "SELECT etrf.item_id, etrf.status FROM `cozeloop-clickhouse`.expt_turn_result_filter etrf FINAL WHERE 1=123", }, } @@ -210,8 +206,8 @@ func TestExptTurnResultFilterDAOImpl_buildBaseSQL(t *testing.T) { mockConfig.EXPECT().GetCKDBName(gomock.Any()).Return(&entity.CKDBConfig{ ExptTurnResultFilterDBName: "ck", }).AnyTimes() - got := d.buildBaseSQL(ctx, tt.joinSQL, tt.whereSQL, tt.keywordCond, tt.evalSetSyncCkDate, tt.args) - assert.NotNil(t, got) + got := d.buildBaseSQL(ctx, tt.whereSQL, tt.keywordCond, tt.args) + assert.Equal(t, tt.want, got) }) } } @@ -238,15 +234,13 @@ func TestExptTurnResultFilterDAOImpl_appendPaginationArgs(t *testing.T) { }, }, args: []interface{}{}, - want: "生成的基础 SQL 预期值,需根据实际实现修改", + want: "LIMIT 10 OFFSET 0", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { args := d.appendPaginationArgs(tt.args, tt.cond) - if len(args) != 2 { - t.Errorf("appendPaginationArgs failed, args len not equal 2, args: %v", args) - } + assert.Equal(t, tt.want, fmt.Sprintf("LIMIT %d OFFSET %d", args[len(args)-2], args[len(args)-1])) }) } } @@ -278,11 +272,11 @@ func TestExptTurnResultFilterDAOImpl_buildGetByExptIDItemIDsSQL(t *testing.T) { t.Run(tt.name, func(t *testing.T) { mockConfig.EXPECT().GetCKDBName(gomock.Any()).Return(&entity.CKDBConfig{ ExptTurnResultFilterDBName: "ck", - }) + }).AnyTimes() got, args := d.buildGetByExptIDItemIDsSQL(ctx, tt.spaceID, tt.exptID, tt.createdDate, tt.itemIDs) assert.NotNil(t, got) if len(args) != 4 { - t.Errorf("buildGetByExptIDItemIDsSQL failed, args len not equal 3, args: %v", args) + t.Errorf("buildGetByExptIDItemIDsSQL failed, args len not equal 4, args: %v", args) } }) } diff --git a/backend/modules/evaluation/infra/repo/experiment/expt_turn_result_filter_repo_impl.go b/backend/modules/evaluation/infra/repo/experiment/expt_turn_result_filter_repo_impl.go index c14af9f6c..24b6ff8ed 100644 --- a/backend/modules/evaluation/infra/repo/experiment/expt_turn_result_filter_repo_impl.go +++ b/backend/modules/evaluation/infra/repo/experiment/expt_turn_result_filter_repo_impl.go @@ -6,6 +6,7 @@ package experiment import ( "context" "strconv" + "time" "github.com/coze-dev/coze-loop/backend/infra/db" "github.com/coze-dev/coze-loop/backend/modules/evaluation/domain/entity" @@ -40,6 +41,7 @@ func (e *ExptTurnResultFilterRepoImpl) Save(ctx context.Context, filter []*entit // 转换为 model.ExptTurnResultFilterAccelerator models := make([]*model.ExptTurnResultFilter, 0, len(filter)) for _, filterEntity := range filter { + filterEntity.UpdatedAt = time.Now() models = append(models, convertor.ExptTurnResultFilterEntity2PO(filterEntity)) } logs.CtxInfo(ctx, "ExptTurnResultFilterRepoImpl.Save: %v", json.Jsonify(models)) diff --git a/backend/modules/evaluation/pkg/conf/expt.go b/backend/modules/evaluation/pkg/conf/expt.go index 7d317424f..35b7d6400 100644 --- a/backend/modules/evaluation/pkg/conf/expt.go +++ b/backend/modules/evaluation/pkg/conf/expt.go @@ -54,7 +54,9 @@ func (c *configer) GetExptTurnResultFilterBmqProducerCfg(ctx context.Context) *e } func (c *configer) GetCKDBName(ctx context.Context) *entity.CKDBConfig { - return nil + const key = "clickhouse_config" + ckdb := &entity.CKDBConfig{} + return lo.Ternary(c.loader.UnmarshalKey(ctx, key, ckdb) == nil, ckdb, &entity.CKDBConfig{}) } func (c *configer) GetExptExportWhiteList(ctx context.Context) (eec *entity.ExptExportWhiteList) { diff --git a/frontend/packages/cozeloop/evaluate/src/pages/experiment/detail/components/experiment-detail-table/index.tsx b/frontend/packages/cozeloop/evaluate/src/pages/experiment/detail/components/experiment-detail-table/index.tsx index da3fc3ab3..d71e06600 100644 --- a/frontend/packages/cozeloop/evaluate/src/pages/experiment/detail/components/experiment-detail-table/index.tsx +++ b/frontend/packages/cozeloop/evaluate/src/pages/experiment/detail/components/experiment-detail-table/index.tsx @@ -11,7 +11,6 @@ import { type LogicField, type SemiTableSort, } from '@cozeloop/evaluate-components'; -import { IS_HIDDEN_EXPERIMENT_DETAIL_FILTER } from '@cozeloop/biz-hooks-adapter'; import { type Experiment, FieldType, @@ -423,12 +422,7 @@ export default function ({ service={service as Service} heightFull={true} - header={ - - } + header={} pageSizeStorageKey="experiment_detail_page_size" empty={tableEmpty} tableProps={tableProps} diff --git a/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql b/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql index f72756ac1..482518670 100755 --- a/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql +++ b/release/deployment/docker-compose/bootstrap/clickhouse-init/init-sql/evaluation.sql @@ -1,11 +1,8 @@ -- Copyright (c) 2025 coze-dev Authors -- SPDX-License-Identifier: Apache-2.0 --- Create database if not exists -CREATE DATABASE IF NOT EXISTS cozeloop_evaluation; - --- Create expt_turn_result_filter_local table for docker environment -CREATE TABLE IF NOT EXISTS cozeloop_evaluation.expt_turn_result_filter_local +-- Create expt_turn_result_filter table for docker environment +CREATE TABLE IF NOT EXISTS expt_turn_result_filter ( `space_id` String, `expt_id` String, @@ -28,8 +25,7 @@ CREATE TABLE IF NOT EXISTS cozeloop_evaluation.expt_turn_result_filter_local INDEX idx_item_id item_id TYPE bloom_filter() GRANULARITY 1, INDEX idx_turn_id turn_id TYPE bloom_filter() GRANULARITY 1 ) -ENGINE = MergeTree() +ENGINE = ReplacingMergeTree(updated_at) PARTITION BY created_date -ORDER BY (expt_id, cityHash64(item_id), turn_id) -SAMPLE BY cityHash64(item_id) +ORDER BY (expt_id, item_id, turn_id) SETTINGS index_granularity = 8192; \ No newline at end of file diff --git a/release/deployment/docker-compose/conf/evaluation.yaml b/release/deployment/docker-compose/conf/evaluation.yaml index b0032f53c..997c59915 100644 --- a/release/deployment/docker-compose/conf/evaluation.yaml +++ b/release/deployment/docker-compose/conf/evaluation.yaml @@ -49,7 +49,7 @@ expt_export_csv_event_rmq: # ClickHouse table configuration clickhouse_table_config: - expt_turn_result_filter_table_name: 'expt_turn_result_filter_local' + expt_turn_result_filter_table_name: 'expt_turn_result_filter' rate_limiter_conf: - key_expr: biz_key + string(space_id) @@ -2199,4 +2199,7 @@ code_evaluator_template_conf: code_template_name: "包含性检查器" expt_export_white_list: - allow_all: true \ No newline at end of file + allow_all: true + +clickhouse_config: + expt_turn_result_filter_db_name: "cozeloop-clickhouse" diff --git a/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql b/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql index f1f584b4b..6411cc376 100755 --- a/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql +++ b/release/deployment/helm-chart/charts/app/bootstrap/init/clickhouse/init-sql/evaluation.sql @@ -1,11 +1,8 @@ -- Copyright (c) 2025 coze-dev Authors -- SPDX-License-Identifier: Apache-2.0 --- Create database if not exists -CREATE DATABASE IF NOT EXISTS cozeloop_evaluation; - --- Create expt_turn_result_filter_local table for kubernetes environment -CREATE TABLE IF NOT EXISTS cozeloop_evaluation.expt_turn_result_filter_local +-- Create expt_turn_result_filter table for docker environment +CREATE TABLE IF NOT EXISTS expt_turn_result_filter ( `space_id` String, `expt_id` String, @@ -27,9 +24,8 @@ CREATE TABLE IF NOT EXISTS cozeloop_evaluation.expt_turn_result_filter_local INDEX idx_expt_id expt_id TYPE bloom_filter() GRANULARITY 1, INDEX idx_item_id item_id TYPE bloom_filter() GRANULARITY 1, INDEX idx_turn_id turn_id TYPE bloom_filter() GRANULARITY 1 -) -ENGINE = ReplicatedReplacingMergeTree('/clickhouse/stone_dataengine_commercial/cozeloop_evaluation/{shard}', '{replica}') -PARTITION BY created_date -ORDER BY (expt_id, cityHash64(item_id), turn_id) -SAMPLE BY cityHash64(item_id) -SETTINGS index_granularity = 8192; \ No newline at end of file + ) + ENGINE = ReplacingMergeTree(updated_at) + PARTITION BY created_date + ORDER BY (expt_id, item_id, turn_id) + SETTINGS index_granularity = 8192; \ No newline at end of file diff --git a/release/deployment/helm-chart/umbrella/conf/evaluation.yaml b/release/deployment/helm-chart/umbrella/conf/evaluation.yaml index 047f02fdf..d65d0d4da 100644 --- a/release/deployment/helm-chart/umbrella/conf/evaluation.yaml +++ b/release/deployment/helm-chart/umbrella/conf/evaluation.yaml @@ -49,7 +49,7 @@ expt_export_csv_event_rmq: # ClickHouse table configuration clickhouse_table_config: - expt_turn_result_filter_table_name: 'expt_turn_result_filter_local' + expt_turn_result_filter_table_name: 'expt_turn_result_filter' rate_limiter_conf: - key_expr: biz_key + string(space_id) @@ -2199,4 +2199,7 @@ code_evaluator_template_conf: code_template_name: "包含性检查器" expt_export_white_list: - allow_all: true \ No newline at end of file + allow_all: true + +clickhouse_config: + expt_turn_result_filter_db_name: "cozeloop-clickhouse" \ No newline at end of file From 7a60f1963cd2ada7e72174e1a219a9b7bd2887b8 Mon Sep 17 00:00:00 2001 From: tpfz Date: Wed, 22 Oct 2025 15:03:05 +0800 Subject: [PATCH 6/9] k8s draft --- .../helm-chart/charts/app/values.yaml | 12 +- .../helm-chart/charts/nginx/values.yaml | 6 +- .../umbrella/conf/model_config.yaml | 146 ++++++++++++++++-- .../helm-chart/umbrella/values.yaml | 15 +- 4 files changed, 160 insertions(+), 19 deletions(-) diff --git a/release/deployment/helm-chart/charts/app/values.yaml b/release/deployment/helm-chart/charts/app/values.yaml index 73d1a0316..fc32c9937 100644 --- a/release/deployment/helm-chart/charts/app/values.yaml +++ b/release/deployment/helm-chart/charts/app/values.yaml @@ -4,12 +4,12 @@ service: targetPort: 8888 image: - registry: "docker.io" - repository: "cozedev" + registry: "" + repository: "" image: "coze-loop" - tag: "1.2.0" - pullPolicy: Always - pullSecrets: "coze-loop-image-secret" + tag: "dev" + pullPolicy: Never + pullSecrets: "" init_image: redis: @@ -119,4 +119,4 @@ custom: domain: port: user: - password: \ No newline at end of file + password: diff --git a/release/deployment/helm-chart/charts/nginx/values.yaml b/release/deployment/helm-chart/charts/nginx/values.yaml index ba41048d4..8131590c8 100644 --- a/release/deployment/helm-chart/charts/nginx/values.yaml +++ b/release/deployment/helm-chart/charts/nginx/values.yaml @@ -13,10 +13,10 @@ image: init_image: app: - registry: "docker.io" - repository: "cozedev" + registry: "" + repository: "" image: "coze-loop" - tag: "1.2.0" + tag: "dev" pullSecrets: "coze-loop-image-secret" deployment: diff --git a/release/deployment/helm-chart/umbrella/conf/model_config.yaml b/release/deployment/helm-chart/umbrella/conf/model_config.yaml index 2aab6ca79..7f32ef4dc 100644 --- a/release/deployment/helm-chart/umbrella/conf/model_config.yaml +++ b/release/deployment/helm-chart/umbrella/conf/model_config.yaml @@ -1,31 +1,159 @@ models: + # reasoning model - id: 1 - name: "doubao" + workspace_id: 0 # In the future, there will be the concept of public/private workspaces. Public models are managed by the public workspace, private models by the private workspace. Currently, all models belong to the public workspace, and the public workspace id is temporarily set to 0. + name: "deepseek-r1-distill-qwen-32b-250120" frame: "eino" protocol: "ark" protocol_config: - api_key: "***" - model: "***" + api_key: "a715a14b-3b93-47da-8bc9-844c12fecff7" + model: "ep-20250304143659-5bcjt" param_config: param_schemas: - name: "temperature" label: "temperature" - desc: "Increasing temperature makes model output more diverse and creative, while decreasing it makes output more focused on instructions but less diverse. It's recommended not to adjust this simultaneously with 'Top p'." + desc: "Increasing temperature will make the model output more diverse and creative. Conversely, lowering the temperature will make the output more compliant with instructions but reduce diversity. It is recommended not to adjust together with 'Top p'." type: "float" min: "0" max: "1.0" default_val: "0.7" - name: "max_tokens" label: "max_tokens" - desc: "Controls the maximum number of tokens in model output. Typically, 100 tokens equals about 150 Chinese characters." + desc: "Controls the maximum length of model output tokens. Typically, 100 tokens are about 150 Chinese characters." type: "int" min: "1" - max: "4096" + max: "8192" default_val: "2048" + # multimodal model + - id: 2 + workspace_id: 0 # In the future, there will be the concept of public/private workspaces. Public models are managed by the public workspace, private models by the private workspace. Currently, all models belong to the public workspace, and the public workspace id is temporarily set to 0. + name: "doubao-1.5-vision-pro-32k" + desc: "" + ability: + max_context_tokens: 65536 + max_input_tokens: 65536 + max_output_tokens: 8192 + function_call: false + json_mode: false + multi_modal: true + ability_multi_modal: + image: true + ability_image: + url_enabled: true + binary_enabled: true + max_image_size: 20 # unit MB + max_image_count: 20 + frame: "eino" + protocol: "ark" + protocol_config: + base_url: "https://ark.cn-beijing.volces.com/api/v3" + api_key: "a715a14b-3b93-47da-8bc9-844c12fecff7" + model: "ep-20250304145131-ndcct" + protocol_config_ark: + region: "cn-beijing" + scenario_configs: + default: + scenario: "default" + quota: + qpm: 0 + tpm: 0 + unavailable: false + evaluator: + scenario: "evaluator" + quota: + qpm: 0 + tpm: 0 + unavailable: false + param_config: + param_schemas: + - name: "temperature" + label: "temperature" + desc: "Increasing temperature will make the model output more diverse and creative. Conversely, lowering the temperature will make the output more compliant with instructions but reduce diversity. It is recommended not to adjust together with 'Top p'." + type: "float" + min: "0" + max: "1.0" + default_val: "0.7" + - name: "max_tokens" + label: "max_tokens" + desc: "Controls the maximum length of model output tokens. Typically, 100 tokens are about 150 Chinese characters." + type: "int" + min: "1" + max: "8192" + default_val: "2048" + # fc model + - id: 3 + workspace_id: 0 # In the future, there will be the concept of public/private workspaces. Public models are managed by the public workspace, private models by the private workspace. Currently, all models belong to the public workspace, and the public workspace id is temporarily set to 0. + name: "doubao-1.5-lite-32k" + desc: "" + ability: + max_context_tokens: 32000 + max_input_tokens: 32000 + max_output_tokens: 12000 + function_call: true + json_mode: false + multi_modal: false + frame: "eino" + protocol: "ark" + protocol_config: + base_url: "https://ark.cn-beijing.volces.com/api/v3" + api_key: "a715a14b-3b93-47da-8bc9-844c12fecff7" + model: "ep-20250227201314-frn9m" + protocol_config_ark: + region: "cn-beijing" + scenario_configs: + default: + scenario: "default" + quota: + qpm: 0 + tpm: 0 + unavailable: false + evaluator: + scenario: "evaluator" + quota: + qpm: 0 + tpm: 0 + unavailable: false + param_config: + param_schemas: + - name: "temperature" + label: "temperature" + desc: "Increasing temperature will make the model output more diverse and creative. Conversely, lowering the temperature will make the output more compliant with instructions but reduce diversity. It is recommended not to adjust together with 'Top p'." + type: "float" + min: "0" + max: "1.0" + default_val: "0.1" - name: "top_p" label: "top_p" - desc: "Selects the minimum token set with cumulative probability reaching top_p during generation, excluding tokens outside the set, balancing diversity and reasonableness." + desc: "The model will consider token results within top_p probability mass." type: "float" - min: "0.001" + min: "0" max: "1.0" - default_val: "0.7" + default_val: "0.1" + - name: "max_tokens" + label: "max_tokens" + desc: "Controls the maximum length of model output tokens. Typically, 100 tokens are about 150 Chinese characters." + type: "int" + min: "1" + max: "8192" + default_val: "2048" + - name: "top_k" + label: "top_k" # Displayed as a name on the front end + desc: "Only sample from the top k tokens with the highest probability to limit the candidate range and improve generation stability." # Displayed as a description on the front end + type: "int" # Required. Must be float, int, bool, string + min: "1" + max: "100" + default_val: "50" + - name: "frequency_penalty" + label: "frequency_penalty" # Displayed as a name on the front end + desc: "Penalizes generated tokens, with higher frequency resulting in higher penalties, suppressing repetitive content." # Displayed as a description on the front end + type: "float" # Required. Must be float, int, bool, string + min: "0" + max: "2.0" + default_val: "0" + - name: "presence_penalty" + label: "presence_penalty" # Displayed as a name on the front end + desc: "Penalizes all tokens that have appeared, preventing the same content from appearing repeatedly, increasing content diversity." # Displayed as a description on the front end + type: "float" # Required. Must be float, int, bool, string + min: "0" + max: "2.0" + default_val: "0" \ No newline at end of file diff --git a/release/deployment/helm-chart/umbrella/values.yaml b/release/deployment/helm-chart/umbrella/values.yaml index a10666cc2..fbe10db90 100644 --- a/release/deployment/helm-chart/umbrella/values.yaml +++ b/release/deployment/helm-chart/umbrella/values.yaml @@ -15,7 +15,20 @@ custom: &custom # 固定,不要动,用于传递全局变量 coze-loop-app: - custom: *custom + custom: + image: + registry: "" + pullSecrets: "***" + redis: + disabled: true + mysql: + disabled: true + clickhouse: + disabled: true + oss: + disabled: true + rmq: + disabled: true coze-loop-nginx: custom: *custom coze-loop-redis: From 0b0ed25bffab43382e9378c8129585a2293418ae Mon Sep 17 00:00:00 2001 From: tpfz Date: Tue, 18 Nov 2025 15:05:57 +0800 Subject: [PATCH 7/9] rebase main --- .../expt_turn_result_filter_repo_impl_test.go | 23 +-- .../helm-chart/charts/app/values.yaml | 12 +- .../helm-chart/charts/nginx/values.yaml | 6 +- .../umbrella/conf/model_config.yaml | 146 ++---------------- .../helm-chart/umbrella/values.yaml | 15 +- 5 files changed, 31 insertions(+), 171 deletions(-) diff --git a/backend/modules/evaluation/infra/repo/experiment/expt_turn_result_filter_repo_impl_test.go b/backend/modules/evaluation/infra/repo/experiment/expt_turn_result_filter_repo_impl_test.go index d95a93c38..2ef857f8b 100644 --- a/backend/modules/evaluation/infra/repo/experiment/expt_turn_result_filter_repo_impl_test.go +++ b/backend/modules/evaluation/infra/repo/experiment/expt_turn_result_filter_repo_impl_test.go @@ -9,7 +9,6 @@ import ( "time" "github.com/coze-dev/coze-loop/backend/modules/evaluation/domain/entity" - "github.com/coze-dev/coze-loop/backend/modules/evaluation/infra/repo/experiment/ck/convertor" "github.com/coze-dev/coze-loop/backend/modules/evaluation/infra/repo/experiment/ck/gorm_gen/model" ckmocks "github.com/coze-dev/coze-loop/backend/modules/evaluation/infra/repo/experiment/ck/mocks" diffmodel "github.com/coze-dev/coze-loop/backend/modules/evaluation/infra/repo/experiment/ck/model" @@ -43,11 +42,17 @@ func TestExptTurnResultFilterRepoImpl_Save(t *testing.T) { { name: "success", mockSetup: func() { - models := make([]*model.ExptTurnResultFilter, 0, len(filterEntities)) - for _, filterEntity := range filterEntities { - models = append(models, convertor.ExptTurnResultFilterEntity2PO(filterEntity)) - } - mockExptTurnResultFilterDAO.EXPECT().Save(gomock.Any(), models).Return(nil) + // 使用 Do 方法来验证参数,忽略 UpdatedAt 字段的差异 + mockExptTurnResultFilterDAO.EXPECT().Save(gomock.Any(), gomock.Any()).DoAndReturn( + func(ctx context.Context, models []*model.ExptTurnResultFilter) error { + assert.Equal(t, 2, len(models)) + assert.Equal(t, "1", models[0].SpaceID) + assert.Equal(t, "100", models[0].ExptID) + assert.Equal(t, "2", models[1].SpaceID) + assert.Equal(t, "200", models[1].ExptID) + return nil + }, + ) }, input: filterEntities, wantErr: false, @@ -55,11 +60,7 @@ func TestExptTurnResultFilterRepoImpl_Save(t *testing.T) { { name: "fail_dao_save", mockSetup: func() { - models := make([]*model.ExptTurnResultFilter, 0, len(filterEntities)) - for _, filterEntity := range filterEntities { - models = append(models, convertor.ExptTurnResultFilterEntity2PO(filterEntity)) - } - mockExptTurnResultFilterDAO.EXPECT().Save(gomock.Any(), models).Return(assert.AnError) + mockExptTurnResultFilterDAO.EXPECT().Save(gomock.Any(), gomock.Any()).Return(assert.AnError) }, input: filterEntities, wantErr: true, diff --git a/release/deployment/helm-chart/charts/app/values.yaml b/release/deployment/helm-chart/charts/app/values.yaml index 269b32a2e..fb87160d6 100644 --- a/release/deployment/helm-chart/charts/app/values.yaml +++ b/release/deployment/helm-chart/charts/app/values.yaml @@ -4,12 +4,12 @@ service: targetPort: 8888 image: - registry: "" - repository: "" + registry: "docker.io" + repository: "cozedev" image: "coze-loop" - tag: "dev" - pullPolicy: Never - pullSecrets: "" + tag: "1.4.1" + pullPolicy: Always + pullSecrets: "coze-loop-image-secret" init_image: redis: @@ -125,4 +125,4 @@ custom: domain: port: user: - password: + password: \ No newline at end of file diff --git a/release/deployment/helm-chart/charts/nginx/values.yaml b/release/deployment/helm-chart/charts/nginx/values.yaml index 8131590c8..c79cbca81 100644 --- a/release/deployment/helm-chart/charts/nginx/values.yaml +++ b/release/deployment/helm-chart/charts/nginx/values.yaml @@ -13,10 +13,10 @@ image: init_image: app: - registry: "" - repository: "" + registry: "docker.io" + repository: "cozedev" image: "coze-loop" - tag: "dev" + tag: "1.4.1" pullSecrets: "coze-loop-image-secret" deployment: diff --git a/release/deployment/helm-chart/umbrella/conf/model_config.yaml b/release/deployment/helm-chart/umbrella/conf/model_config.yaml index 7f32ef4dc..2aab6ca79 100644 --- a/release/deployment/helm-chart/umbrella/conf/model_config.yaml +++ b/release/deployment/helm-chart/umbrella/conf/model_config.yaml @@ -1,159 +1,31 @@ models: - # reasoning model - id: 1 - workspace_id: 0 # In the future, there will be the concept of public/private workspaces. Public models are managed by the public workspace, private models by the private workspace. Currently, all models belong to the public workspace, and the public workspace id is temporarily set to 0. - name: "deepseek-r1-distill-qwen-32b-250120" + name: "doubao" frame: "eino" protocol: "ark" protocol_config: - api_key: "a715a14b-3b93-47da-8bc9-844c12fecff7" - model: "ep-20250304143659-5bcjt" + api_key: "***" + model: "***" param_config: param_schemas: - name: "temperature" label: "temperature" - desc: "Increasing temperature will make the model output more diverse and creative. Conversely, lowering the temperature will make the output more compliant with instructions but reduce diversity. It is recommended not to adjust together with 'Top p'." + desc: "Increasing temperature makes model output more diverse and creative, while decreasing it makes output more focused on instructions but less diverse. It's recommended not to adjust this simultaneously with 'Top p'." type: "float" min: "0" max: "1.0" default_val: "0.7" - name: "max_tokens" label: "max_tokens" - desc: "Controls the maximum length of model output tokens. Typically, 100 tokens are about 150 Chinese characters." + desc: "Controls the maximum number of tokens in model output. Typically, 100 tokens equals about 150 Chinese characters." type: "int" min: "1" - max: "8192" + max: "4096" default_val: "2048" - # multimodal model - - id: 2 - workspace_id: 0 # In the future, there will be the concept of public/private workspaces. Public models are managed by the public workspace, private models by the private workspace. Currently, all models belong to the public workspace, and the public workspace id is temporarily set to 0. - name: "doubao-1.5-vision-pro-32k" - desc: "" - ability: - max_context_tokens: 65536 - max_input_tokens: 65536 - max_output_tokens: 8192 - function_call: false - json_mode: false - multi_modal: true - ability_multi_modal: - image: true - ability_image: - url_enabled: true - binary_enabled: true - max_image_size: 20 # unit MB - max_image_count: 20 - frame: "eino" - protocol: "ark" - protocol_config: - base_url: "https://ark.cn-beijing.volces.com/api/v3" - api_key: "a715a14b-3b93-47da-8bc9-844c12fecff7" - model: "ep-20250304145131-ndcct" - protocol_config_ark: - region: "cn-beijing" - scenario_configs: - default: - scenario: "default" - quota: - qpm: 0 - tpm: 0 - unavailable: false - evaluator: - scenario: "evaluator" - quota: - qpm: 0 - tpm: 0 - unavailable: false - param_config: - param_schemas: - - name: "temperature" - label: "temperature" - desc: "Increasing temperature will make the model output more diverse and creative. Conversely, lowering the temperature will make the output more compliant with instructions but reduce diversity. It is recommended not to adjust together with 'Top p'." - type: "float" - min: "0" - max: "1.0" - default_val: "0.7" - - name: "max_tokens" - label: "max_tokens" - desc: "Controls the maximum length of model output tokens. Typically, 100 tokens are about 150 Chinese characters." - type: "int" - min: "1" - max: "8192" - default_val: "2048" - # fc model - - id: 3 - workspace_id: 0 # In the future, there will be the concept of public/private workspaces. Public models are managed by the public workspace, private models by the private workspace. Currently, all models belong to the public workspace, and the public workspace id is temporarily set to 0. - name: "doubao-1.5-lite-32k" - desc: "" - ability: - max_context_tokens: 32000 - max_input_tokens: 32000 - max_output_tokens: 12000 - function_call: true - json_mode: false - multi_modal: false - frame: "eino" - protocol: "ark" - protocol_config: - base_url: "https://ark.cn-beijing.volces.com/api/v3" - api_key: "a715a14b-3b93-47da-8bc9-844c12fecff7" - model: "ep-20250227201314-frn9m" - protocol_config_ark: - region: "cn-beijing" - scenario_configs: - default: - scenario: "default" - quota: - qpm: 0 - tpm: 0 - unavailable: false - evaluator: - scenario: "evaluator" - quota: - qpm: 0 - tpm: 0 - unavailable: false - param_config: - param_schemas: - - name: "temperature" - label: "temperature" - desc: "Increasing temperature will make the model output more diverse and creative. Conversely, lowering the temperature will make the output more compliant with instructions but reduce diversity. It is recommended not to adjust together with 'Top p'." - type: "float" - min: "0" - max: "1.0" - default_val: "0.1" - name: "top_p" label: "top_p" - desc: "The model will consider token results within top_p probability mass." + desc: "Selects the minimum token set with cumulative probability reaching top_p during generation, excluding tokens outside the set, balancing diversity and reasonableness." type: "float" - min: "0" + min: "0.001" max: "1.0" - default_val: "0.1" - - name: "max_tokens" - label: "max_tokens" - desc: "Controls the maximum length of model output tokens. Typically, 100 tokens are about 150 Chinese characters." - type: "int" - min: "1" - max: "8192" - default_val: "2048" - - name: "top_k" - label: "top_k" # Displayed as a name on the front end - desc: "Only sample from the top k tokens with the highest probability to limit the candidate range and improve generation stability." # Displayed as a description on the front end - type: "int" # Required. Must be float, int, bool, string - min: "1" - max: "100" - default_val: "50" - - name: "frequency_penalty" - label: "frequency_penalty" # Displayed as a name on the front end - desc: "Penalizes generated tokens, with higher frequency resulting in higher penalties, suppressing repetitive content." # Displayed as a description on the front end - type: "float" # Required. Must be float, int, bool, string - min: "0" - max: "2.0" - default_val: "0" - - name: "presence_penalty" - label: "presence_penalty" # Displayed as a name on the front end - desc: "Penalizes all tokens that have appeared, preventing the same content from appearing repeatedly, increasing content diversity." # Displayed as a description on the front end - type: "float" # Required. Must be float, int, bool, string - min: "0" - max: "2.0" - default_val: "0" \ No newline at end of file + default_val: "0.7" diff --git a/release/deployment/helm-chart/umbrella/values.yaml b/release/deployment/helm-chart/umbrella/values.yaml index 883b5435a..ce9987142 100644 --- a/release/deployment/helm-chart/umbrella/values.yaml +++ b/release/deployment/helm-chart/umbrella/values.yaml @@ -15,20 +15,7 @@ custom: &custom # 固定,不要动,用于传递全局变量 coze-loop-app: - custom: - image: - registry: "" - pullSecrets: "***" - redis: - disabled: true - mysql: - disabled: true - clickhouse: - disabled: true - oss: - disabled: true - rmq: - disabled: true + custom: *custom coze-loop-nginx: custom: *custom coze-loop-redis: From 796520ab8a57b37108e1d505f5e9ae91b8c408aa Mon Sep 17 00:00:00 2001 From: "yangfeng.alanyf" Date: Tue, 18 Nov 2025 17:27:00 +0800 Subject: [PATCH 8/9] chore(evaluate): enable evaluate experiment detail filter --- .../components/contrast-table/table-header.tsx | 8 +------- .../contrast/utils/logic-filter-tools.tsx | 6 +++--- .../logic-filter-fields.tsx | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/frontend/packages/cozeloop/evaluate/src/pages/experiment/contrast/components/contrast-table/table-header.tsx b/frontend/packages/cozeloop/evaluate/src/pages/experiment/contrast/components/contrast-table/table-header.tsx index 20e2a8b2a..bba205508 100644 --- a/frontend/packages/cozeloop/evaluate/src/pages/experiment/contrast/components/contrast-table/table-header.tsx +++ b/frontend/packages/cozeloop/evaluate/src/pages/experiment/contrast/components/contrast-table/table-header.tsx @@ -9,7 +9,6 @@ import { ColumnsManage, RefreshButton, } from '@cozeloop/evaluate-components'; -import { IS_HIDDEN_EXPERIMENT_DETAIL_FILTER } from '@cozeloop/biz-hooks-adapter'; import { type ColumnEvaluator, type Experiment, @@ -199,10 +198,5 @@ export default function ExperimentContrastTableHeader({ ); - return ( - - ); + return ; } diff --git a/frontend/packages/cozeloop/evaluate/src/pages/experiment/contrast/utils/logic-filter-tools.tsx b/frontend/packages/cozeloop/evaluate/src/pages/experiment/contrast/utils/logic-filter-tools.tsx index 698c3acca..537f78443 100644 --- a/frontend/packages/cozeloop/evaluate/src/pages/experiment/contrast/utils/logic-filter-tools.tsx +++ b/frontend/packages/cozeloop/evaluate/src/pages/experiment/contrast/utils/logic-filter-tools.tsx @@ -9,7 +9,7 @@ import { } from '@cozeloop/evaluate-components'; import { FieldType, type Experiment } from '@cozeloop/api-schema/evaluation'; -import { ExperimentItemRunStatusSelect } from '@/components/experiment'; +import { ExprGroupItemRunStatusSelect } from '@/components/experiment'; export function getExperimentContrastLogicFields( experiments: Experiment[], @@ -27,11 +27,11 @@ export function getExperimentContrastLogicFields( return [ { title: I18n.t('status'), - name: getLogicFieldName(FieldType.TurnRunState, 'turn_status'), + name: getLogicFieldName(FieldType.ItemRunState, ''), type: 'options', // 禁用等于和不等于操作符 disabledOperations: ['equals', 'not-equals'], - setter: ExperimentItemRunStatusSelect, + setter: ExprGroupItemRunStatusSelect, setterProps: { className: 'w-full', prefix: '', diff --git a/frontend/packages/cozeloop/evaluate/src/pages/experiment/detail/components/experiment-detail-table/logic-filter-fields.tsx b/frontend/packages/cozeloop/evaluate/src/pages/experiment/detail/components/experiment-detail-table/logic-filter-fields.tsx index 82ed1ac90..8e124e007 100644 --- a/frontend/packages/cozeloop/evaluate/src/pages/experiment/detail/components/experiment-detail-table/logic-filter-fields.tsx +++ b/frontend/packages/cozeloop/evaluate/src/pages/experiment/detail/components/experiment-detail-table/logic-filter-fields.tsx @@ -6,6 +6,7 @@ import { getLogicFieldName, type LogicField, } from '@cozeloop/evaluate-components'; +import { IS_HIDDEN_EXPERIMENT_DETAIL_FILTER } from '@cozeloop/biz-hooks-adapter'; import { type ColumnEvaluator, FieldType, @@ -134,6 +135,14 @@ export function getFilterFields( fieldSchemas: FieldSchema[], columnAnnotations: ColumnAnnotation[], ) { + const evalSetField: LogicField = { + title: I18n.t('evaluation_set'), + name: 'eval_set', + type: 'options', + children: fieldSchemas + ?.filter(item => item?.content_type === ContentType.Text) + ?.map(getEvalSetLogicField), + }; const fields: LogicField[] = [ { title: I18n.t('evaluator'), @@ -141,14 +150,7 @@ export function getFilterFields( type: 'options', children: columnEvaluators.map(getEvaluatorLogicField), }, - { - title: I18n.t('evaluation_set'), - name: 'eval_set', - type: 'options', - children: fieldSchemas - ?.filter(item => item?.content_type === ContentType.Text) - ?.map(getEvalSetLogicField), - }, + ...(IS_HIDDEN_EXPERIMENT_DETAIL_FILTER ? [] : [evalSetField]), { title: I18n.t('manual_annotation'), name: 'annotation', From 947b30e7daa1fc1724dcf4673de434dc2f74ddc7 Mon Sep 17 00:00:00 2001 From: tpfz Date: Wed, 19 Nov 2025 18:01:37 +0800 Subject: [PATCH 9/9] fix bug --- .../ck/convertor/expt_turn_result_filter.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/modules/evaluation/infra/repo/experiment/ck/convertor/expt_turn_result_filter.go b/backend/modules/evaluation/infra/repo/experiment/ck/convertor/expt_turn_result_filter.go index 842a9853b..b164441b5 100644 --- a/backend/modules/evaluation/infra/repo/experiment/ck/convertor/expt_turn_result_filter.go +++ b/backend/modules/evaluation/infra/repo/experiment/ck/convertor/expt_turn_result_filter.go @@ -25,7 +25,7 @@ func ExptTurnResultFilterEntity2PO(filterEntity *entity.ExptTurnResultFilterEnti } } - return &model.ExptTurnResultFilter{ + exptTurnResultFilter := &model.ExptTurnResultFilter{ SpaceID: strconv.FormatInt(filterEntity.SpaceID, 10), ExptID: strconv.FormatInt(filterEntity.ExptID, 10), ItemID: strconv.FormatInt(filterEntity.ItemID, 10), @@ -41,6 +41,11 @@ func ExptTurnResultFilterEntity2PO(filterEntity *entity.ExptTurnResultFilterEnti EvalSetVersionID: strconv.FormatInt(filterEntity.EvalSetVersionID, 10), UpdatedAt: filterEntity.UpdatedAt, } + if filterEntity.EvaluatorScoreCorrected { + exptTurnResultFilter.EvaluatorScoreCorrected = 1 + } + + return exptTurnResultFilter } // ExptTurnResultFilterPO2Entity 将 model.ExptTurnResultFilterAccelerator 转换为 ExptTurnResultFilterEntity @@ -54,7 +59,7 @@ func ExptTurnResultFilterPO2Entity(filterPO *model.ExptTurnResultFilter) *entity annotationBool[k] = v > 0 } - return &entity.ExptTurnResultFilterEntity{ + exptTurnResultFilterEntity := &entity.ExptTurnResultFilterEntity{ SpaceID: ParseStringToInt64(filterPO.SpaceID), ExptID: ParseStringToInt64(filterPO.ExptID), ItemID: ParseStringToInt64(filterPO.ItemID), @@ -69,6 +74,10 @@ func ExptTurnResultFilterPO2Entity(filterPO *model.ExptTurnResultFilter) *entity CreatedDate: filterPO.CreatedDate, EvalSetVersionID: ParseStringToInt64(filterPO.EvalSetVersionID), } + if filterPO.EvaluatorScoreCorrected > 0 { + exptTurnResultFilterEntity.EvaluatorScoreCorrected = true + } + return exptTurnResultFilterEntity } // ParseStringToInt64 将 string 转换为 int64