Skip to content

Commit ee7c5d5

Browse files
lizwang11caijialin0626ming845378603
authored
[feat][backend]: prompt upgrade for mcp&dlp&security_level (#456)
* [feat][prompt] add no render * [feat][prompt] openapi add no render * [feat][prompt] noRender -> skipRender * [feat][prompt]: add custom tool & model config * [feat][prompt]: add thinking config * [feat][prompt]: add thinking config * [feat][prompt]: add batch get new field * [feat][prompt]: add mcp config field * [feat][prompt]: add mcp config crud dao * [feat][prompt]: abstract tool list and tool call * [feat][prompt]: typo * [feat][prompt]: add mcp config convert * [feat][prompt]: add mcp config convert * [feat][prompt]: add replyItemWrapper * [feat][prompt]: add ut * [feat][prompt]: add ut * [feat][prompt]: separate tool result map from reorganization * [feat][prompt]: separate tool result map from reorganization * [feat][prompt]: separate tool result map from reorganization * [feat][prompt]: refactor * ut (vibe-kanban 62dc0838) 看一下feat/prompt\_sync\_1222这个分支和main的diff,帮我补齐所有差异的ut,并确保完整的ut测试通过,其中需要mock的统一使用mockgen来生成,你可参考其他test文件 写完之后,你可以使用go test ./... -v | grep FAIL 来测试 * ut (vibe-kanban 793afb18) @/Users/bytedance/GolandProjects/coze-loop/backend/modules/prompt/domain/service/tool\_results\_collector\_test.go 需要使用mock ,使用mockgen 在@/Users/bytedance/GolandProjects/coze-loop/backend/modules/prompt/domain/service/mocks 中生成mock方法并使用,你可以参考 tool\_config\_test * [feat][prompt]: go lint * ut (vibe-kanban b25bde48) 参考下面的ut报告帮我补充一下对应的ut ❌ Patch coverage is `76.68919%` with `69 lines` in your changes missing coverage. Please review. [Files with missing lines](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)Patch %Lines [backend/modules/prompt/application/openapi.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fopenapi.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9vcGVuYXBpLmdv) 15.78% [29 Missing and 3 partials ⚠️](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev) [...nd/modules/prompt/application/convertor/openapi.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fconvertor%2Fopenapi.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9jb252ZXJ0b3Ivb3BlbmFwaS5nbw==) 77.77% [10 Missing and 10 partials ⚠️](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev) [backend/modules/prompt/domain/service/execute.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fservice%2Fexecute.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vc2VydmljZS9leGVjdXRlLmdv) 89.61% [4 Missing and 4 partials ⚠️](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev) [...kend/modules/prompt/domain/entity/prompt\_detail.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fentity%2Fprompt_detail.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vZW50aXR5L3Byb21wdF9kZXRhaWwuZ28=) 83.33% [3 Missing and 2 partials ⚠️](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev) [...end/modules/prompt/application/convertor/prompt.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fconvertor%2Fprompt.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9jb252ZXJ0b3IvcHJvbXB0Lmdv) 84.61% [2 Missing and 2 partials ⚠️](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev) ❌ Your patch check has failed because the patch coverage (76.68%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the [target](https://docs.codecov.com/docs/commit-status#target) coverage. [![Impacted file tree graph](https://camo.githubusercontent.com/f72f15574daff346298f0d18a8e0eb0647a91ef2042b383e5da8f19e06d8ed10/68747470733a2f2f6170702e636f6465636f762e696f2f67682f636f7a652d6465762f636f7a652d6c6f6f702f70756c6c2f3335352f6772617068732f747265652e7376673f77696474683d363530266865696768743d313530267372633d707226746f6b656e3d52505751574b544f56382675746d5f6d656469756d3d726566657272616c2675746d5f736f757263653d6769746875622675746d5f636f6e74656e743d636f6d6d656e742675746d5f63616d706169676e3d70722b636f6d6d656e74732675746d5f7465726d3d636f7a652d646576)](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&utm\_medium=referral&utm\_source=github&utm\_content=comment&utm\_campaign=pr+comments&utm\_term=coze-dev) ```javascript @@ Coverage Diff @@ ## main #355 +/- ## ======================================== Coverage 69.76% 69.77% ======================================== Files 616 618 +2 Lines 58291 58501 +210 ======================================== + Hits 40666 40818 +152 - Misses 14637 14680 +43 - Partials 2988 3003 +15 ``` [Flag](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)Coverage Δ [unittests](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev) `69.77% <76.68%> (+<0.01%)` ⬆️ Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#carryforward-flags-in-the-pull-request-comment) to find out more. [Files with missing lines](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev)Coverage Δ [backend/modules/prompt/domain/service/service.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fservice%2Fservice.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vc2VydmljZS9zZXJ2aWNlLmdv) `100.00% <100.00%> (ø)` [...ckend/modules/prompt/domain/service/tool\_config.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fservice%2Ftool_config.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vc2VydmljZS90b29sX2NvbmZpZy5nbw==) `100.00% <100.00%> (ø)` [...es/prompt/domain/service/tool\_results\_collector.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fservice%2Ftool_results_collector.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vc2VydmljZS90b29sX3Jlc3VsdHNfY29sbGVjdG9yLmdv) `100.00% <100.00%> (ø)` [...end/modules/prompt/application/convertor/prompt.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fconvertor%2Fprompt.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9jb252ZXJ0b3IvcHJvbXB0Lmdv) `83.46% <84.61%> (+0.01%)` ⬆️ [...kend/modules/prompt/domain/entity/prompt\_detail.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fentity%2Fprompt_detail.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vZW50aXR5L3Byb21wdF9kZXRhaWwuZ28=) `85.31% <83.33%> (-0.94%)` ⬇️ [backend/modules/prompt/domain/service/execute.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fdomain%2Fservice%2Fexecute.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9kb21haW4vc2VydmljZS9leGVjdXRlLmdv) `77.21% <89.61%> (+0.50%)` ⬆️ [...nd/modules/prompt/application/convertor/openapi.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fconvertor%2Fopenapi.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9jb252ZXJ0b3Ivb3BlbmFwaS5nbw==) `89.24% <77.77%> (-3.24%)` ⬇️ [backend/modules/prompt/application/openapi.go](https://app.codecov.io/gh/coze-dev/coze-loop/pull/355?src=pr&el=tree&filepath=backend%2Fmodules%2Fprompt%2Fapplication%2Fopenapi.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=coze-dev#diff-YmFja2VuZC9tb2R1bGVzL3Byb21wdC9hcHBsaWNhdGlvbi9vcGVuYXBpLmdv) `85.92% <15.78%> (-5.39%)` ⬇️ * [feat][prompt]: go lint * [feat][prompt]: tool config add ctx * [feat][prompt]: add response api * [feat][prompt]: support thinking config * [feat][prompt]: support response api * [feat][prompt]: add ut * [feat][prompt]: add signature * [feat][prompt]: update support mcp config * [feat][prompt]: get support mcp config * [feat][prompt]: Extend toolResultKey * [feat][prompt]: add paas metric * [feat][prompt]: add get user id & draft prompt get * [feat][prompt]: add get user id & draft prompt get * [feat][prompt]BatchGetPromptBasic (#416) * feat:prompt_release * feat:prompt_release * feat:prompt_release * feat:prompt_release * Feat/prompt release (#428) * feat:prompt_release * feat:prompt_release * feat:prompt_release * feat:prompt_release * Feat/dlp sync (#419) * feat: support dlp and security level for prompt * feat: add prompt commit and draft dao hook * feat: change permission check for ListParentPrompt * fix: user draft save encrypt message --------- Co-authored-by: wangluming.wlm <wangluming.wlm@bytedance.com> * fix: prompt idl with js conv * Fix prompt openapi draft fetch flow * feat(prompt-openapi): add execute compatibility fields and align behavior * refactor(prompt-openapi): reduce fornax-only execute compatibility fields * feat(prompt): align openapi execute metrics and ptaas event fields * feat: fix the data race of debug * bugfix:Copyright * fix:missing method BatchGetPromptBasic * fix:userClient * fix:test * [feat][prompt]: fix enum * [feat][prompt]: fix enum * [feat][prompt]: fix enum * [feat][prompt]: fix lint and ut * [feat][prompt]: add ut * test: improve prompt patch coverage * [feat][prompt]: add ut * feat(prompt): add unit tests to improve patch coverage to 80%+ - application/manage_test.go: add tests for UpdatePrompt, CommitDraft, GetPrompt, ListCommit error branches, CreatePrompt/ClonePrompt SecurityLevel defaults - application/openapi_test.go: add tests for promptTypeToMetricValue, getRequest* helpers, normalizeExecuteRequest branches - application/convertor/prompt_coverage_test.go: add tests for TokenUsageDO2DTO, BatchDebugToolCallDO2DTO, VariableVal, PromptCommit, McpConfig, ToolChoiceType, Scenario, nil element filtering - application/convertor/openapi_coverage_test.go: add tests for ThinkingConfig, ThinkingOption, ReasoningEffort, ParamConfigValue, ToolChoiceSpecification, ContentPartDTO2DO branches - domain/entity/prompt_detail_test.go: add tests for formatMultiPart, formatMessages, convertVariablesToMap, DeepEqual - domain/service/execute_test.go: add tests for Signature field, DisableTracing, CollectToolResults error, streaming errors - infra/metrics/paas_coverage_test.go: add tests for EmitPaasMetric nil guards, WithPaasStatus regular error, all With* functions no-context safety - infra/repo/manage_test.go: add test for BatchGetPromptBasic partial result * fix: resolve thrift IDL conflict and regenerate kitex code - Keep domain_openapi/prompt.thrift include, add extra.thrift include from main - Add extra.Extra field to BatchGetPromptByPromptKeyRequest and ExecuteRequest - Keep ListPromptBasicRequest field 6 map<string,string> extra without extra.Extra to avoid name conflict - Regenerate kitex_gen code --------- Co-authored-by: caijialin.626 <caijialin.626@bytedance.com> Co-authored-by: ming845378603 <52918361+ming845378603@users.noreply.github.com> Co-authored-by: wangluming.wlm <wangluming.wlm@bytedance.com>
1 parent eb284ff commit ee7c5d5

113 files changed

Lines changed: 41279 additions & 19638 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ backend/script/errorx/.env
6161
.specify/
6262
specs/
6363
.puml
64+
.trae
6465
openspec/

backend/api/handler/coze/loop/apis/prompt_manage_service.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/api/handler/coze/loop/apis/wire_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/api/router/coze/loop/apis/coze.loop.apis.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/api/router/coze/loop/apis/middleware.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAx
473473
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
474474
github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM=
475475
github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA=
476+
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
476477
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
477478
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
478479
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=

backend/infra/platestwrite/latest_write_tracker.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ const (
131131
ResourceTypePromptCommitLabelMapping ResourceType = "prompt_commit_label_mapping"
132132
ResourceTypeCozeloopOptimizeTask ResourceType = "cozeloop_optimize_task" // 外场智能优化
133133
ResourceTypePromptRelation ResourceType = "prompt_relation"
134+
ResourceTypePromptRelease ResourceType = "prompt_release"
135+
ResourceTypeReleaseTask ResourceType = "release_task"
136+
ResourceTypeReleaseSubtask ResourceType = "release_subtask"
137+
ResourceTypeReleaseTaskResource ResourceType = "release_task_resource"
134138

135139
ResourceTypeExperiment ResourceType = "experiment"
136140
ResourceTypeEvalSet ResourceType = "eval_set"

backend/kitex_gen/coze/loop/apis/promptmanageservice/client.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/kitex_gen/coze/loop/apis/promptmanageservice/promptmanageservice.go

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)