From 9535b1de6591496e9dc72f4ba2f6ed616c8680d3 Mon Sep 17 00:00:00 2001 From: Nick Hale <4175918+njhale@users.noreply.github.com> Date: Sun, 31 Mar 2024 04:06:34 -0400 Subject: [PATCH] fix: trim leading whitespace from arg descriptions Trim the optional leading whitespace from descriptions when parsing arguments to prevent them from showing up in the chat completion function definitions produced by gptscript. Signed-off-by: Nick Hale <4175918+njhale@users.noreply.github.com> --- pkg/loader/loader_test.go | 2 +- pkg/parser/parser.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/loader/loader_test.go b/pkg/loader/loader_test.go index fd0eda93..c8e44647 100644 --- a/pkg/loader/loader_test.go +++ b/pkg/loader/loader_test.go @@ -77,7 +77,7 @@ func TestHelloWorld(t *testing.T) { "arguments": { "properties": { "input": { - "description": " Any string", + "description": "Any string", "type": "string" } }, diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index 1c8bc68c..de890fc1 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -60,7 +60,7 @@ func addArg(line string, tool *types.Tool) error { tool.Parameters.Arguments.Properties[key] = &openapi3.SchemaRef{ Value: &openapi3.Schema{ - Description: value, + Description: strings.TrimSpace(value), Type: "string", }, }