From c85766139371bb4324826fa8716b3478eea898c1 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 8 Feb 2025 18:28:47 +0300 Subject: Feat: add tool reminder bind --- llm.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'llm.go') diff --git a/llm.go b/llm.go index be7f418..a5f70bf 100644 --- a/llm.go +++ b/llm.go @@ -51,8 +51,11 @@ func (lcp LlamaCPPeer) FormMsg(msg, role string) (io.Reader, error) { messages[i] = m.ToPrompt() } prompt := strings.Join(messages, "\n") + if cfg.ToolUse && msg != "" { + prompt += "\n" + cfg.ToolRole + ":\n" + toolSysMsg + } botMsgStart := "\n" + cfg.AssistantRole + ":\n" - payload := models.NewLCPReq(prompt+botMsgStart, role, defaultLCPProps) + payload := models.NewLCPReq(prompt+botMsgStart, cfg, defaultLCPProps) data, err := json.Marshal(payload) if err != nil { logger.Error("failed to form a msg", "error", err) @@ -106,6 +109,11 @@ func (op OpenAIer) FormMsg(msg, role string) (io.Reader, error) { ragMsg := models.RoleMsg{Role: cfg.ToolRole, Content: ragResp} chatBody.Messages = append(chatBody.Messages, ragMsg) } + if cfg.ToolUse { + toolMsg := models.RoleMsg{Role: cfg.ToolRole, + Content: toolSysMsg} + chatBody.Messages = append(chatBody.Messages, toolMsg) + } } data, err := json.Marshal(chatBody) if err != nil { -- cgit v1.2.3