Skip to content

Commit

Permalink
feat: when no userPrompt setting, we use default one
Browse files Browse the repository at this point in the history
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
  • Loading branch information
Abirdcfly committed Dec 22, 2023
1 parent 09de386 commit 50ec289
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
21 changes: 21 additions & 0 deletions api/app-node/prompt/v1alpha1/prompttemplate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2023 KubeAGI.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

const (
DefaultUserPrompt = `{{.question}}`
)
1 change: 1 addition & 0 deletions api/app-node/prompt/v1alpha1/prompttemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type CommonPromptConfig struct {
// system prompts, support template
SystemMessage string `json:"systemMessage,omitempty"`
// user prompts,support template
// +kubebuilder:default="{{.question}}"
UserMessage string `json:"userMessage,omitempty"`
}

Expand Down
8 changes: 7 additions & 1 deletion apiserver/pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,14 @@ func UpdateApplicationConfig(ctx context.Context, c dynamic.Interface, input gen
},
}
if err = createOrUpdateResource(ctx, c, common.SchemaOf(&common.ArcadiaAPIGroup, "Prompt"), input.Namespace, input.Name, func() {
var userMessage string
if input.UserPrompt == nil || len(strings.TrimSpace(*input.UserPrompt)) == 0 {
userMessage = apiprompt.DefaultUserPrompt
} else {
userMessage = *input.UserPrompt
}
prompt.Spec.CommonPromptConfig = apiprompt.CommonPromptConfig{
UserMessage: pointer.StringDeref(input.UserPrompt, "just say something."),
UserMessage: userMessage,
}
}, prompt); err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ spec:
description: system prompts, support template
type: string
userMessage:
default: '{{.question}}'
description: user prompts,support template
type: string
type: object
Expand Down
2 changes: 1 addition & 1 deletion deploy/charts/arcadia/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: arcadia
description: A Helm chart(KubeBB Component) for KubeAGI Arcadia
type: application
version: 0.1.50
version: 0.1.51
appVersion: "0.0.1"

keywords:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ spec:
description: system prompts, support template
type: string
userMessage:
default: '{{.question}}'
description: user prompts,support template
type: string
type: object
Expand Down

0 comments on commit 50ec289

Please sign in to comment.