From 01fe3cbe51e5978ba0e593e1f895efbc064bc78d Mon Sep 17 00:00:00 2001 From: 0xff-dev Date: Thu, 11 Jan 2024 15:51:40 +0800 Subject: [PATCH] fix: optimize prompt output --- pkg/evaluator/evaluator.go | 2 +- pkg/evaluator/prompt.go | 43 ++++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/pkg/evaluator/evaluator.go b/pkg/evaluator/evaluator.go index 5e0cc569..94b297aa 100644 --- a/pkg/evaluator/evaluator.go +++ b/pkg/evaluator/evaluator.go @@ -169,7 +169,7 @@ func (evaluator *Evaluator) EvaluateWithData(ctx context.Context, data *Data, op switch evaluator.llm.Spec.Type { case llms.ZhiPuAI: params := zhipuai.DefaultModelParams() - params.Model = llms.ZhiPuAILite + params.Model = llms.ZhiPuAIPro params.Prompt = []zhipuai.Prompt{ {Role: zhipuai.User, Content: output.String()}, } diff --git a/pkg/evaluator/prompt.go b/pkg/evaluator/prompt.go index 70a9577b..03ae8e7d 100644 --- a/pkg/evaluator/prompt.go +++ b/pkg/evaluator/prompt.go @@ -21,23 +21,40 @@ const DefaultOutputFormat = `json ` const ( - DefaultPromptTemplate = ` -I have a component in my repository that I'm interested in assessing the {{ .Dimension }} implications of this component.Below are some context from component {{ .Dimension }} check: -1. A component is a software which can be deployed into kubernetes with its helm charts. -2. Use customized tekton pipelines to run the tests. + DefaultPromptTemplate = `I have a component in my repository and I want to evaluate the impact of the component's {{.Dimension}} dimension. +here is the context of the component's {{.Dimension}} dimension +1. a component is a piece of software that can be deployed into kubernetes via its helm chart. +2. tests are run using a customized tokton. -Below are the tested Tasks: - {{ .Tasks }} +You need to rate the component (1-10, out of 10), give recommendations and point out problems. +The scores are integer types, and the suggestions and problems are string arrays. +At least one of the suggestions and problems must be given. Answers are output in json format: -**Component {{ .Dimension }} Assessment**: - - Could you please review the above tested tasks and inform me any potential {{ .Dimension }} risks if I adopt this component in production? +{"chinese": {"score":1, "suggestions":[""], "problems":[""]}, "english":{"score":1, "suggestions":[""], "problems":[""]}} -**Final Rating based on above tested tasks**: - - On a scale of 1 to 10, with 10 being the most reliable, how would you rate the {{ .Dimension }} of this component? +Note that the data corresponding to the chinese field in the json should be output in Chinese, and the data corresponding to the english field should be output in English.` -Your answer should follow the below format: -{{.OutputFormat}} -` + /* + DefaultPromptTemplate = ` + I have a component in my repository that I'm interested in assessing the {{ .Dimension }} implications of this component.Below are some context from component {{ .Dimension }} check: + 1. A component is a software which can be deployed into kubernetes with its helm charts. + 2. Use customized tekton pipelines to run the tests. + + Below are the tested Tasks: + + {{ .Tasks }} + + + **Component {{ .Dimension }} Assessment**: + - Could you please review the above tested tasks and inform me any potential {{ .Dimension }} risks if I adopt this component in production? + + **Final Rating based on above tested tasks**: + - On a scale of 1 to 10, with 10 being the most reliable, how would you rate the {{ .Dimension }} of this component? + + Your answer should follow the below format: + {{.OutputFormat}} + ` + */ )