Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
[44;97;1m 🤖 Plandex [0;0;22m 📝 Refactor planFinished function to return a JSON object and update prompt message
Dane Schneidera320c4aac9f2
diff --git a/app/server/model/finished.go b/app/server/model/finished.goindex d93251da..f3d635fd 100644--- a/app/server/model/finished.go+++ b/app/server/model/finished.go@@ -2,9 +2,9 @@ package modelimport ("context"+ "encoding/json""fmt""plandex-server/model/prompts"- "time""github.com/sashabaranov/go-openai")@@ -13,7 +13,12 @@ type PlanFinishedParams struct {Conversation []openai.ChatCompletionMessage}-func PlanFinished(params PlanFinishedParams) (bool, error) {+type PlanFinishedRes struct {+ Reasoning string `json:"reasoning"`+ Finished bool `json:"finished"`+}++func PlanFinished(params PlanFinishedParams) (PlanFinishedRes, error) {messages := []openai.ChatCompletionMessage{{Role: openai.ChatMessageRoleSystem,@@ -33,11 +38,11 @@ func PlanFinished(params PlanFinishedParams) (bool, error) {if err != nil {fmt.Println("PlanFinished err:", err)- return false, err+ return PlanFinishedRes{}, err}if len(resp.Choices) == 0 {- return false, fmt.Errorf("no response from GPT")+ return PlanFinishedRes{}, fmt.Errorf("no response from GPT")}content := resp.Choices[0].Message.Content@@ -46,5 +51,8 @@ func PlanFinished(params PlanFinishedParams) (bool, error) {// You might want to adjust this according to your needs.isFinished := content == "finished"- return isFinished, nil+ return PlanFinishedRes{+ Reasoning: content,+ Finished: isFinished,+ }, nil}diff --git a/app/server/model/prompts/finished.go b/app/server/model/prompts/finished.goindex 3cf74a88..efd34ea1 100644--- a/app/server/model/prompts/finished.go+++ b/app/server/model/prompts/finished.go@@ -1,6 +1,6 @@package prompts-const SysFinished = "You are an AI assistant that determines whether a software development plan has been finished or not. Analyze the conversation and decide whether all tasks have been completed. If there are still tasks to be done, specify them."+const SysFinished = "You are an AI assistant that determines whether a software development plan has been finished or not. Analyze the conversation and decide whether all tasks have been completed."func GetFinishedPrompt(conversation string) string {return SysFinished + "\n\nConversation:\n" + conversation