From 7162530322d5835b806919963670c8e962f77522 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 22 May 2024 13:09:34 -0700 Subject: [PATCH] feat: add sys.chat.history This allows multi agent flows to recall previous conversations --- pkg/builtin/builtin.go | 44 +++++++++- pkg/engine/cmd.go | 16 +++- pkg/engine/engine.go | 23 ++++- pkg/runner/runner.go | 4 + pkg/tests/runner_test.go | 84 ++++++------------- pkg/tests/testdata/TestCase/call1.golden | 14 +--- pkg/tests/testdata/TestCase2/call1.golden | 14 +--- pkg/tests/testdata/TestChat/call1.golden | 14 +--- pkg/tests/testdata/TestChat/call2.golden | 14 +--- .../testdata/TestChatRunNoError/call1.golden | 14 +--- pkg/tests/testdata/TestContext/call1.golden | 13 +-- .../testdata/TestContextArg/call1.golden | 13 +-- .../testdata/TestContextSubChat/call1.golden | 14 +--- .../testdata/TestContextSubChat/call10.golden | 14 +--- .../testdata/TestContextSubChat/call2.golden | 15 ++-- .../testdata/TestContextSubChat/call3.golden | 15 ++-- .../testdata/TestContextSubChat/call4.golden | 14 +--- .../testdata/TestContextSubChat/call5.golden | 14 +--- .../testdata/TestContextSubChat/call6.golden | 14 +--- .../testdata/TestContextSubChat/call7.golden | 15 ++-- .../testdata/TestContextSubChat/call8.golden | 15 ++-- .../testdata/TestContextSubChat/call9.golden | 14 +--- .../testdata/TestContextSubChat/step1.golden | 29 ++----- .../testdata/TestContextSubChat/step2.golden | 14 +--- .../testdata/TestContextSubChat/step3.golden | 43 +++------- .../testdata/TestContextSubChat/step4.golden | 14 +--- pkg/tests/testdata/TestCwd/call1.golden | 14 +--- pkg/tests/testdata/TestCwd/call2.golden | 14 +--- pkg/tests/testdata/TestCwd/call3.golden | 14 +--- .../testdata/TestDualSubChat/call1.golden | 14 +--- .../testdata/TestDualSubChat/call2.golden | 15 ++-- .../testdata/TestDualSubChat/call3.golden | 15 ++-- .../testdata/TestDualSubChat/call4.golden | 15 ++-- .../testdata/TestDualSubChat/call5.golden | 15 ++-- .../testdata/TestDualSubChat/call6.golden | 15 ++-- .../testdata/TestDualSubChat/call7.golden | 14 +--- .../testdata/TestDualSubChat/step1.golden | 44 ++++------ .../testdata/TestDualSubChat/step2.golden | 29 ++----- .../testdata/TestDualSubChat/step3.golden | 29 ++----- pkg/tests/testdata/TestExport/call1.golden | 14 +--- pkg/tests/testdata/TestExport/call2.golden | 13 +-- pkg/tests/testdata/TestExport/call3.golden | 14 +--- .../testdata/TestExportContext/call1.golden | 14 +--- pkg/tests/testdata/TestSubChat/call1.golden | 14 +--- pkg/tests/testdata/TestSubChat/call2.golden | 14 +--- pkg/tests/testdata/TestSubChat/call3.golden | 14 +--- pkg/tests/testdata/TestToolAs/call1.golden | 14 +--- pkg/types/completion.go | 39 ++++++--- 48 files changed, 333 insertions(+), 575 deletions(-) diff --git a/pkg/builtin/builtin.go b/pkg/builtin/builtin.go index 5eb7be3c..7ee3c00c 100644 --- a/pkg/builtin/builtin.go +++ b/pkg/builtin/builtin.go @@ -20,15 +20,17 @@ import ( "github.com/AlecAivazis/survey/v2" "github.com/BurntSushi/locker" "github.com/google/shlex" + "github.com/gptscript-ai/gptscript/pkg/engine" "github.com/gptscript-ai/gptscript/pkg/types" "github.com/jaytaylor/html2text" ) var SafeTools = map[string]struct{}{ - "sys.echo": {}, - "sys.time.now": {}, - "sys.prompt": {}, - "sys.chat.finish": {}, + "sys.echo": {}, + "sys.time.now": {}, + "sys.prompt": {}, + "sys.chat.finish": {}, + "sys.chat.history": {}, } var tools = map[string]types.Tool{ @@ -182,6 +184,13 @@ var tools = map[string]types.Tool{ }, BuiltinFunc: SysPrompt, }, + "sys.chat.history": { + Parameters: types.Parameters{ + Description: "Retrieves the previous chat dialog", + Arguments: types.ObjectSchema(), + }, + BuiltinFunc: SysChatHistory, + }, } func SysProgram() *types.Program { @@ -567,6 +576,33 @@ func (e *ErrChatFinish) Error() string { return fmt.Sprintf("CHAT FINISH: %s", e.Message) } +func SysChatHistory(ctx context.Context, _ []string, _ string) (string, error) { + engineContext, _ := engine.FromContext(ctx) + + data, err := json.Marshal(engine.ChatHistory{ + History: writeHistory(engineContext), + }) + + return string(data), err +} + +func writeHistory(ctx *engine.Context) (result []engine.ChatHistoryCall) { + if ctx == nil { + return nil + } + if ctx.Parent != nil { + result = append(result, writeHistory(ctx.Parent)...) + } + if ctx.LastReturn != nil && ctx.LastReturn.State != nil { + result = append(result, engine.ChatHistoryCall{ + ID: ctx.ID, + Tool: ctx.Tool, + Completion: ctx.LastReturn.State.Completion, + }) + } + return +} + func SysChatFinish(ctx context.Context, env []string, input string) (string, error) { var params struct { Message string `json:"return,omitempty"` diff --git a/pkg/engine/cmd.go b/pkg/engine/cmd.go index e1bcd620..6d1ae3bc 100644 --- a/pkg/engine/cmd.go +++ b/pkg/engine/cmd.go @@ -21,7 +21,7 @@ import ( "github.com/gptscript-ai/gptscript/pkg/version" ) -func (e *Engine) runCommand(ctx context.Context, tool types.Tool, input string, toolCategory ToolCategory) (cmdOut string, cmdErr error) { +func (e *Engine) runCommand(ctx Context, tool types.Tool, input string, toolCategory ToolCategory) (cmdOut string, cmdErr error) { id := counter.Next() defer func() { @@ -42,10 +42,18 @@ func (e *Engine) runCommand(ctx context.Context, tool types.Tool, input string, "input": input, }, } - return tool.BuiltinFunc(ctx, e.Env, input) + return tool.BuiltinFunc(ctx.WrappedContext(), e.Env, input) } - cmd, stop, err := e.newCommand(ctx, nil, tool, input) + var instructions []string + for _, inputContext := range ctx.InputContext { + instructions = append(instructions, inputContext.Content) + } + var extraEnv = []string{ + strings.TrimSpace(fmt.Sprintf("GPTSCRIPT_CONTEXT=%s", strings.Join(instructions, "\n"))), + } + + cmd, stop, err := e.newCommand(ctx.Ctx, extraEnv, tool, input) if err != nil { return "", err } @@ -66,7 +74,7 @@ func (e *Engine) runCommand(ctx context.Context, tool types.Tool, input string, cmd.Stdout = io.MultiWriter(all, output) if toolCategory == CredentialToolCategory { - pause := context2.GetPauseFuncFromCtx(ctx) + pause := context2.GetPauseFuncFromCtx(ctx.Ctx) unpause := pause() defer unpause() } diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index da662a10..18d8a717 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -69,9 +69,20 @@ type CallContext struct { type Context struct { commonContext - Ctx context.Context - Parent *Context - Program *types.Program + Ctx context.Context + Parent *Context + LastReturn *Return + Program *types.Program +} + +type ChatHistory struct { + History []ChatHistoryCall `json:"history,omitempty"` +} + +type ChatHistoryCall struct { + ID string `json:"id,omitempty"` + Tool types.Tool `json:"tool,omitempty"` + Completion types.CompletionRequest `json:"completion,omitempty"` } type ToolCategory string @@ -194,7 +205,7 @@ func (e *Engine) Start(ctx Context, input string) (ret *Return, _ error) { } else if tool.IsEcho() { return e.runEcho(tool) } - s, err := e.runCommand(ctx.WrappedContext(), tool, input, ctx.ToolCategory) + s, err := e.runCommand(ctx, tool, input, ctx.ToolCategory) if err != nil { return nil, err } @@ -233,6 +244,10 @@ func (e *Engine) Start(ctx Context, input string) (ret *Return, _ error) { input = "" } + if tool.Chat && input == "{}" { + input = "" + } + if input != "" { completion.Messages = append(completion.Messages, types.CompletionMessage{ Role: types.CompletionMessageRoleTypeUser, diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 42966493..8a06525c 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -711,6 +711,10 @@ func (r *Runner) subCalls(callCtx engine.Context, monitor Monitor, env []string, resultLock sync.Mutex ) + if state.Continuation != nil { + callCtx.LastReturn = state.Continuation + } + if state.InputContextContinuation != nil { return state, nil, nil } diff --git a/pkg/tests/runner_test.go b/pkg/tests/runner_test.go index 9c690705..7856deff 100644 --- a/pkg/tests/runner_test.go +++ b/pkg/tests/runner_test.go @@ -227,9 +227,8 @@ func TestSubChat(t *testing.T) { "state": { "input": "Hello", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestSubChat/test.gpt:chatbot", @@ -238,7 +237,7 @@ func TestSubChat(t *testing.T) { } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -272,12 +271,7 @@ func TestSubChat(t *testing.T) { ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }, "pending": { "call_1": { @@ -303,10 +297,9 @@ func TestSubChat(t *testing.T) { "continuation": { "state": { "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -325,12 +318,7 @@ func TestSubChat(t *testing.T) { ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant 1" @@ -355,9 +343,8 @@ func TestSubChat(t *testing.T) { "state": { "input": "Hello", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestSubChat/test.gpt:chatbot", @@ -366,7 +353,7 @@ func TestSubChat(t *testing.T) { } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -400,12 +387,7 @@ func TestSubChat(t *testing.T) { ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }, "pending": { "call_1": { @@ -431,10 +413,9 @@ func TestSubChat(t *testing.T) { "continuation": { "state": { "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -471,12 +452,7 @@ func TestSubChat(t *testing.T) { ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant 2" @@ -513,10 +489,9 @@ func TestChat(t *testing.T) { "state": { "input": "Hello", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -544,12 +519,7 @@ func TestChat(t *testing.T) { ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant 1" @@ -570,10 +540,9 @@ func TestChat(t *testing.T) { "state": { "input": "Hello", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -619,12 +588,7 @@ func TestChat(t *testing.T) { ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant 2" diff --git a/pkg/tests/testdata/TestCase/call1.golden b/pkg/tests/testdata/TestCase/call1.golden index 48a5c7cc..1e6d76a5 100644 --- a/pkg/tests/testdata/TestCase/call1.golden +++ b/pkg/tests/testdata/TestCase/call1.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestCase/test.gpt:Bob", @@ -19,7 +18,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -29,10 +28,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestCase2/call1.golden b/pkg/tests/testdata/TestCase2/call1.golden index 3cd9716f..581e03f5 100644 --- a/pkg/tests/testdata/TestCase2/call1.golden +++ b/pkg/tests/testdata/TestCase2/call1.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestCase2/test.gpt:bob", @@ -19,7 +18,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -29,10 +28,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestChat/call1.golden b/pkg/tests/testdata/TestChat/call1.golden index 7e6c72d6..0fef0adb 100644 --- a/pkg/tests/testdata/TestChat/call1.golden +++ b/pkg/tests/testdata/TestChat/call1.golden @@ -1,8 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -21,10 +20,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestChat/call2.golden b/pkg/tests/testdata/TestChat/call2.golden index e81d33ca..ff513bb2 100644 --- a/pkg/tests/testdata/TestChat/call2.golden +++ b/pkg/tests/testdata/TestChat/call2.golden @@ -1,8 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -39,10 +38,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestChatRunNoError/call1.golden b/pkg/tests/testdata/TestChatRunNoError/call1.golden index 17221df1..5fdf4ff8 100644 --- a/pkg/tests/testdata/TestChatRunNoError/call1.golden +++ b/pkg/tests/testdata/TestChatRunNoError/call1.golden @@ -1,8 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -12,10 +11,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContext/call1.golden b/pkg/tests/testdata/TestContext/call1.golden index 71aca7cc..ccb2b718 100644 --- a/pkg/tests/testdata/TestContext/call1.golden +++ b/pkg/tests/testdata/TestContext/call1.golden @@ -1,8 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "messages": [ { "role": "system", "content": [ @@ -12,10 +10,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextArg/call1.golden b/pkg/tests/testdata/TestContextArg/call1.golden index 3d6ac3a4..016e9613 100644 --- a/pkg/tests/testdata/TestContextArg/call1.golden +++ b/pkg/tests/testdata/TestContextArg/call1.golden @@ -1,8 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "messages": [ { "role": "system", "content": [ @@ -21,10 +19,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/call1.golden b/pkg/tests/testdata/TestContextSubChat/call1.golden index 86fedd68..f976d1c8 100644 --- a/pkg/tests/testdata/TestContextSubChat/call1.golden +++ b/pkg/tests/testdata/TestContextSubChat/call1.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestContextSubChat/test.gpt:chatbot", @@ -10,7 +9,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -20,10 +19,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/call10.golden b/pkg/tests/testdata/TestContextSubChat/call10.golden index 5b6d8b04..b4433d52 100644 --- a/pkg/tests/testdata/TestContextSubChat/call10.golden +++ b/pkg/tests/testdata/TestContextSubChat/call10.golden @@ -1,8 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -39,10 +38,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/call2.golden b/pkg/tests/testdata/TestContextSubChat/call2.golden index f7398a8f..c3843cb9 100644 --- a/pkg/tests/testdata/TestContextSubChat/call2.golden +++ b/pkg/tests/testdata/TestContextSubChat/call2.golden @@ -1,7 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -19,7 +19,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -38,10 +38,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/call3.golden b/pkg/tests/testdata/TestContextSubChat/call3.golden index b4389d30..da02aace 100644 --- a/pkg/tests/testdata/TestContextSubChat/call3.golden +++ b/pkg/tests/testdata/TestContextSubChat/call3.golden @@ -1,7 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -19,7 +19,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -56,10 +56,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/call4.golden b/pkg/tests/testdata/TestContextSubChat/call4.golden index 5a41b929..4fb1d2bb 100644 --- a/pkg/tests/testdata/TestContextSubChat/call4.golden +++ b/pkg/tests/testdata/TestContextSubChat/call4.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestContextSubChat/test.gpt:chatbot", @@ -10,7 +9,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -53,10 +52,5 @@ }, "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/call5.golden b/pkg/tests/testdata/TestContextSubChat/call5.golden index b2fbefa9..25249ec2 100644 --- a/pkg/tests/testdata/TestContextSubChat/call5.golden +++ b/pkg/tests/testdata/TestContextSubChat/call5.golden @@ -1,8 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -21,10 +20,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/call6.golden b/pkg/tests/testdata/TestContextSubChat/call6.golden index 86fedd68..f976d1c8 100644 --- a/pkg/tests/testdata/TestContextSubChat/call6.golden +++ b/pkg/tests/testdata/TestContextSubChat/call6.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestContextSubChat/test.gpt:chatbot", @@ -10,7 +9,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -20,10 +19,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/call7.golden b/pkg/tests/testdata/TestContextSubChat/call7.golden index b0696e50..7c1c9a19 100644 --- a/pkg/tests/testdata/TestContextSubChat/call7.golden +++ b/pkg/tests/testdata/TestContextSubChat/call7.golden @@ -1,7 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -19,7 +19,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -38,10 +38,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/call8.golden b/pkg/tests/testdata/TestContextSubChat/call8.golden index 74084399..e1350cdc 100644 --- a/pkg/tests/testdata/TestContextSubChat/call8.golden +++ b/pkg/tests/testdata/TestContextSubChat/call8.golden @@ -1,7 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -19,7 +19,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -56,10 +56,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/call9.golden b/pkg/tests/testdata/TestContextSubChat/call9.golden index 00ea4ae3..0cb1f56a 100644 --- a/pkg/tests/testdata/TestContextSubChat/call9.golden +++ b/pkg/tests/testdata/TestContextSubChat/call9.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestContextSubChat/test.gpt:chatbot", @@ -10,7 +9,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -53,10 +52,5 @@ }, "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestContextSubChat/step1.golden b/pkg/tests/testdata/TestContextSubChat/step1.golden index 2deefc63..1a675b28 100644 --- a/pkg/tests/testdata/TestContextSubChat/step1.golden +++ b/pkg/tests/testdata/TestContextSubChat/step1.golden @@ -7,9 +7,8 @@ "continuation": { "state": { "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestContextSubChat/test.gpt:chatbot", @@ -18,7 +17,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -44,12 +43,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }, "pending": { "call_1": { @@ -78,9 +72,9 @@ "state": { "input": "Input to chatbot1", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -98,7 +92,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -126,12 +120,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant Response 1 - from chatbot1" diff --git a/pkg/tests/testdata/TestContextSubChat/step2.golden b/pkg/tests/testdata/TestContextSubChat/step2.golden index 6c9b09ae..d9631971 100644 --- a/pkg/tests/testdata/TestContextSubChat/step2.golden +++ b/pkg/tests/testdata/TestContextSubChat/step2.golden @@ -7,10 +7,9 @@ "state": { "input": "User 1", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -38,12 +37,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant Response 3 - from main chat tool" diff --git a/pkg/tests/testdata/TestContextSubChat/step3.golden b/pkg/tests/testdata/TestContextSubChat/step3.golden index 4319caad..d57035d5 100644 --- a/pkg/tests/testdata/TestContextSubChat/step3.golden +++ b/pkg/tests/testdata/TestContextSubChat/step3.golden @@ -7,10 +7,9 @@ "state": { "input": "User 1", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -38,12 +37,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant Response 3 - from main chat tool" @@ -54,9 +48,8 @@ "continuation": { "state": { "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestContextSubChat/test.gpt:chatbot", @@ -65,7 +58,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -91,12 +84,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }, "pending": { "call_3": { @@ -125,9 +113,9 @@ "state": { "input": "Input to chatbot1 on resume", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -145,7 +133,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -173,12 +161,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant Response 4 - from chatbot1" diff --git a/pkg/tests/testdata/TestContextSubChat/step4.golden b/pkg/tests/testdata/TestContextSubChat/step4.golden index 1d53337a..40798cf6 100644 --- a/pkg/tests/testdata/TestContextSubChat/step4.golden +++ b/pkg/tests/testdata/TestContextSubChat/step4.golden @@ -7,10 +7,9 @@ "state": { "input": "User 1", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -56,12 +55,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant Response 6 - from main chat tool resume" diff --git a/pkg/tests/testdata/TestCwd/call1.golden b/pkg/tests/testdata/TestCwd/call1.golden index f358e579..af0c8c12 100644 --- a/pkg/tests/testdata/TestCwd/call1.golden +++ b/pkg/tests/testdata/TestCwd/call1.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestCwd/subtool/test.gpt:", @@ -17,7 +16,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -27,10 +26,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestCwd/call2.golden b/pkg/tests/testdata/TestCwd/call2.golden index 7677539d..9069b850 100644 --- a/pkg/tests/testdata/TestCwd/call2.golden +++ b/pkg/tests/testdata/TestCwd/call2.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestCwd/subtool/test.gpt:", @@ -17,7 +16,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -58,10 +57,5 @@ }, "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestCwd/call3.golden b/pkg/tests/testdata/TestCwd/call3.golden index de03ed7b..05c4924a 100644 --- a/pkg/tests/testdata/TestCwd/call3.golden +++ b/pkg/tests/testdata/TestCwd/call3.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestCwd/subtool/test.gpt:", @@ -17,7 +16,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -89,10 +88,5 @@ }, "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestDualSubChat/call1.golden b/pkg/tests/testdata/TestDualSubChat/call1.golden index 5eb4dc68..a0c21ccc 100644 --- a/pkg/tests/testdata/TestDualSubChat/call1.golden +++ b/pkg/tests/testdata/TestDualSubChat/call1.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestDualSubChat/test.gpt:chatbot", @@ -17,7 +16,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -36,10 +35,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestDualSubChat/call2.golden b/pkg/tests/testdata/TestDualSubChat/call2.golden index f7398a8f..c3843cb9 100644 --- a/pkg/tests/testdata/TestDualSubChat/call2.golden +++ b/pkg/tests/testdata/TestDualSubChat/call2.golden @@ -1,7 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -19,7 +19,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -38,10 +38,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestDualSubChat/call3.golden b/pkg/tests/testdata/TestDualSubChat/call3.golden index e211e8f2..755dda31 100644 --- a/pkg/tests/testdata/TestDualSubChat/call3.golden +++ b/pkg/tests/testdata/TestDualSubChat/call3.golden @@ -1,7 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -19,7 +19,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -38,10 +38,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestDualSubChat/call4.golden b/pkg/tests/testdata/TestDualSubChat/call4.golden index 7a0b9aa0..45b6648b 100644 --- a/pkg/tests/testdata/TestDualSubChat/call4.golden +++ b/pkg/tests/testdata/TestDualSubChat/call4.golden @@ -1,7 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -19,7 +19,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -56,10 +56,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestDualSubChat/call5.golden b/pkg/tests/testdata/TestDualSubChat/call5.golden index 1ce59fd6..2aa21e94 100644 --- a/pkg/tests/testdata/TestDualSubChat/call5.golden +++ b/pkg/tests/testdata/TestDualSubChat/call5.golden @@ -1,7 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -19,7 +19,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -56,10 +56,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestDualSubChat/call6.golden b/pkg/tests/testdata/TestDualSubChat/call6.golden index dd8d25fb..6194daed 100644 --- a/pkg/tests/testdata/TestDualSubChat/call6.golden +++ b/pkg/tests/testdata/TestDualSubChat/call6.golden @@ -1,7 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -19,7 +19,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -74,10 +74,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestDualSubChat/call7.golden b/pkg/tests/testdata/TestDualSubChat/call7.golden index 96e29d18..60842c68 100644 --- a/pkg/tests/testdata/TestDualSubChat/call7.golden +++ b/pkg/tests/testdata/TestDualSubChat/call7.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestDualSubChat/test.gpt:chatbot", @@ -17,7 +16,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -96,10 +95,5 @@ }, "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestDualSubChat/step1.golden b/pkg/tests/testdata/TestDualSubChat/step1.golden index 35323401..421bb069 100644 --- a/pkg/tests/testdata/TestDualSubChat/step1.golden +++ b/pkg/tests/testdata/TestDualSubChat/step1.golden @@ -7,9 +7,8 @@ "state": { "input": "User 1", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestDualSubChat/test.gpt:chatbot", @@ -25,7 +24,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -70,12 +69,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }, "pending": { "call_1": { @@ -116,9 +110,9 @@ "state": { "input": "Input to chatbot1", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -136,7 +130,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -164,12 +158,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant Response 1 - from chatbot1" @@ -185,9 +174,9 @@ "state": { "input": "Input to chatbot2", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -205,7 +194,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -233,12 +222,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistent Response 2 - from chatbot2" diff --git a/pkg/tests/testdata/TestDualSubChat/step2.golden b/pkg/tests/testdata/TestDualSubChat/step2.golden index 36903882..82f1a7cd 100644 --- a/pkg/tests/testdata/TestDualSubChat/step2.golden +++ b/pkg/tests/testdata/TestDualSubChat/step2.golden @@ -7,9 +7,8 @@ "state": { "input": "User 1", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestDualSubChat/test.gpt:chatbot", @@ -25,7 +24,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -70,12 +69,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }, "pending": { "call_1": { @@ -123,9 +117,9 @@ "state": { "input": "Input to chatbot2", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -143,7 +137,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -171,12 +165,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistent Response 2 - from chatbot2" diff --git a/pkg/tests/testdata/TestDualSubChat/step3.golden b/pkg/tests/testdata/TestDualSubChat/step3.golden index df7b92ea..ab2dc7c3 100644 --- a/pkg/tests/testdata/TestDualSubChat/step3.golden +++ b/pkg/tests/testdata/TestDualSubChat/step3.golden @@ -7,9 +7,8 @@ "state": { "input": "User 1", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestDualSubChat/test.gpt:chatbot", @@ -25,7 +24,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -70,12 +69,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }, "pending": { "call_1": { @@ -123,9 +117,9 @@ "state": { "input": "Input to chatbot2", "completion": { - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ { "function": { "toolID": "sys.chat.finish", @@ -143,7 +137,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -189,12 +183,7 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] } }, "result": "Assistant 3" diff --git a/pkg/tests/testdata/TestExport/call1.golden b/pkg/tests/testdata/TestExport/call1.golden index 8d0e4ea6..bc35465f 100644 --- a/pkg/tests/testdata/TestExport/call1.golden +++ b/pkg/tests/testdata/TestExport/call1.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestExport/parent.gpt:frommain", @@ -57,7 +56,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -67,10 +66,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestExport/call2.golden b/pkg/tests/testdata/TestExport/call2.golden index c4ab9832..240c2312 100644 --- a/pkg/tests/testdata/TestExport/call2.golden +++ b/pkg/tests/testdata/TestExport/call2.golden @@ -1,8 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "messages": [ { "role": "system", "content": [ @@ -12,10 +10,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestExport/call3.golden b/pkg/tests/testdata/TestExport/call3.golden index 560a2ddd..3b76c8af 100644 --- a/pkg/tests/testdata/TestExport/call3.golden +++ b/pkg/tests/testdata/TestExport/call3.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestExport/parent.gpt:frommain", @@ -57,7 +56,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -98,10 +97,5 @@ }, "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestExportContext/call1.golden b/pkg/tests/testdata/TestExportContext/call1.golden index cf8d7dc3..2b7105dd 100644 --- a/pkg/tests/testdata/TestExportContext/call1.golden +++ b/pkg/tests/testdata/TestExportContext/call1.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestExportContext/test.gpt:subtool", @@ -37,7 +36,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -47,10 +46,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestSubChat/call1.golden b/pkg/tests/testdata/TestSubChat/call1.golden index 7ec7696c..dc161663 100644 --- a/pkg/tests/testdata/TestSubChat/call1.golden +++ b/pkg/tests/testdata/TestSubChat/call1.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestSubChat/test.gpt:chatbot", @@ -10,7 +9,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -29,10 +28,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestSubChat/call2.golden b/pkg/tests/testdata/TestSubChat/call2.golden index 17221df1..5fdf4ff8 100644 --- a/pkg/tests/testdata/TestSubChat/call2.golden +++ b/pkg/tests/testdata/TestSubChat/call2.golden @@ -1,8 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -12,10 +11,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestSubChat/call3.golden b/pkg/tests/testdata/TestSubChat/call3.golden index 13bab818..b1b4b3a9 100644 --- a/pkg/tests/testdata/TestSubChat/call3.golden +++ b/pkg/tests/testdata/TestSubChat/call3.golden @@ -1,8 +1,7 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": false, - "Tools": null, - "Messages": [ + "model": "gpt-4o", + "internalSystemPrompt": false, + "messages": [ { "role": "system", "content": [ @@ -30,10 +29,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/tests/testdata/TestToolAs/call1.golden b/pkg/tests/testdata/TestToolAs/call1.golden index e90d6d6f..e7ec18b5 100644 --- a/pkg/tests/testdata/TestToolAs/call1.golden +++ b/pkg/tests/testdata/TestToolAs/call1.golden @@ -1,7 +1,6 @@ `{ - "Model": "gpt-4o", - "InternalSystemPrompt": null, - "Tools": [ + "model": "gpt-4o", + "tools": [ { "function": { "toolID": "testdata/TestToolAs/test.gpt:infile", @@ -39,7 +38,7 @@ } } ], - "Messages": [ + "messages": [ { "role": "system", "content": [ @@ -58,10 +57,5 @@ ], "usage": {} } - ], - "MaxTokens": 0, - "Temperature": null, - "JSONResponse": false, - "Grammar": "", - "Cache": null + ] }` diff --git a/pkg/types/completion.go b/pkg/types/completion.go index 14c7e987..7665a51f 100644 --- a/pkg/types/completion.go +++ b/pkg/types/completion.go @@ -9,15 +9,14 @@ import ( ) type CompletionRequest struct { - Model string - InternalSystemPrompt *bool - Tools []CompletionTool - Messages []CompletionMessage - MaxTokens int - Temperature *float32 - JSONResponse bool - Grammar string - Cache *bool + Model string `json:"model,omitempty"` + InternalSystemPrompt *bool `json:"internalSystemPrompt,omitempty"` + Tools []CompletionTool `json:"tools,omitempty"` + Messages []CompletionMessage `json:"messages,omitempty"` + MaxTokens int `json:"maxTokens,omitempty"` + Temperature *float32 `json:"temperature,omitempty"` + JSONResponse bool `json:"jsonResponse,omitempty"` + Cache *bool `json:"cache,omitempty"` } func (r *CompletionRequest) GetCache() bool { @@ -57,6 +56,20 @@ type CompletionMessage struct { Usage Usage `json:"usage,omitempty"` } +func (c CompletionMessage) ChatText() string { + var buf strings.Builder + for _, part := range c.Content { + if part.Text == "" { + continue + } + if buf.Len() > 0 { + buf.WriteString(" ") + } + buf.WriteString(part.Text) + } + return buf.String() +} + type Usage struct { PromptTokens int `json:"promptTokens,omitempty"` CompletionTokens int `json:"completionTokens,omitempty"` @@ -73,8 +86,8 @@ type CompletionStatus struct { PartialResponse *CompletionMessage } -func (in CompletionMessage) IsToolCall() bool { - for _, content := range in.Content { +func (c CompletionMessage) IsToolCall() bool { + for _, content := range c.Content { if content.ToolCall != nil { return true } @@ -90,9 +103,9 @@ func Text(text string) []ContentPart { } } -func (in CompletionMessage) String() string { +func (c CompletionMessage) String() string { buf := strings.Builder{} - for i, content := range in.Content { + for i, content := range c.Content { if i > 0 { buf.WriteString("\n") }