From 75a82de5bf54810836b18965922fe68871577229 Mon Sep 17 00:00:00 2001 From: Cole Lashley Date: Thu, 21 Mar 2024 18:00:55 -0700 Subject: [PATCH] Adding engineered query to chat command (#488) * added engineered query to chat command * let ai know responses are rendered in markdown --- wavesrv/pkg/cmdrunner/cmdrunner.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wavesrv/pkg/cmdrunner/cmdrunner.go b/wavesrv/pkg/cmdrunner/cmdrunner.go index a2c1152b2..5709c9061 100644 --- a/wavesrv/pkg/cmdrunner/cmdrunner.go +++ b/wavesrv/pkg/cmdrunner/cmdrunner.go @@ -2625,7 +2625,7 @@ func getCmdInfoEngineeredPrompt(userQuery string, curLineStr string, shellType s // Enclose the command in triple backticks to format it as a code block. promptCurrentCommand = " The user is currently working with the command: ```\n" + curLineStr + "\n```\n\n" } - promptFormattingInstruction := "Please ensure any command line suggestions or code snippets that are meant to be run by the user are enclosed in triple backquotes for easy copy and paste into the terminal." + promptFormattingInstruction := "Please ensure any command line suggestions or code snippets or scripts that are meant to be run by the user are enclosed in triple backquotes for easy copy and paste into the terminal. Also note that any response you give will be rendered in markdown." promptQuestion := " The user's question is:\n\n" + userQuery + "" return promptBase + promptCurrentCommand + promptFormattingInstruction + promptQuestion @@ -2875,7 +2875,9 @@ func OpenAICommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus update := scbus.MakeUpdatePacket() return update, nil } - prompt := []packet.OpenAIPromptMessageType{{Role: sstore.OpenAIRoleUser, Content: promptStr}} + osType := GetOsTypeFromRuntime() + engineeredQuery := getCmdInfoEngineeredPrompt(promptStr, "", ids.Remote.ShellType, osType) + prompt := []packet.OpenAIPromptMessageType{{Role: sstore.OpenAIRoleUser, Content: engineeredQuery}} if resolveBool(pk.Kwargs["cmdinfoclear"], false) { update := sstore.UpdateWithClearOpenAICmdInfo(cmd.ScreenId) if err != nil {