From 210f53a2d3c3ff4c8b0c8d95d5559243b31816f3 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Fri, 3 May 2024 16:02:09 -0400 Subject: [PATCH] fix: print instructions last when fmt-ing If instructions are not printed last, then anything printed after the instruction is parsed as instructions. For example: ``` Hello, how are you? Chat: true ``` would not be parsed as a chat tool. This change will ensure that things that are fmt-ed will also be parsed the same way. Signed-off-by: Donnie Adams --- pkg/types/tool.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/types/tool.go b/pkg/types/tool.go index b6eb8528..7ef0d0fc 100644 --- a/pkg/types/tool.go +++ b/pkg/types/tool.go @@ -267,10 +267,6 @@ func (t Tool) String() string { if t.Parameters.InternalPrompt != nil { _, _ = fmt.Fprintf(buf, "Internal Prompt: %v\n", *t.Parameters.InternalPrompt) } - if t.Instructions != "" && t.BuiltinFunc == nil { - _, _ = fmt.Fprintln(buf) - _, _ = fmt.Fprintln(buf, t.Instructions) - } if len(t.Parameters.Credentials) > 0 { _, _ = fmt.Fprintf(buf, "Credentials: %s\n", strings.Join(t.Parameters.Credentials, ", ")) } @@ -278,6 +274,12 @@ func (t Tool) String() string { _, _ = fmt.Fprintf(buf, "Chat: true\n") } + // Instructions should be printed last + if t.Instructions != "" && t.BuiltinFunc == nil { + _, _ = fmt.Fprintln(buf) + _, _ = fmt.Fprintln(buf, t.Instructions) + } + return buf.String() }