Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export systemPrompt in gql #977

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 73 additions & 2 deletions apiserver/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions apiserver/graph/generated/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apiserver/graph/schema/application.gql
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ mutation updateApplicationConfig($input: UpdateApplicationConfigInput!){
numDocuments
docNullReturn
userPrompt
systemPrompt
showRespInfo
showRetrievalInfo
showNextGuide
Expand Down Expand Up @@ -130,6 +131,7 @@ query getApplication($name: String!, $namespace: String!){
numDocuments
docNullReturn
userPrompt
systemPrompt
showRespInfo
showRetrievalInfo
showNextGuide
Expand Down
9 changes: 8 additions & 1 deletion apiserver/graph/schema/application.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ type Application {
userPrompt 用户级别的 Prompt
"""
userPrompt: String

"""
systemPrompt 系统级别的 Prompt
"""
systemPrompt: String
"""
showRespInfo 查看关联信息配置,即是否在chat界面显示关联信息
"""
Expand Down Expand Up @@ -390,6 +393,10 @@ input UpdateApplicationConfigInput {
"""
userPrompt: String
"""
systemPrompt 系统级别的 Prompt
"""
systemPrompt: String
"""
showRespInfo 查看关联信息配置,即是否在chat界面显示关联信息
"""
showRespInfo: Boolean
Expand Down
8 changes: 6 additions & 2 deletions apiserver/pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func cr2app(prompt *apiprompt.Prompt, chainConfig *apichain.CommonChainConfig, r
}
if prompt != nil {
gApp.UserPrompt = pointer.String(prompt.Spec.UserMessage)
gApp.SystemPrompt = pointer.String(prompt.Spec.SystemMessage)
}
if chainConfig != nil {
gApp.Model = pointer.String(chainConfig.Model)
Expand Down Expand Up @@ -444,9 +445,12 @@ func UpdateApplicationConfig(ctx context.Context, c client.Client, input generat
} else {
userMessage = *input.UserPrompt
}
prompt.Spec.CommonPromptConfig = apiprompt.CommonPromptConfig{
UserMessage: userMessage,
if utils.HasValue(input.SystemPrompt) {
prompt.Spec.CommonPromptConfig.SystemMessage = *input.SystemPrompt
} else {
prompt.Spec.CommonPromptConfig.SystemMessage = ""
}
prompt.Spec.CommonPromptConfig.UserMessage = userMessage
return nil
}); err != nil {
return nil, err
Expand Down
Loading