Skip to content

Commit

Permalink
Merge pull request #937 from Abirdcfly/fixbool
Browse files Browse the repository at this point in the history
fix: app enableUploadFile cant set to false
  • Loading branch information
bjwswang authored Mar 27, 2024
2 parents 696905e + 557aa33 commit 797f359
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/base/v1alpha1/application_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type WebConfig struct {
ShowRetrievalInfo bool `json:"showRetrievalInfo,omitempty"`
ShowNextGuide bool `json:"showNextGuide,omitempty"`
// +kubebuilder:default:=true
EnableUploadFile bool `json:"enableUploadFile,omitempty"`
EnableUploadFile *bool `json:"enableUploadFile,omitempty"`
}

type Node struct {
Expand Down
7 changes: 6 additions & 1 deletion api/base/v1alpha1/zz_generated.deepcopy.go

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

6 changes: 4 additions & 2 deletions apiserver/pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func cr2app(prompt *apiprompt.Prompt, chainConfig *apichain.CommonChainConfig, r
ShowRetrievalInfo: pointer.Bool(app.Spec.ShowRetrievalInfo),
DocNullReturn: pointer.String(app.Spec.DocNullReturn),
ChatTimeout: pointer.Float64(app.Spec.ChatTimeoutSecond),
EnableUploadFile: pointer.Bool(app.Spec.EnableUploadFile),
EnableUploadFile: app.Spec.EnableUploadFile,
}
if prompt != nil {
gApp.UserPrompt = pointer.String(prompt.Spec.UserMessage)
Expand Down Expand Up @@ -741,7 +741,9 @@ func mutateApp(app *v1alpha1.Application, input generated.UpdateApplicationConfi
app.Spec.ShowNextGuide = pointer.BoolDeref(input.ShowNextGuide, app.Spec.ShowNextGuide)
app.Spec.DocNullReturn = pointer.StringDeref(input.DocNullReturn, app.Spec.DocNullReturn)
app.Spec.ChatTimeoutSecond = pointer.Float64Deref(input.ChatTimeout, v1alpha1.DefaultChatTimeoutSeconds)
app.Spec.EnableUploadFile = pointer.BoolDeref(input.EnableUploadFile, app.Spec.EnableUploadFile)
if input.EnableUploadFile != nil {
app.Spec.EnableUploadFile = input.EnableUploadFile
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion apiserver/service/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (cs *ChatService) ChatFile() gin.HandlerFunc {
c.JSON(http.StatusBadRequest, chat.ErrorResp{Err: err.Error()})
return
}
if !app.Spec.EnableUploadFile {
if pointer.BoolDeref(app.Spec.EnableUploadFile, false) {
c.JSON(http.StatusForbidden, chat.ErrorResp{Err: "file upload is not enabled"})
return
}
Expand Down

0 comments on commit 797f359

Please sign in to comment.