From ea0184f3b3c6aaff72e868b919fc8c9b657a0395 Mon Sep 17 00:00:00 2001 From: Nick Hale <4175918+njhale@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:56:35 -0400 Subject: [PATCH 01/38] chore: use laplateforme provider for mistral smoke tests Signed-off-by: Nick Hale <4175918+njhale@users.noreply.github.com> --- .github/workflows/smoke.yaml | 5 +- .../Bob/mistral-large-2402-expected.json | 808 +++++++++++------- .../mistral-large-2402-expected.json | 553 +++++++----- 3 files changed, 839 insertions(+), 527 deletions(-) diff --git a/.github/workflows/smoke.yaml b/.github/workflows/smoke.yaml index 0106ed6d..59ff43a2 100644 --- a/.github/workflows/smoke.yaml +++ b/.github/workflows/smoke.yaml @@ -170,8 +170,9 @@ jobs: go-version: "1.21" - env: OPENAI_API_KEY: ${{ secrets.SMOKE_OPENAI_API_KEY }} - GPTSCRIPT_DEFAULT_MODEL: mistral-large-2402 from https://api.mistral.ai/v1 - GPTSCRIPT_PROVIDER_API_MISTRAL_AI_API_KEY: ${{ secrets.SMOKE_GPTSCRIPT_PROVIDER_API_MISTRAL_AI_API_KEY }} + GPTSCRIPT_DEFAULT_MODEL: mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider + MISTRAL_API_KEY: ${{ secrets.SMOKE_MISTRAL_API_KEY }} + GPTSCRIPT_CREDENTIAL_OVERRIDE: "github.com/gptscript-ai/mistral-laplateforme-provider/credential:MISTRAL_API_KEY" name: Run smoke test for mistral-large-2402 run: | echo "Running smoke test for model mistral-large-2402" diff --git a/pkg/tests/smoke/testdata/Bob/mistral-large-2402-expected.json b/pkg/tests/smoke/testdata/Bob/mistral-large-2402-expected.json index f7341a7b..8730226a 100644 --- a/pkg/tests/smoke/testdata/Bob/mistral-large-2402-expected.json +++ b/pkg/tests/smoke/testdata/Bob/mistral-large-2402-expected.json @@ -1,15 +1,15 @@ [ { - "time": "2024-06-20T17:10:39.294578-04:00", + "time": "2024-07-03T10:53:01.406601-04:00", "type": "runStart", "usage": {} }, { - "time": "2024-06-20T17:10:39.294835-04:00", + "time": "2024-07-03T10:53:01.406888-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -34,17 +34,123 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callStart", "usage": {} }, { - "time": "2024-06-20T17:10:39.501107-04:00", + "time": "2024-07-03T10:53:02.106674-04:00", + "type": "runStart", + "usage": {} + }, + { + "time": "2024-07-03T10:53:02.107085-04:00", + "callContext": { + "id": "1720018383", + "tool": { + "name": "Mistral La Plateforme Provider", + "description": "Model provider for Mistral models running on La Plateforme", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", + "modelProvider": true, + "internalPrompt": null, + "credentials": [ + "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env" + ], + "instructions": "#!sys.daemon /usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py", + "id": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt:Mistral La Plateforme Provider", + "toolMapping": { + "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env": [ + { + "reference": "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env", + "toolID": "https://raw.githubusercontent.com/gptscript-ai/credential/651dfad6e7cf3a385ef408afa93ce522c10f8508/tool.gpt:token" + } + ] + }, + "localTools": { + "mistral la plateforme provider": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt:Mistral La Plateforme Provider" + }, + "source": { + "location": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt", + "lineNo": 1, + "repo": { + "VCS": "git", + "Root": "https://github.com/gptscript-ai/mistral-laplateforme-provider.git", + "Path": "/", + "Name": "tool.gpt", + "Revision": "cbf1aeb6db495b9b6223984651d29ac511d2748d" + } + }, + "workingDir": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d" + }, + "currentAgent": {}, + "inputContext": null, + "toolCategory": "provider", + "displayText": "Running sys.daemon" + }, + "type": "callStart", + "usage": {} + }, + { + "time": "2024-07-03T10:53:03.125117-04:00", + "callContext": { + "id": "1720018383", + "tool": { + "name": "Mistral La Plateforme Provider", + "description": "Model provider for Mistral models running on La Plateforme", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", + "modelProvider": true, + "internalPrompt": null, + "credentials": [ + "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env" + ], + "instructions": "#!sys.daemon /usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py", + "id": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt:Mistral La Plateforme Provider", + "toolMapping": { + "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env": [ + { + "reference": "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env", + "toolID": "https://raw.githubusercontent.com/gptscript-ai/credential/651dfad6e7cf3a385ef408afa93ce522c10f8508/tool.gpt:token" + } + ] + }, + "localTools": { + "mistral la plateforme provider": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt:Mistral La Plateforme Provider" + }, + "source": { + "location": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt", + "lineNo": 1, + "repo": { + "VCS": "git", + "Root": "https://github.com/gptscript-ai/mistral-laplateforme-provider.git", + "Path": "/", + "Name": "tool.gpt", + "Revision": "cbf1aeb6db495b9b6223984651d29ac511d2748d" + } + }, + "workingDir": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d" + }, + "currentAgent": {}, + "inputContext": null, + "toolCategory": "provider", + "displayText": "Running sys.daemon" + }, + "type": "callFinish", + "usage": {}, + "content": "http://127.0.0.1:10244" + }, + { + "time": "2024-07-03T10:53:03.125375-04:00", + "type": "runFinish", + "usage": {} + }, + { + "time": "2024-07-03T10:53:03.12547-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -69,10 +175,11 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callChat", - "chatCompletionId": "1718917841", + "chatCompletionId": "1720018384", "usage": {}, "chatRequest": { "model": "mistral-large-2402", @@ -104,11 +211,11 @@ } }, { - "time": "2024-06-20T17:10:39.501246-04:00", + "time": "2024-07-03T10:53:03.126002-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -133,19 +240,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917841", + "chatCompletionId": "1720018384", "usage": {}, "content": "Waiting for model response..." }, { - "time": "2024-06-20T17:10:40.154068-04:00", + "time": "2024-07-03T10:53:03.438634-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -170,18 +278,19 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917841", + "chatCompletionId": "1720018384", "usage": {} }, { - "time": "2024-06-20T17:10:40.786117-04:00", + "time": "2024-07-03T10:53:03.917633-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -206,19 +315,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917841", + "chatCompletionId": "1720018384", "usage": {}, "content": "\u003ctool call\u003e bob -\u003e {\"question\": \"how are you doing\"}" }, { - "time": "2024-06-20T17:10:40.786643-04:00", + "time": "2024-07-03T10:53:03.9181-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -243,14 +353,15 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callChat", - "chatCompletionId": "1718917841", + "chatCompletionId": "1720018384", "usage": { - "promptTokens": 85, + "promptTokens": 188, "completionTokens": 23, - "totalTokens": 108 + "totalTokens": 211 }, "chatResponse": { "role": "assistant", @@ -258,7 +369,7 @@ { "toolCall": { "index": 0, - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "function": { "name": "bob", "arguments": "{\"question\": \"how are you doing\"}" @@ -267,18 +378,18 @@ } ], "usage": { - "promptTokens": 85, + "promptTokens": 188, "completionTokens": 23, - "totalTokens": 108 + "totalTokens": 211 } } }, { - "time": "2024-06-20T17:10:40.78704-04:00", + "time": "2024-07-03T10:53:03.918447-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -303,10 +414,11 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "toolSubCalls": { - "WWpUyFBHH": { + "IePX3uH5y": { "toolID": "testdata/Bob/test.gpt:bob", "input": "{\"question\": \"how are you doing\"}" } @@ -315,13 +427,13 @@ "usage": {} }, { - "time": "2024-06-20T17:10:40.787133-04:00", + "time": "2024-07-03T10:53:03.918585-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -344,22 +456,23 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callStart", "usage": {}, "content": "{\"question\": \"how are you doing\"}" }, { - "time": "2024-06-20T17:10:40.94973-04:00", + "time": "2024-07-03T10:53:04.089188-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -382,12 +495,13 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callChat", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "chatRequest": { "model": "mistral-large-2402", @@ -405,13 +519,13 @@ } }, { - "time": "2024-06-20T17:10:40.950046-04:00", + "time": "2024-07-03T10:53:04.089548-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -434,23 +548,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Waiting for model response..." }, { - "time": "2024-06-20T17:10:41.218814-04:00", + "time": "2024-07-03T10:53:04.287287-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -473,23 +588,23 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", - "usage": {}, - "content": "Thanks" + "chatCompletionId": "1720018385", + "usage": {} }, { - "time": "2024-06-20T17:10:41.218971-04:00", + "time": "2024-07-03T10:53:04.287688-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -512,23 +627,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks" }, { - "time": "2024-06-20T17:10:41.242129-04:00", + "time": "2024-07-03T10:53:04.302879-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -551,23 +667,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for" }, { - "time": "2024-06-20T17:10:41.278815-04:00", + "time": "2024-07-03T10:53:04.323886-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -590,23 +707,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking" }, { - "time": "2024-06-20T17:10:41.298557-04:00", + "time": "2024-07-03T10:53:04.345227-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -629,23 +747,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"" }, { - "time": "2024-06-20T17:10:41.329684-04:00", + "time": "2024-07-03T10:53:04.364182-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -668,23 +787,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how" }, { - "time": "2024-06-20T17:10:41.36213-04:00", + "time": "2024-07-03T10:53:04.387098-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -707,23 +827,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are" }, { - "time": "2024-06-20T17:10:41.404159-04:00", + "time": "2024-07-03T10:53:04.405872-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -746,23 +867,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you" }, { - "time": "2024-06-20T17:10:41.443596-04:00", + "time": "2024-07-03T10:53:04.427749-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -785,23 +907,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing" }, { - "time": "2024-06-20T17:10:41.46035-04:00", + "time": "2024-07-03T10:53:04.448563-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -824,23 +947,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\"," }, { - "time": "2024-06-20T17:10:41.479186-04:00", + "time": "2024-07-03T10:53:04.468026-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -863,23 +987,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\", I" }, { - "time": "2024-06-20T17:10:41.508921-04:00", + "time": "2024-07-03T10:53:04.490606-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -902,23 +1027,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\", I'" }, { - "time": "2024-06-20T17:10:41.538159-04:00", + "time": "2024-07-03T10:53:04.511171-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -941,23 +1067,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\", I'm" }, { - "time": "2024-06-20T17:10:41.578073-04:00", + "time": "2024-07-03T10:53:04.531235-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -980,23 +1107,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\", I'm doing" }, { - "time": "2024-06-20T17:10:41.59766-04:00", + "time": "2024-07-03T10:53:04.553855-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -1019,23 +1147,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\", I'm doing great" }, { - "time": "2024-06-20T17:10:41.711868-04:00", + "time": "2024-07-03T10:53:04.574503-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -1058,23 +1187,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\", I'm doing great fellow" }, { - "time": "2024-06-20T17:10:41.712039-04:00", + "time": "2024-07-03T10:53:04.598055-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -1097,23 +1227,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, - "content": "Thanks for asking \"how are you doing\", I'm doing great fellow friendly AI" + "content": "Thanks for asking \"how are you doing\", I'm doing great fellow friendly" }, { - "time": "2024-06-20T17:10:41.712067-04:00", + "time": "2024-07-03T10:53:04.613412-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -1136,23 +1267,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\", I'm doing great fellow friendly AI" }, { - "time": "2024-06-20T17:10:41.718662-04:00", + "time": "2024-07-03T10:53:04.635897-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -1175,23 +1307,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\", I'm doing great fellow friendly AI tool" }, { - "time": "2024-06-20T17:10:41.748288-04:00", + "time": "2024-07-03T10:53:04.656116-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -1214,23 +1347,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\", I'm doing great fellow friendly AI tool!" }, { - "time": "2024-06-20T17:10:41.78608-04:00", + "time": "2024-07-03T10:53:04.680962-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -1253,23 +1387,24 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callProgress", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": {}, "content": "Thanks for asking \"how are you doing\", I'm doing great fellow friendly AI tool!" }, { - "time": "2024-06-20T17:10:41.786165-04:00", + "time": "2024-07-03T10:53:04.681447-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -1292,16 +1427,17 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callChat", - "chatCompletionId": "1718917842", + "chatCompletionId": "1720018385", "usage": { - "promptTokens": 41, + "promptTokens": 143, "completionTokens": 19, - "totalTokens": 60 + "totalTokens": 162 }, "chatResponse": { "role": "assistant", @@ -1311,20 +1447,20 @@ } ], "usage": { - "promptTokens": 41, + "promptTokens": 143, "completionTokens": 19, - "totalTokens": 60 + "totalTokens": 162 } } }, { - "time": "2024-06-20T17:10:41.7862-04:00", + "time": "2024-07-03T10:53:04.681598-04:00", "callContext": { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -1347,20 +1483,21 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917840" + "parentID": "1720018382" }, "type": "callFinish", "usage": {}, "content": "Thanks for asking \"how are you doing\", I'm doing great fellow friendly AI tool!" }, { - "time": "2024-06-20T17:10:41.78624-04:00", + "time": "2024-07-03T10:53:04.681725-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1385,6 +1522,7 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "toolResults": 1, @@ -1392,11 +1530,11 @@ "usage": {} }, { - "time": "2024-06-20T17:10:41.957577-04:00", + "time": "2024-07-03T10:53:04.842182-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1421,10 +1559,11 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callChat", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, "chatRequest": { "model": "mistral-large-2402", @@ -1438,7 +1577,7 @@ "content": "", "tool_calls": [ { - "id": "WWpUyFBHH", + "id": "IePX3uH5y", "type": "function", "function": { "name": "bob", @@ -1451,7 +1590,7 @@ "role": "tool", "content": "Thanks for asking \"how are you doing\", I'm doing great fellow friendly AI tool!", "name": "bob", - "tool_call_id": "WWpUyFBHH" + "tool_call_id": "IePX3uH5y" } ], "temperature": 0, @@ -1476,11 +1615,11 @@ } }, { - "time": "2024-06-20T17:10:41.957749-04:00", + "time": "2024-07-03T10:53:04.842685-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1505,19 +1644,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, "content": "Waiting for model response..." }, { - "time": "2024-06-20T17:10:42.455931-04:00", + "time": "2024-07-03T10:53:05.384131-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1542,19 +1682,19 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", - "usage": {}, - "content": "Bob" + "chatCompletionId": "1720018386", + "usage": {} }, { - "time": "2024-06-20T17:10:42.45599-04:00", + "time": "2024-07-03T10:53:05.384657-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1579,19 +1719,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied" + "content": "Bob" }, { - "time": "2024-06-20T17:10:42.456033-04:00", + "time": "2024-07-03T10:53:05.404612-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1616,19 +1757,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied" + "content": "Bob said" }, { - "time": "2024-06-20T17:10:42.475053-04:00", + "time": "2024-07-03T10:53:05.430068-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1653,19 +1795,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied," + "content": "Bob said," }, { - "time": "2024-06-20T17:10:42.534667-04:00", + "time": "2024-07-03T10:53:05.452982-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1690,19 +1833,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"" + "content": "Bob said, \"" }, { - "time": "2024-06-20T17:10:42.594649-04:00", + "time": "2024-07-03T10:53:05.501525-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1727,19 +1871,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks" + "content": "Bob said, \"Thanks for" }, { - "time": "2024-06-20T17:10:42.653279-04:00", + "time": "2024-07-03T10:53:05.50179-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1764,19 +1909,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for" + "content": "Bob said, \"Thanks for" }, { - "time": "2024-06-20T17:10:42.760299-04:00", + "time": "2024-07-03T10:53:05.532152-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1801,19 +1947,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking" + "content": "Bob said, \"Thanks for asking" }, { - "time": "2024-06-20T17:10:42.774637-04:00", + "time": "2024-07-03T10:53:05.553295-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1838,19 +1985,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking '" + "content": "Bob said, \"Thanks for asking '" }, { - "time": "2024-06-20T17:10:42.835456-04:00", + "time": "2024-07-03T10:53:05.576012-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1875,19 +2023,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how" + "content": "Bob said, \"Thanks for asking 'how" }, { - "time": "2024-06-20T17:10:42.889942-04:00", + "time": "2024-07-03T10:53:05.602885-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1912,19 +2061,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are" + "content": "Bob said, \"Thanks for asking 'how are" }, { - "time": "2024-06-20T17:10:42.951997-04:00", + "time": "2024-07-03T10:53:05.624751-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1949,19 +2099,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you" + "content": "Bob said, \"Thanks for asking 'how are you" }, { - "time": "2024-06-20T17:10:43.009024-04:00", + "time": "2024-07-03T10:53:05.649543-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1986,19 +2137,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing" + "content": "Bob said, \"Thanks for asking 'how are you doing" }, { - "time": "2024-06-20T17:10:43.072963-04:00", + "time": "2024-07-03T10:53:05.674199-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2023,19 +2175,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing'," + "content": "Bob said, \"Thanks for asking 'how are you doing'," }, { - "time": "2024-06-20T17:10:43.129687-04:00", + "time": "2024-07-03T10:53:05.697398-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2060,19 +2213,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I" + "content": "Bob said, \"Thanks for asking 'how are you doing', I" }, { - "time": "2024-06-20T17:10:43.168387-04:00", + "time": "2024-07-03T10:53:05.725234-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2097,19 +2251,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'" }, { - "time": "2024-06-20T17:10:43.286476-04:00", + "time": "2024-07-03T10:53:05.747687-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2134,19 +2289,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'm" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'm" }, { - "time": "2024-06-20T17:10:43.286589-04:00", + "time": "2024-07-03T10:53:05.773761-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2171,19 +2327,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'm doing great" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'm doing" }, { - "time": "2024-06-20T17:10:43.286632-04:00", + "time": "2024-07-03T10:53:05.798352-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2208,19 +2365,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'm doing great" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'm doing great" }, { - "time": "2024-06-20T17:10:43.323232-04:00", + "time": "2024-07-03T10:53:05.823105-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2245,19 +2403,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'm doing great fellow" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'm doing great fellow" }, { - "time": "2024-06-20T17:10:43.3614-04:00", + "time": "2024-07-03T10:53:05.846373-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2282,19 +2441,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly" }, { - "time": "2024-06-20T17:10:43.402971-04:00", + "time": "2024-07-03T10:53:05.871647-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2319,19 +2479,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI" }, { - "time": "2024-06-20T17:10:43.442811-04:00", + "time": "2024-07-03T10:53:05.895603-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2356,19 +2517,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI tool" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI tool" }, { - "time": "2024-06-20T17:10:43.477932-04:00", + "time": "2024-07-03T10:53:05.919754-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2393,19 +2555,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI tool!\"" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI tool!\"" }, { - "time": "2024-06-20T17:10:43.524916-04:00", + "time": "2024-07-03T10:53:05.956244-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2430,19 +2593,20 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI tool!\"" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI tool!\"" }, { - "time": "2024-06-20T17:10:43.525171-04:00", + "time": "2024-07-03T10:53:05.956647-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2467,35 +2631,36 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callChat", - "chatCompletionId": "1718917843", + "chatCompletionId": "1720018386", "usage": { - "promptTokens": 143, + "promptTokens": 246, "completionTokens": 23, - "totalTokens": 166 + "totalTokens": 269 }, "chatResponse": { "role": "assistant", "content": [ { - "text": "Bob replied, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI tool!\"" + "text": "Bob said, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI tool!\"" } ], "usage": { - "promptTokens": 143, + "promptTokens": 246, "completionTokens": 23, - "totalTokens": 166 + "totalTokens": 269 } } }, { - "time": "2024-06-20T17:10:43.525284-04:00", + "time": "2024-07-03T10:53:05.956695-04:00", "callContext": { - "id": "1718917840", + "id": "1720018382", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -2520,14 +2685,15 @@ }, "workingDir": "testdata/Bob" }, + "currentAgent": {}, "inputContext": null }, "type": "callFinish", "usage": {}, - "content": "Bob replied, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI tool!\"" + "content": "Bob said, \"Thanks for asking 'how are you doing', I'm doing great fellow friendly AI tool!\"" }, { - "time": "2024-06-20T17:10:43.525327-04:00", + "time": "2024-07-03T10:53:05.956743-04:00", "type": "runFinish", "usage": {} } diff --git a/pkg/tests/smoke/testdata/BobAsShell/mistral-large-2402-expected.json b/pkg/tests/smoke/testdata/BobAsShell/mistral-large-2402-expected.json index b3e54dc4..43df5fa7 100644 --- a/pkg/tests/smoke/testdata/BobAsShell/mistral-large-2402-expected.json +++ b/pkg/tests/smoke/testdata/BobAsShell/mistral-large-2402-expected.json @@ -1,15 +1,15 @@ [ { - "time": "2024-06-20T17:10:43.55694-04:00", + "time": "2024-07-03T10:53:05.993864-04:00", "type": "runStart", "usage": {} }, { - "time": "2024-06-20T17:10:43.557263-04:00", + "time": "2024-07-03T10:53:05.99419-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -34,17 +34,123 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callStart", "usage": {} }, { - "time": "2024-06-20T17:10:43.805494-04:00", + "time": "2024-07-03T10:53:06.366435-04:00", + "type": "runStart", + "usage": {} + }, + { + "time": "2024-07-03T10:53:06.366952-04:00", + "callContext": { + "id": "1720018387", + "tool": { + "name": "Mistral La Plateforme Provider", + "description": "Model provider for Mistral models running on La Plateforme", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", + "modelProvider": true, + "internalPrompt": null, + "credentials": [ + "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env" + ], + "instructions": "#!sys.daemon /usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py", + "id": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt:Mistral La Plateforme Provider", + "toolMapping": { + "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env": [ + { + "reference": "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env", + "toolID": "https://raw.githubusercontent.com/gptscript-ai/credential/651dfad6e7cf3a385ef408afa93ce522c10f8508/tool.gpt:token" + } + ] + }, + "localTools": { + "mistral la plateforme provider": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt:Mistral La Plateforme Provider" + }, + "source": { + "location": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt", + "lineNo": 1, + "repo": { + "VCS": "git", + "Root": "https://github.com/gptscript-ai/mistral-laplateforme-provider.git", + "Path": "/", + "Name": "tool.gpt", + "Revision": "cbf1aeb6db495b9b6223984651d29ac511d2748d" + } + }, + "workingDir": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d" + }, + "currentAgent": {}, + "inputContext": null, + "toolCategory": "provider", + "displayText": "Running sys.daemon" + }, + "type": "callStart", + "usage": {} + }, + { + "time": "2024-07-03T10:53:07.383203-04:00", + "callContext": { + "id": "1720018387", + "tool": { + "name": "Mistral La Plateforme Provider", + "description": "Model provider for Mistral models running on La Plateforme", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", + "modelProvider": true, + "internalPrompt": null, + "credentials": [ + "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env" + ], + "instructions": "#!sys.daemon /usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py", + "id": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt:Mistral La Plateforme Provider", + "toolMapping": { + "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env": [ + { + "reference": "github.com/gptscript-ai/credential as github.com/gptscript-ai/mistral-laplateforme-provider/credential with \"Please enter your Mistral La Plateforme API Key\" as message and token as field and \"MISTRAL_API_KEY\" as env", + "toolID": "https://raw.githubusercontent.com/gptscript-ai/credential/651dfad6e7cf3a385ef408afa93ce522c10f8508/tool.gpt:token" + } + ] + }, + "localTools": { + "mistral la plateforme provider": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt:Mistral La Plateforme Provider" + }, + "source": { + "location": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d/tool.gpt", + "lineNo": 1, + "repo": { + "VCS": "git", + "Root": "https://github.com/gptscript-ai/mistral-laplateforme-provider.git", + "Path": "/", + "Name": "tool.gpt", + "Revision": "cbf1aeb6db495b9b6223984651d29ac511d2748d" + } + }, + "workingDir": "https://raw.githubusercontent.com/gptscript-ai/mistral-laplateforme-provider/cbf1aeb6db495b9b6223984651d29ac511d2748d" + }, + "currentAgent": {}, + "inputContext": null, + "toolCategory": "provider", + "displayText": "Running sys.daemon" + }, + "type": "callFinish", + "usage": {}, + "content": "http://127.0.0.1:10798" + }, + { + "time": "2024-07-03T10:53:07.383553-04:00", + "type": "runFinish", + "usage": {} + }, + { + "time": "2024-07-03T10:53:07.383621-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -69,10 +175,11 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callChat", - "chatCompletionId": "1718917845", + "chatCompletionId": "1720018388", "usage": {}, "chatRequest": { "model": "mistral-large-2402", @@ -104,11 +211,11 @@ } }, { - "time": "2024-06-20T17:10:43.805682-04:00", + "time": "2024-07-03T10:53:07.384109-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -133,19 +240,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917845", + "chatCompletionId": "1720018388", "usage": {}, "content": "Waiting for model response..." }, { - "time": "2024-06-20T17:10:44.078279-04:00", + "time": "2024-07-03T10:53:07.670442-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -170,18 +278,19 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917845", + "chatCompletionId": "1720018388", "usage": {} }, { - "time": "2024-06-20T17:10:44.913816-04:00", + "time": "2024-07-03T10:53:08.283965-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -206,19 +315,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917845", + "chatCompletionId": "1720018388", "usage": {}, "content": "\u003ctool call\u003e bob -\u003e {\"question\": \"how are you doing\"}" }, { - "time": "2024-06-20T17:10:44.914845-04:00", + "time": "2024-07-03T10:53:08.284275-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -243,14 +353,15 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callChat", - "chatCompletionId": "1718917845", + "chatCompletionId": "1720018388", "usage": { - "promptTokens": 85, + "promptTokens": 188, "completionTokens": 23, - "totalTokens": 108 + "totalTokens": 211 }, "chatResponse": { "role": "assistant", @@ -258,7 +369,7 @@ { "toolCall": { "index": 0, - "id": "UPthtEfla", + "id": "K9FVJPqm6", "function": { "name": "bob", "arguments": "{\"question\": \"how are you doing\"}" @@ -267,18 +378,18 @@ } ], "usage": { - "promptTokens": 85, + "promptTokens": 188, "completionTokens": 23, - "totalTokens": 108 + "totalTokens": 211 } } }, { - "time": "2024-06-20T17:10:44.915086-04:00", + "time": "2024-07-03T10:53:08.285881-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -303,10 +414,11 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "toolSubCalls": { - "UPthtEfla": { + "K9FVJPqm6": { "toolID": "testdata/BobAsShell/test.gpt:bob", "input": "{\"question\": \"how are you doing\"}" } @@ -315,13 +427,13 @@ "usage": {} }, { - "time": "2024-06-20T17:10:44.915147-04:00", + "time": "2024-07-03T10:53:08.286454-04:00", "callContext": { - "id": "UPthtEfla", + "id": "K9FVJPqm6", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -344,9 +456,10 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917844", + "parentID": "1720018386", "displayText": "Running bob from testdata/BobAsShell/test.gpt" }, "type": "callStart", @@ -354,13 +467,13 @@ "content": "{\"question\": \"how are you doing\"}" }, { - "time": "2024-06-20T17:10:44.916248-04:00", + "time": "2024-07-03T10:53:08.287602-04:00", "callContext": { - "id": "UPthtEfla", + "id": "K9FVJPqm6", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -383,13 +496,14 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917844", + "parentID": "1720018386", "displayText": "Running bob from testdata/BobAsShell/test.gpt" }, "type": "callChat", - "chatCompletionId": "1718917846", + "chatCompletionId": "1720018389", "usage": {}, "chatRequest": { "model": "", @@ -397,13 +511,13 @@ } }, { - "time": "2024-06-20T17:10:44.92245-04:00", + "time": "2024-07-03T10:53:08.295318-04:00", "callContext": { - "id": "UPthtEfla", + "id": "K9FVJPqm6", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -426,24 +540,25 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917844", + "parentID": "1720018386", "displayText": "Running bob from testdata/BobAsShell/test.gpt" }, "type": "callProgress", - "chatCompletionId": "1718917846", + "chatCompletionId": "1720018389", "usage": {}, "content": "Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\n" }, { - "time": "2024-06-20T17:10:44.922905-04:00", + "time": "2024-07-03T10:53:08.295753-04:00", "callContext": { - "id": "UPthtEfla", + "id": "K9FVJPqm6", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -466,26 +581,27 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917844", + "parentID": "1720018386", "displayText": "Running bob from testdata/BobAsShell/test.gpt" }, "type": "callChat", - "chatCompletionId": "1718917846", + "chatCompletionId": "1720018389", "usage": {}, "chatResponse": { "usage": {} } }, { - "time": "2024-06-20T17:10:44.922998-04:00", + "time": "2024-07-03T10:53:08.29586-04:00", "callContext": { - "id": "UPthtEfla", + "id": "K9FVJPqm6", "tool": { "name": "bob", "description": "I'm Bob, a friendly guy.", - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "arguments": { "properties": { @@ -508,9 +624,10 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null, "toolName": "bob", - "parentID": "1718917844", + "parentID": "1720018386", "displayText": "Running bob from testdata/BobAsShell/test.gpt" }, "type": "callFinish", @@ -518,11 +635,11 @@ "content": "Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\n" }, { - "time": "2024-06-20T17:10:44.92306-04:00", + "time": "2024-07-03T10:53:08.295955-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -547,6 +664,7 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "toolResults": 1, @@ -554,11 +672,11 @@ "usage": {} }, { - "time": "2024-06-20T17:10:45.091313-04:00", + "time": "2024-07-03T10:53:08.467884-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -583,10 +701,11 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callChat", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, "chatRequest": { "model": "mistral-large-2402", @@ -600,7 +719,7 @@ "content": "", "tool_calls": [ { - "id": "UPthtEfla", + "id": "K9FVJPqm6", "type": "function", "function": { "name": "bob", @@ -613,7 +732,7 @@ "role": "tool", "content": "Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\n", "name": "bob", - "tool_call_id": "UPthtEfla" + "tool_call_id": "K9FVJPqm6" } ], "temperature": 0, @@ -638,11 +757,11 @@ } }, { - "time": "2024-06-20T17:10:45.091762-04:00", + "time": "2024-07-03T10:53:08.468218-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -667,19 +786,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, "content": "Waiting for model response..." }, { - "time": "2024-06-20T17:10:45.427766-04:00", + "time": "2024-07-03T10:53:08.755588-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -704,19 +824,19 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", - "usage": {}, - "content": "Bob" + "chatCompletionId": "1720018390", + "usage": {} }, { - "time": "2024-06-20T17:10:45.427886-04:00", + "time": "2024-07-03T10:53:08.756052-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -741,19 +861,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied" + "content": "Bob" }, { - "time": "2024-06-20T17:10:45.427938-04:00", + "time": "2024-07-03T10:53:08.792872-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -778,19 +899,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied," + "content": "Bob said" }, { - "time": "2024-06-20T17:10:45.427998-04:00", + "time": "2024-07-03T10:53:08.843651-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -815,19 +937,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"" + "content": "Bob said," }, { - "time": "2024-06-20T17:10:45.428017-04:00", + "time": "2024-07-03T10:53:08.890513-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -852,19 +975,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"" + "content": "Bob said, \"" }, { - "time": "2024-06-20T17:10:45.428046-04:00", + "time": "2024-07-03T10:53:08.940592-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -889,19 +1013,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks" + "content": "Bob said, \"Thanks" }, { - "time": "2024-06-20T17:10:45.434307-04:00", + "time": "2024-07-03T10:53:08.979075-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -926,19 +1051,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for" + "content": "Bob said, \"Thanks for" }, { - "time": "2024-06-20T17:10:45.462196-04:00", + "time": "2024-07-03T10:53:09.026193-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -963,19 +1089,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking" + "content": "Bob said, \"Thanks for asking" }, { - "time": "2024-06-20T17:10:45.496748-04:00", + "time": "2024-07-03T10:53:09.082478-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1000,19 +1127,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how" + "content": "Bob said, \"Thanks for asking how" }, { - "time": "2024-06-20T17:10:45.516868-04:00", + "time": "2024-07-03T10:53:09.120629-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1037,19 +1165,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are" + "content": "Bob said, \"Thanks for asking how are" }, { - "time": "2024-06-20T17:10:45.545808-04:00", + "time": "2024-07-03T10:53:09.169561-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1074,19 +1203,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you" + "content": "Bob said, \"Thanks for asking how are you" }, { - "time": "2024-06-20T17:10:45.572091-04:00", + "time": "2024-07-03T10:53:09.216601-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1111,19 +1241,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing" + "content": "Bob said, \"Thanks for asking how are you doing" }, { - "time": "2024-06-20T17:10:45.602668-04:00", + "time": "2024-07-03T10:53:09.261113-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1148,19 +1279,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing," + "content": "Bob said, \"Thanks for asking how are you doing," }, { - "time": "2024-06-20T17:10:45.627618-04:00", + "time": "2024-07-03T10:53:09.306429-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1185,19 +1317,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I" + "content": "Bob said, \"Thanks for asking how are you doing, I" }, { - "time": "2024-06-20T17:10:45.659445-04:00", + "time": "2024-07-03T10:53:09.354951-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1222,19 +1355,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'" + "content": "Bob said, \"Thanks for asking how are you doing, I'" }, { - "time": "2024-06-20T17:10:45.682109-04:00", + "time": "2024-07-03T10:53:09.401888-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1259,19 +1393,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'm" + "content": "Bob said, \"Thanks for asking how are you doing, I'm" }, { - "time": "2024-06-20T17:10:45.710817-04:00", + "time": "2024-07-03T10:53:09.448467-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1296,19 +1431,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'm doing" + "content": "Bob said, \"Thanks for asking how are you doing, I'm doing" }, { - "time": "2024-06-20T17:10:45.743363-04:00", + "time": "2024-07-03T10:53:09.493586-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1333,19 +1469,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'm doing great" + "content": "Bob said, \"Thanks for asking how are you doing, I'm doing great" }, { - "time": "2024-06-20T17:10:45.766321-04:00", + "time": "2024-07-03T10:53:09.537745-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1370,19 +1507,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'm doing great fellow" + "content": "Bob said, \"Thanks for asking how are you doing, I'm doing great fellow" }, { - "time": "2024-06-20T17:10:45.801585-04:00", + "time": "2024-07-03T10:53:09.585266-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1407,19 +1545,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'm doing great fellow friendly" + "content": "Bob said, \"Thanks for asking how are you doing, I'm doing great fellow friendly" }, { - "time": "2024-06-20T17:10:46.066262-04:00", + "time": "2024-07-03T10:53:09.63097-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1444,19 +1583,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI" + "content": "Bob said, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI" }, { - "time": "2024-06-20T17:10:46.093598-04:00", + "time": "2024-07-03T10:53:09.678117-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1481,19 +1621,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI tool" + "content": "Bob said, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI tool" }, { - "time": "2024-06-20T17:10:46.118737-04:00", + "time": "2024-07-03T10:53:09.726398-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1518,19 +1659,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\"" + "content": "Bob said, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\"" }, { - "time": "2024-06-20T17:10:46.146712-04:00", + "time": "2024-07-03T10:53:09.773449-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1555,19 +1697,20 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callProgress", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\"" + "content": "Bob said, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\"" }, { - "time": "2024-06-20T17:10:46.146789-04:00", + "time": "2024-07-03T10:53:09.774342-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1592,35 +1735,36 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callChat", - "chatCompletionId": "1718917847", + "chatCompletionId": "1720018390", "usage": { - "promptTokens": 144, + "promptTokens": 247, "completionTokens": 22, - "totalTokens": 166 + "totalTokens": 269 }, "chatResponse": { "role": "assistant", "content": [ { - "text": "Bob replied, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\"" + "text": "Bob said, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\"" } ], "usage": { - "promptTokens": 144, + "promptTokens": 247, "completionTokens": 22, - "totalTokens": 166 + "totalTokens": 269 } } }, { - "time": "2024-06-20T17:10:46.146827-04:00", + "time": "2024-07-03T10:53:09.774431-04:00", "callContext": { - "id": "1718917844", + "id": "1720018386", "tool": { - "modelName": "mistral-large-2402 from https://api.mistral.ai/v1", + "modelName": "mistral-large-2402 from github.com/gptscript-ai/mistral-laplateforme-provider", "internalPrompt": null, "tools": [ "bob" @@ -1645,14 +1789,15 @@ }, "workingDir": "testdata/BobAsShell" }, + "currentAgent": {}, "inputContext": null }, "type": "callFinish", "usage": {}, - "content": "Bob replied, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\"" + "content": "Bob said, \"Thanks for asking how are you doing, I'm doing great fellow friendly AI tool!\"" }, { - "time": "2024-06-20T17:10:46.146844-04:00", + "time": "2024-07-03T10:53:09.774496-04:00", "type": "runFinish", "usage": {} } From 753f5aa57bfc4e9623861ff45313a66a362ef2d2 Mon Sep 17 00:00:00 2001 From: Grant Linville Date: Wed, 3 Jul 2024 11:35:27 -0400 Subject: [PATCH 02/38] enhance: add simple integration test (#606) Signed-off-by: Grant Linville --- .github/workflows/integration.yaml | 40 ++++++++++++++++++++++++++++++ Makefile | 6 ++++- integration/cred_test.go | 13 ++++++++++ integration/helpers.go | 16 ++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/integration.yaml create mode 100644 integration/cred_test.go create mode 100644 integration/helpers.go diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml new file mode 100644 index 00000000..e0b78be2 --- /dev/null +++ b/.github/workflows/integration.yaml @@ -0,0 +1,40 @@ +name: integration + +on: + push: + branches: + - main + paths-ignore: + - docs/** + - tools/** + - README.md + pull_request: + branches: + - main + paths-ignore: + - docs/** + - tools/** + - README.md + +jobs: + integration: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04, windows-latest] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + - uses: actions/setup-go@v5 + with: + cache: false + go-version: "1.22" + - name: Build + if: matrix.os == 'ubuntu-22.04' + run: make build + - name: build-windows + if: matrix.os == 'windows-latest' + run: make build-exe + - name: Run Integration Tests + run: make integration \ No newline at end of file diff --git a/Makefile b/Makefile index 0fed6344..e0d93a1d 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,11 @@ tidy: go mod tidy test: - go test -v ./... + go test -v ./pkg/... + +.PHONY: integration +integration: + go test -v ./integration/... smoke: build smoke: diff --git a/integration/cred_test.go b/integration/cred_test.go new file mode 100644 index 00000000..b92ccd55 --- /dev/null +++ b/integration/cred_test.go @@ -0,0 +1,13 @@ +package integration + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestGPTScriptCredential(t *testing.T) { + out, err := GPTScriptExec("cred") + require.NoError(t, err) + require.Contains(t, out, "CREDENTIAL") +} diff --git a/integration/helpers.go b/integration/helpers.go new file mode 100644 index 00000000..8af581c3 --- /dev/null +++ b/integration/helpers.go @@ -0,0 +1,16 @@ +package integration + +import ( + "os/exec" + "runtime" +) + +func GPTScriptExec(args ...string) (string, error) { + cmd := exec.Command("../bin/gptscript", args...) + if runtime.GOOS == "windows" { + cmd = exec.Command("..\\bin\\gptscript.exe", args...) + } + + out, err := cmd.CombinedOutput() + return string(out), err +} From 1104843ccc7c571568756e8468d7607d546fb467 Mon Sep 17 00:00:00 2001 From: Daishan Peng Date: Wed, 3 Jul 2024 11:29:02 -0700 Subject: [PATCH 03/38] Fix: Try to send interupt to sys.daemon to allow cleanup Signed-off-by: Daishan Peng --- pkg/daemon/daemon.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 58afbf98..bce6ec43 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -5,6 +5,7 @@ import ( "io" "os" "os/exec" + "runtime" ) func SysDaemon() error { @@ -19,5 +20,11 @@ func SysDaemon() error { cmd := exec.CommandContext(ctx, os.Args[2], os.Args[3:]...) cmd.Stderr = os.Stderr cmd.Stdout = os.Stdout + cmd.Cancel = func() error { + if runtime.GOOS == "windows" { + return cmd.Process.Kill() + } + return cmd.Process.Signal(os.Interrupt) + } return cmd.Run() } From faecb7c65cda2c5d093724932e4d5d4c725567fd Mon Sep 17 00:00:00 2001 From: Daishan Peng Date: Wed, 3 Jul 2024 12:12:22 -0700 Subject: [PATCH 04/38] Revert "Fix: Try to send interupt to sys.daemon to allow cleanup" This reverts commit 1104843ccc7c571568756e8468d7607d546fb467. --- pkg/daemon/daemon.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index bce6ec43..58afbf98 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -5,7 +5,6 @@ import ( "io" "os" "os/exec" - "runtime" ) func SysDaemon() error { @@ -20,11 +19,5 @@ func SysDaemon() error { cmd := exec.CommandContext(ctx, os.Args[2], os.Args[3:]...) cmd.Stderr = os.Stderr cmd.Stdout = os.Stdout - cmd.Cancel = func() error { - if runtime.GOOS == "windows" { - return cmd.Process.Kill() - } - return cmd.Process.Signal(os.Interrupt) - } return cmd.Run() } From e4d174b9afb232bac243a7eea7be95b28b226a28 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Wed, 3 Jul 2024 16:33:49 -0400 Subject: [PATCH 05/38] chore: fix Go version to 1.22.4 There is a change in 1.22.5 that breaks sys.daemon on Windows. Fixing this version for now until we address this issue. Signed-off-by: Donnie Adams --- .github/workflows/main.yaml | 4 +++- .github/workflows/release.yaml | 4 +++- go.mod | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6b469c39..6ea47e8f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -26,7 +26,9 @@ jobs: uses: actions/setup-go@v5 with: cache: false - go-version: "1.22" + # This can't be upgraded until the issue with sys.daemon on Windows is resolved + # After the issue is resolved, this can be set to 1.22 + go-version: "1.22.4" - name: Run GoReleaser uses: goreleaser/goreleaser-action@v4 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 18871150..883a479d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -27,7 +27,9 @@ jobs: uses: actions/setup-go@v5 with: cache: false - go-version: "1.22" + # This can't be upgraded until the issue with sys.daemon on Windows is resolved + # After the issue is resolved, this can be set to 1.22 + go-version: "1.22.4" - name: Run GoReleaser uses: goreleaser/goreleaser-action@v4 with: diff --git a/go.mod b/go.mod index 36106b3f..fe1b3fa6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,7 @@ module github.com/gptscript-ai/gptscript -go 1.22.3 +// This can't be upgraded until the issue with sys.daemon on Windows is resolved +go 1.22.4 require ( github.com/AlecAivazis/survey/v2 v2.3.7 From b1a31ac53223ccca819cea9e060f4075df8bb115 Mon Sep 17 00:00:00 2001 From: Atulpriya Sharma Date: Thu, 4 Jul 2024 16:03:05 +0530 Subject: [PATCH 06/38] Add GPTReview Example --- examples/gptreview.gpt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/gptreview.gpt diff --git a/examples/gptreview.gpt b/examples/gptreview.gpt new file mode 100644 index 00000000..2176c89a --- /dev/null +++ b/examples/gptreview.gpt @@ -0,0 +1,28 @@ + Name: Code Reviewer + Description: A tool to help you perform code review of open PRs + Context: learn-gh + Tools: sys.exec, sys.http.html2text?, sys.find, sys.read, sys.write + Args: PR_URL: The GitHub PR_URL + chat:true + + You have the gh cli available to you. Use it to perform code review for a pr. + + Perform the following steps in order: + 1. Ask the user for the ($PR_URL) and save it. + 2. Identify the files changed in the pull request ($PR_URL) using the pr number and perform a diff. + 1. Analyze the complete code of each identified file and perform a detailed line by line code review. + 2. Repeat the process for each changed file in the pr. + 3. Share your review comments separately for each file. + 4. In a new line write "Code: Approved" or "Code: Require Changes" based on the review. + --- + Name: learn-gh + Description: A tool to help you learn gh cli + + #!/usr/bin/env bash + + echo "The following is the help text for the gh cli and some of its sub-commands. Use these when figuring out how to construct new commands. Note that the --search flag is used for filtering and sorting as well; there is no dedicated --sort flag." + gh --help + gh repo --help + gh pr --help + gh pr checkout --help + gh pr diff --help \ No newline at end of file From e7193ad8872d8b1dc49d7b972f94dcfb84a7d63f Mon Sep 17 00:00:00 2001 From: Nick Hale <4175918+njhale@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:57:52 -0400 Subject: [PATCH 07/38] Revert "Revert "Fix: Try to send interupt to sys.daemon to allow cleanup"" --- pkg/daemon/daemon.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 58afbf98..bce6ec43 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -5,6 +5,7 @@ import ( "io" "os" "os/exec" + "runtime" ) func SysDaemon() error { @@ -19,5 +20,11 @@ func SysDaemon() error { cmd := exec.CommandContext(ctx, os.Args[2], os.Args[3:]...) cmd.Stderr = os.Stderr cmd.Stdout = os.Stdout + cmd.Cancel = func() error { + if runtime.GOOS == "windows" { + return cmd.Process.Kill() + } + return cmd.Process.Signal(os.Interrupt) + } return cmd.Run() } From b6442cdd23770049e7031ec62d14c7dd20321419 Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Tue, 9 Jul 2024 16:05:31 -0700 Subject: [PATCH 08/38] chore: remove references to tap in favor of homebrew-core Signed-off-by: Taylor Price --- .goreleaser.yml | 13 ------------- README.md | 2 +- docs/docs/01-overview.md | 2 +- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index b04bb8ea..d76c2e2e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -50,16 +50,3 @@ release: owner: gptscript-ai name: gptscript prerelease: auto - -brews: - - description: "GPTScript CLI" - install: | - bin.install "gptscript" - generate_completions_from_executable(bin/"gptscript", "completion", shells: [:bash, :zsh, :fish]) - homepage: "https://github.com/gptscript-ai/gptscript" - skip_upload: false - folder: "Formula" - repository: - owner: gptscript-ai - name: homebrew-tap - token: "{{ .Env.GH_PROJECT_TOKEN }}" diff --git a/README.md b/README.md index 65cc37e4..1da91c90 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Here are some sample use cases of GPTScript: ### Getting started MacOS and Linux (Homebrew): ``` -brew install gptscript-ai/tap/gptscript +brew install gptscript gptscript github.com/gptscript-ai/llm-basics-demo ``` diff --git a/docs/docs/01-overview.md b/docs/docs/01-overview.md index a3e71857..5ba2e7d1 100644 --- a/docs/docs/01-overview.md +++ b/docs/docs/01-overview.md @@ -22,7 +22,7 @@ Here are some sample use cases of GPTScript: ```shell - brew install gptscript-ai/tap/gptscript + brew install gptscript gptscript github.com/gptscript-ai/llm-basics-demo ``` From 476f4ae22ecaa6cdd101b12f74fce7b47cc46cc4 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 10 Jul 2024 16:52:09 -0700 Subject: [PATCH 09/38] chore: add support for tools with only a single agent line and nothing else --- pkg/engine/engine.go | 5 + pkg/input/input.go | 6 +- pkg/parser/parser.go | 1 + pkg/tests/runner_test.go | 20 +++ .../testdata/TestAgentOnly/call1-resp.golden | 16 ++ pkg/tests/testdata/TestAgentOnly/call1.golden | 42 +++++ .../testdata/TestAgentOnly/call2-resp.golden | 9 + pkg/tests/testdata/TestAgentOnly/call2.golden | 57 ++++++ pkg/tests/testdata/TestAgentOnly/step1.golden | 168 ++++++++++++++++++ pkg/tests/testdata/TestAgentOnly/test.gpt | 20 +++ pkg/types/tool.go | 4 + 11 files changed, 346 insertions(+), 2 deletions(-) create mode 100644 pkg/tests/testdata/TestAgentOnly/call1-resp.golden create mode 100644 pkg/tests/testdata/TestAgentOnly/call1.golden create mode 100644 pkg/tests/testdata/TestAgentOnly/call2-resp.golden create mode 100644 pkg/tests/testdata/TestAgentOnly/call2.golden create mode 100644 pkg/tests/testdata/TestAgentOnly/step1.golden create mode 100644 pkg/tests/testdata/TestAgentOnly/test.gpt diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index b0a6e4eb..43c1da99 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -207,6 +207,11 @@ func NewContext(ctx context.Context, prg *types.Program, input string) (Context, } callCtx.AgentGroup = agentGroup + + if callCtx.Tool.IsAgentsOnly() && len(callCtx.AgentGroup) > 0 { + callCtx.Tool = callCtx.Program.ToolSet[callCtx.AgentGroup[0].ToolID] + } + return callCtx, nil } diff --git a/pkg/input/input.go b/pkg/input/input.go index 0037fa5e..3d480431 100644 --- a/pkg/input/input.go +++ b/pkg/input/input.go @@ -3,10 +3,12 @@ package input import ( "fmt" "io" + "io/fs" "os" "path/filepath" "strings" + "github.com/gptscript-ai/gptscript/internal" "github.com/gptscript-ai/gptscript/pkg/loader" "github.com/gptscript-ai/gptscript/pkg/types" ) @@ -33,7 +35,7 @@ func FromFile(file string) (string, error) { } return string(data), nil } else if file != "" { - if s, err := os.Stat(file); err == nil && s.IsDir() { + if s, err := fs.Stat(internal.FS, file); err == nil && s.IsDir() { for _, ext := range types.DefaultFiles { if _, err := os.Stat(filepath.Join(file, ext)); err == nil { file = filepath.Join(file, ext) @@ -42,7 +44,7 @@ func FromFile(file string) (string, error) { } } log.Debugf("reading file %s", file) - data, err := os.ReadFile(file) + data, err := fs.ReadFile(internal.FS, file) if err != nil { return "", fmt.Errorf("reading %s: %w", file, err) } diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index b998320b..22cd5e9e 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -199,6 +199,7 @@ func (c *context) finish(tools *[]Node) { len(c.tool.GlobalTools) > 0 || len(c.tool.ExportInputFilters) > 0 || len(c.tool.ExportOutputFilters) > 0 || + len(c.tool.Agents) > 0 || c.tool.Chat { *tools = append(*tools, Node{ ToolNode: &ToolNode{ diff --git a/pkg/tests/runner_test.go b/pkg/tests/runner_test.go index 6efe4a11..0b75c8a2 100644 --- a/pkg/tests/runner_test.go +++ b/pkg/tests/runner_test.go @@ -800,6 +800,26 @@ func TestExport(t *testing.T) { assert.Equal(t, "TEST RESULT CALL: 3", x) } +func TestAgentOnly(t *testing.T) { + r := tester.NewRunner(t) + + prg, err := r.Load("") + require.NoError(t, err) + + r.RespondWith(tester.Result{ + Func: types.CompletionFunctionCall{ + Name: "agent2", + Arguments: "Agent 2 input", + }, + }) + + resp, err := r.Chat(context.Background(), nil, prg, nil, "Input 1") + require.NoError(t, err) + r.AssertResponded(t) + assert.False(t, resp.Done) + autogold.Expect("TEST RESULT CALL: 2").Equal(t, resp.Content) + autogold.ExpectFile(t, toJSONString(t, resp), autogold.Name(t.Name()+"/step1")) +} func TestAgents(t *testing.T) { r := tester.NewRunner(t) diff --git a/pkg/tests/testdata/TestAgentOnly/call1-resp.golden b/pkg/tests/testdata/TestAgentOnly/call1-resp.golden new file mode 100644 index 00000000..ea865122 --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/call1-resp.golden @@ -0,0 +1,16 @@ +`{ + "role": "assistant", + "content": [ + { + "toolCall": { + "index": 0, + "id": "call_1", + "function": { + "name": "agent2", + "arguments": "Agent 2 input" + } + } + } + ], + "usage": {} +}` diff --git a/pkg/tests/testdata/TestAgentOnly/call1.golden b/pkg/tests/testdata/TestAgentOnly/call1.golden new file mode 100644 index 00000000..b63c6fd3 --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/call1.golden @@ -0,0 +1,42 @@ +`{ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent2", + "name": "agent2", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + } + ], + "messages": [ + { + "role": "system", + "content": [ + { + "text": "I am agent1" + } + ], + "usage": {} + }, + { + "role": "user", + "content": [ + { + "text": "Input 1" + } + ], + "usage": {} + } + ], + "chat": true +}` diff --git a/pkg/tests/testdata/TestAgentOnly/call2-resp.golden b/pkg/tests/testdata/TestAgentOnly/call2-resp.golden new file mode 100644 index 00000000..997ca1b9 --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/call2-resp.golden @@ -0,0 +1,9 @@ +`{ + "role": "assistant", + "content": [ + { + "text": "TEST RESULT CALL: 2" + } + ], + "usage": {} +}` diff --git a/pkg/tests/testdata/TestAgentOnly/call2.golden b/pkg/tests/testdata/TestAgentOnly/call2.golden new file mode 100644 index 00000000..82f95523 --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/call2.golden @@ -0,0 +1,57 @@ +`{ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent1", + "name": "agent1", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + }, + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent3", + "name": "agent3", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + } + ], + "messages": [ + { + "role": "system", + "content": [ + { + "text": "I am agent2" + } + ], + "usage": {} + }, + { + "role": "user", + "content": [ + { + "text": "Agent 2 input" + } + ], + "usage": {} + } + ], + "chat": true +}` diff --git a/pkg/tests/testdata/TestAgentOnly/step1.golden b/pkg/tests/testdata/TestAgentOnly/step1.golden new file mode 100644 index 00000000..662dbf04 --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/step1.golden @@ -0,0 +1,168 @@ +`{ + "done": false, + "content": "TEST RESULT CALL: 2", + "toolID": "testdata/TestAgentOnly/test.gpt:agent2", + "state": { + "continuation": { + "state": { + "input": "Input 1", + "completion": { + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent2", + "name": "agent2", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + } + ], + "messages": [ + { + "role": "system", + "content": [ + { + "text": "I am agent1" + } + ], + "usage": {} + }, + { + "role": "user", + "content": [ + { + "text": "Input 1" + } + ], + "usage": {} + }, + { + "role": "assistant", + "content": [ + { + "toolCall": { + "index": 0, + "id": "call_1", + "function": { + "name": "agent2", + "arguments": "Agent 2 input" + } + } + } + ], + "usage": {} + } + ], + "chat": true + }, + "pending": { + "call_1": { + "index": 0, + "id": "call_1", + "function": { + "name": "agent2", + "arguments": "Agent 2 input" + } + } + } + }, + "calls": { + "call_1": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent2", + "input": "Agent 2 input" + } + } + }, + "subCalls": [ + { + "toolId": "testdata/TestAgentOnly/test.gpt:agent2", + "callId": "call_1", + "state": { + "continuation": { + "state": { + "input": "Agent 2 input", + "completion": { + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent1", + "name": "agent1", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + }, + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent3", + "name": "agent3", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + } + ], + "messages": [ + { + "role": "system", + "content": [ + { + "text": "I am agent2" + } + ], + "usage": {} + }, + { + "role": "user", + "content": [ + { + "text": "Agent 2 input" + } + ], + "usage": {} + }, + { + "role": "assistant", + "content": [ + { + "text": "TEST RESULT CALL: 2" + } + ], + "usage": {} + } + ], + "chat": true + } + }, + "result": "TEST RESULT CALL: 2" + }, + "continuationToolID": "testdata/TestAgentOnly/test.gpt:agent2" + } + } + ], + "subCallID": "call_1" + } +}` diff --git a/pkg/tests/testdata/TestAgentOnly/test.gpt b/pkg/tests/testdata/TestAgentOnly/test.gpt new file mode 100644 index 00000000..f2ae9f9e --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/test.gpt @@ -0,0 +1,20 @@ +agents: agent1, agent2 + +---- +name: agent1 +chat: true + +I am agent1 + +---- +name: agent2 +chat: true +agents: agent3 + +I am agent2 + +--- +name: agent3 +chat: true + +I am agent3 \ No newline at end of file diff --git a/pkg/types/tool.go b/pkg/types/tool.go index b0af5183..e4b3424a 100644 --- a/pkg/types/tool.go +++ b/pkg/types/tool.go @@ -763,6 +763,10 @@ func (t Tool) IsOpenAPI() bool { return strings.HasPrefix(t.Instructions, OpenAPIPrefix) } +func (t Tool) IsAgentsOnly() bool { + return t.IsNoop() && len(t.Context) == 0 +} + func (t Tool) IsEcho() bool { return strings.HasPrefix(t.Instructions, EchoPrefix) } From f773577c977feb3da163dbac7f1921df25211aa6 Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Thu, 11 Jul 2024 10:37:26 -0700 Subject: [PATCH 10/38] chore: maintain homebrew tap as well as homebrew core formulas Signed-off-by: Taylor Price --- .github/workflows/release.yaml | 10 ++ .goreleaser.yml | 7 +- docs/docs/01-overview.md | 11 ++ examples/gptreview.gpt | 28 +++ pkg/engine/engine.go | 5 + pkg/input/input.go | 6 +- pkg/parser/parser.go | 1 + pkg/tests/runner_test.go | 20 +++ .../testdata/TestAgentOnly/call1-resp.golden | 16 ++ pkg/tests/testdata/TestAgentOnly/call1.golden | 42 +++++ .../testdata/TestAgentOnly/call2-resp.golden | 9 + pkg/tests/testdata/TestAgentOnly/call2.golden | 57 ++++++ pkg/tests/testdata/TestAgentOnly/step1.golden | 168 ++++++++++++++++++ pkg/tests/testdata/TestAgentOnly/test.gpt | 20 +++ pkg/types/tool.go | 4 + 15 files changed, 399 insertions(+), 5 deletions(-) create mode 100644 examples/gptreview.gpt create mode 100644 pkg/tests/testdata/TestAgentOnly/call1-resp.golden create mode 100644 pkg/tests/testdata/TestAgentOnly/call1.golden create mode 100644 pkg/tests/testdata/TestAgentOnly/call2-resp.golden create mode 100644 pkg/tests/testdata/TestAgentOnly/call2.golden create mode 100644 pkg/tests/testdata/TestAgentOnly/step1.golden create mode 100644 pkg/tests/testdata/TestAgentOnly/test.gpt diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 883a479d..d09608e7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -40,6 +40,16 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_PROJECT_TOKEN: ${{ secrets.GH_PROJECT_TOKEN }} GORELEASER_CURRENT_TAG: ${{ github.ref_name }} + homebrew-release: + needs: release-tag + if: "! contains(github.ref_name, '-rc')" + runs-on: ubuntu-latest + steps: + - name: Update Homebrew formula + uses: dawidd6/action-homebrew-bump-formula@v3 + with: + token: ${{secrets.BREW_GH_TOKEN}} + formula: gptscript winget-release: needs: release-tag if: "! contains(github.ref_name, '-rc')" diff --git a/.goreleaser.yml b/.goreleaser.yml index b04bb8ea..3f767be0 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -52,13 +52,14 @@ release: prerelease: auto brews: - - description: "GPTScript CLI" + - name: gptscript + description: "GPTScript CLI" install: | bin.install "gptscript" - generate_completions_from_executable(bin/"gptscript", "completion", shells: [:bash, :zsh, :fish]) + generate_completions_from_executable(bin/"gptscript", "completion") homepage: "https://github.com/gptscript-ai/gptscript" skip_upload: false - folder: "Formula" + directory: "Formula" repository: owner: gptscript-ai name: homebrew-tap diff --git a/docs/docs/01-overview.md b/docs/docs/01-overview.md index a3e71857..b3d5b9fc 100644 --- a/docs/docs/01-overview.md +++ b/docs/docs/01-overview.md @@ -21,10 +21,21 @@ Here are some sample use cases of GPTScript: + ## Homebrew Tap +___ ```shell brew install gptscript-ai/tap/gptscript gptscript github.com/gptscript-ai/llm-basics-demo ``` + ## Homebrew +___ +:::warning +The [formula in homebrew-core](https://github.com/Homebrew/homebrew-core/blob/master/Formula/g/gptscript.rb) might be slightly outdated. Use our homebrew tap to always get the latest updates. +::: + ``` + brew install gptscript + gptscript github.com/gptscript-ai/llm-basics-demo + ``` ```shell diff --git a/examples/gptreview.gpt b/examples/gptreview.gpt new file mode 100644 index 00000000..2176c89a --- /dev/null +++ b/examples/gptreview.gpt @@ -0,0 +1,28 @@ + Name: Code Reviewer + Description: A tool to help you perform code review of open PRs + Context: learn-gh + Tools: sys.exec, sys.http.html2text?, sys.find, sys.read, sys.write + Args: PR_URL: The GitHub PR_URL + chat:true + + You have the gh cli available to you. Use it to perform code review for a pr. + + Perform the following steps in order: + 1. Ask the user for the ($PR_URL) and save it. + 2. Identify the files changed in the pull request ($PR_URL) using the pr number and perform a diff. + 1. Analyze the complete code of each identified file and perform a detailed line by line code review. + 2. Repeat the process for each changed file in the pr. + 3. Share your review comments separately for each file. + 4. In a new line write "Code: Approved" or "Code: Require Changes" based on the review. + --- + Name: learn-gh + Description: A tool to help you learn gh cli + + #!/usr/bin/env bash + + echo "The following is the help text for the gh cli and some of its sub-commands. Use these when figuring out how to construct new commands. Note that the --search flag is used for filtering and sorting as well; there is no dedicated --sort flag." + gh --help + gh repo --help + gh pr --help + gh pr checkout --help + gh pr diff --help \ No newline at end of file diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index b0a6e4eb..43c1da99 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -207,6 +207,11 @@ func NewContext(ctx context.Context, prg *types.Program, input string) (Context, } callCtx.AgentGroup = agentGroup + + if callCtx.Tool.IsAgentsOnly() && len(callCtx.AgentGroup) > 0 { + callCtx.Tool = callCtx.Program.ToolSet[callCtx.AgentGroup[0].ToolID] + } + return callCtx, nil } diff --git a/pkg/input/input.go b/pkg/input/input.go index 0037fa5e..3d480431 100644 --- a/pkg/input/input.go +++ b/pkg/input/input.go @@ -3,10 +3,12 @@ package input import ( "fmt" "io" + "io/fs" "os" "path/filepath" "strings" + "github.com/gptscript-ai/gptscript/internal" "github.com/gptscript-ai/gptscript/pkg/loader" "github.com/gptscript-ai/gptscript/pkg/types" ) @@ -33,7 +35,7 @@ func FromFile(file string) (string, error) { } return string(data), nil } else if file != "" { - if s, err := os.Stat(file); err == nil && s.IsDir() { + if s, err := fs.Stat(internal.FS, file); err == nil && s.IsDir() { for _, ext := range types.DefaultFiles { if _, err := os.Stat(filepath.Join(file, ext)); err == nil { file = filepath.Join(file, ext) @@ -42,7 +44,7 @@ func FromFile(file string) (string, error) { } } log.Debugf("reading file %s", file) - data, err := os.ReadFile(file) + data, err := fs.ReadFile(internal.FS, file) if err != nil { return "", fmt.Errorf("reading %s: %w", file, err) } diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index b998320b..22cd5e9e 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -199,6 +199,7 @@ func (c *context) finish(tools *[]Node) { len(c.tool.GlobalTools) > 0 || len(c.tool.ExportInputFilters) > 0 || len(c.tool.ExportOutputFilters) > 0 || + len(c.tool.Agents) > 0 || c.tool.Chat { *tools = append(*tools, Node{ ToolNode: &ToolNode{ diff --git a/pkg/tests/runner_test.go b/pkg/tests/runner_test.go index 6efe4a11..0b75c8a2 100644 --- a/pkg/tests/runner_test.go +++ b/pkg/tests/runner_test.go @@ -800,6 +800,26 @@ func TestExport(t *testing.T) { assert.Equal(t, "TEST RESULT CALL: 3", x) } +func TestAgentOnly(t *testing.T) { + r := tester.NewRunner(t) + + prg, err := r.Load("") + require.NoError(t, err) + + r.RespondWith(tester.Result{ + Func: types.CompletionFunctionCall{ + Name: "agent2", + Arguments: "Agent 2 input", + }, + }) + + resp, err := r.Chat(context.Background(), nil, prg, nil, "Input 1") + require.NoError(t, err) + r.AssertResponded(t) + assert.False(t, resp.Done) + autogold.Expect("TEST RESULT CALL: 2").Equal(t, resp.Content) + autogold.ExpectFile(t, toJSONString(t, resp), autogold.Name(t.Name()+"/step1")) +} func TestAgents(t *testing.T) { r := tester.NewRunner(t) diff --git a/pkg/tests/testdata/TestAgentOnly/call1-resp.golden b/pkg/tests/testdata/TestAgentOnly/call1-resp.golden new file mode 100644 index 00000000..ea865122 --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/call1-resp.golden @@ -0,0 +1,16 @@ +`{ + "role": "assistant", + "content": [ + { + "toolCall": { + "index": 0, + "id": "call_1", + "function": { + "name": "agent2", + "arguments": "Agent 2 input" + } + } + } + ], + "usage": {} +}` diff --git a/pkg/tests/testdata/TestAgentOnly/call1.golden b/pkg/tests/testdata/TestAgentOnly/call1.golden new file mode 100644 index 00000000..b63c6fd3 --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/call1.golden @@ -0,0 +1,42 @@ +`{ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent2", + "name": "agent2", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + } + ], + "messages": [ + { + "role": "system", + "content": [ + { + "text": "I am agent1" + } + ], + "usage": {} + }, + { + "role": "user", + "content": [ + { + "text": "Input 1" + } + ], + "usage": {} + } + ], + "chat": true +}` diff --git a/pkg/tests/testdata/TestAgentOnly/call2-resp.golden b/pkg/tests/testdata/TestAgentOnly/call2-resp.golden new file mode 100644 index 00000000..997ca1b9 --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/call2-resp.golden @@ -0,0 +1,9 @@ +`{ + "role": "assistant", + "content": [ + { + "text": "TEST RESULT CALL: 2" + } + ], + "usage": {} +}` diff --git a/pkg/tests/testdata/TestAgentOnly/call2.golden b/pkg/tests/testdata/TestAgentOnly/call2.golden new file mode 100644 index 00000000..82f95523 --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/call2.golden @@ -0,0 +1,57 @@ +`{ + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent1", + "name": "agent1", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + }, + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent3", + "name": "agent3", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + } + ], + "messages": [ + { + "role": "system", + "content": [ + { + "text": "I am agent2" + } + ], + "usage": {} + }, + { + "role": "user", + "content": [ + { + "text": "Agent 2 input" + } + ], + "usage": {} + } + ], + "chat": true +}` diff --git a/pkg/tests/testdata/TestAgentOnly/step1.golden b/pkg/tests/testdata/TestAgentOnly/step1.golden new file mode 100644 index 00000000..662dbf04 --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/step1.golden @@ -0,0 +1,168 @@ +`{ + "done": false, + "content": "TEST RESULT CALL: 2", + "toolID": "testdata/TestAgentOnly/test.gpt:agent2", + "state": { + "continuation": { + "state": { + "input": "Input 1", + "completion": { + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent2", + "name": "agent2", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + } + ], + "messages": [ + { + "role": "system", + "content": [ + { + "text": "I am agent1" + } + ], + "usage": {} + }, + { + "role": "user", + "content": [ + { + "text": "Input 1" + } + ], + "usage": {} + }, + { + "role": "assistant", + "content": [ + { + "toolCall": { + "index": 0, + "id": "call_1", + "function": { + "name": "agent2", + "arguments": "Agent 2 input" + } + } + } + ], + "usage": {} + } + ], + "chat": true + }, + "pending": { + "call_1": { + "index": 0, + "id": "call_1", + "function": { + "name": "agent2", + "arguments": "Agent 2 input" + } + } + } + }, + "calls": { + "call_1": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent2", + "input": "Agent 2 input" + } + } + }, + "subCalls": [ + { + "toolId": "testdata/TestAgentOnly/test.gpt:agent2", + "callId": "call_1", + "state": { + "continuation": { + "state": { + "input": "Agent 2 input", + "completion": { + "model": "gpt-4o", + "internalSystemPrompt": false, + "tools": [ + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent1", + "name": "agent1", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + }, + { + "function": { + "toolID": "testdata/TestAgentOnly/test.gpt:agent3", + "name": "agent3", + "parameters": { + "properties": { + "defaultPromptParameter": { + "description": "Prompt to send to the assistant. This may be an instruction or question.", + "type": "string" + } + }, + "type": "object" + } + } + } + ], + "messages": [ + { + "role": "system", + "content": [ + { + "text": "I am agent2" + } + ], + "usage": {} + }, + { + "role": "user", + "content": [ + { + "text": "Agent 2 input" + } + ], + "usage": {} + }, + { + "role": "assistant", + "content": [ + { + "text": "TEST RESULT CALL: 2" + } + ], + "usage": {} + } + ], + "chat": true + } + }, + "result": "TEST RESULT CALL: 2" + }, + "continuationToolID": "testdata/TestAgentOnly/test.gpt:agent2" + } + } + ], + "subCallID": "call_1" + } +}` diff --git a/pkg/tests/testdata/TestAgentOnly/test.gpt b/pkg/tests/testdata/TestAgentOnly/test.gpt new file mode 100644 index 00000000..f2ae9f9e --- /dev/null +++ b/pkg/tests/testdata/TestAgentOnly/test.gpt @@ -0,0 +1,20 @@ +agents: agent1, agent2 + +---- +name: agent1 +chat: true + +I am agent1 + +---- +name: agent2 +chat: true +agents: agent3 + +I am agent2 + +--- +name: agent3 +chat: true + +I am agent3 \ No newline at end of file diff --git a/pkg/types/tool.go b/pkg/types/tool.go index b0af5183..e4b3424a 100644 --- a/pkg/types/tool.go +++ b/pkg/types/tool.go @@ -763,6 +763,10 @@ func (t Tool) IsOpenAPI() bool { return strings.HasPrefix(t.Instructions, OpenAPIPrefix) } +func (t Tool) IsAgentsOnly() bool { + return t.IsNoop() && len(t.Context) == 0 +} + func (t Tool) IsEcho() bool { return strings.HasPrefix(t.Instructions, EchoPrefix) } From 1f2d7c7c56cdd88c20b5275932120b106747e28a Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Thu, 11 Jul 2024 11:01:46 -0700 Subject: [PATCH 11/38] chore: update goreleaser Signed-off-by: Taylor Price --- .github/workflows/release.yaml | 2 +- .goreleaser.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d09608e7..10b852cc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -34,7 +34,7 @@ jobs: uses: goreleaser/goreleaser-action@v4 with: distribution: goreleaser - version: v1.23.0 + version: v2.0.1 args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 3f767be0..6695c68a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,3 +1,4 @@ +version: 2 dist: releases snapshot: name_template: '{{ trimprefix .Summary "v" }}' From 5d7cde648dde0da1ca9d0b6a20c77fa9bcf4dcb0 Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Thu, 11 Jul 2024 11:03:21 -0700 Subject: [PATCH 12/38] chore: update goreleaser action Signed-off-by: Taylor Price --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 10b852cc..edc8b2ac 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,7 +31,7 @@ jobs: # After the issue is resolved, this can be set to 1.22 go-version: "1.22.4" - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser version: v2.0.1 From d3cf668b59b536ccd8eb19449416ecddf1c9aa2b Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Thu, 11 Jul 2024 11:31:56 -0700 Subject: [PATCH 13/38] fix: replace user PAT with bot PAT Signed-off-by: Taylor Price --- .github/workflows/main.yaml | 2 +- .github/workflows/release.yaml | 2 +- .goreleaser.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6ea47e8f..f916fdab 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -37,7 +37,7 @@ jobs: args: release --clean --snapshot env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_PROJECT_TOKEN: ${{ secrets.GH_PROJECT_TOKEN }} + TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} - name: Upload to S3 uses: jakejarvis/s3-sync-action@v0.5.1 env: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index edc8b2ac..bf38499d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -38,7 +38,7 @@ jobs: args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_PROJECT_TOKEN: ${{ secrets.GH_PROJECT_TOKEN }} + TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} GORELEASER_CURRENT_TAG: ${{ github.ref_name }} homebrew-release: needs: release-tag diff --git a/.goreleaser.yml b/.goreleaser.yml index 6695c68a..522e3b22 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -64,4 +64,4 @@ brews: repository: owner: gptscript-ai name: homebrew-tap - token: "{{ .Env.GH_PROJECT_TOKEN }}" + token: "{{ .Env.TAP_GITHUB_TOKEN }}" From 0c73f4b85ba75350e5a6fcd88952315bab81dc60 Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Thu, 11 Jul 2024 12:19:07 -0700 Subject: [PATCH 14/38] fix: update goreleaser action and version for main workflow Signed-off-by: Taylor Price --- .github/workflows/main.yaml | 4 ++-- .github/workflows/release.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f916fdab..ae26c52c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -30,10 +30,10 @@ jobs: # After the issue is resolved, this can be set to 1.22 go-version: "1.22.4" - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser - version: v1.23.0 + version: "~> v2" args: release --clean --snapshot env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bf38499d..b34c2fad 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -34,7 +34,7 @@ jobs: uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser - version: v2.0.1 + version: "~> v2" args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 75bd379f453cd3a5ba8ef5b23022edda6f37139f Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 12 Jul 2024 22:05:27 -0700 Subject: [PATCH 15/38] chore: add location option to loading scripts --- pkg/loader/loader.go | 18 ++++++++++++++++-- pkg/sdkserver/routes.go | 2 +- pkg/sdkserver/run.go | 8 ++++++++ pkg/sdkserver/types.go | 1 + 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pkg/loader/loader.go b/pkg/loader/loader.go index c12f976f..f60f09a1 100644 --- a/pkg/loader/loader.go +++ b/pkg/loader/loader.go @@ -373,12 +373,20 @@ func ProgramFromSource(ctx context.Context, content, subToolName string, opts .. } opt := complete(opts...) + var locationPath, locationName string + if opt.Location != "" { + locationPath = path.Dir(opt.Location) + locationName = path.Base(opt.Location) + } + prg := types.Program{ ToolSet: types.ToolSet{}, } tools, err := readTool(ctx, opt.Cache, &prg, &source{ Content: []byte(content), - Location: "inline", + Path: locationPath, + Name: locationName, + Location: opt.Location, }, subToolName) if err != nil { return types.Program{}, err @@ -388,12 +396,18 @@ func ProgramFromSource(ctx context.Context, content, subToolName string, opts .. } type Options struct { - Cache *cache.Client + Cache *cache.Client + Location string } func complete(opts ...Options) (result Options) { for _, opt := range opts { result.Cache = types.FirstSet(opt.Cache, result.Cache) + result.Location = types.FirstSet(opt.Location, result.Location) + } + + if result.Location == "" { + result.Location = "inline" } return diff --git a/pkg/sdkserver/routes.go b/pkg/sdkserver/routes.go index c16b4429..e17a2d1a 100644 --- a/pkg/sdkserver/routes.go +++ b/pkg/sdkserver/routes.go @@ -183,7 +183,7 @@ func (s *server) execHandler(w http.ResponseWriter, r *http.Request) { logger.Debugf("executing tool: %+v", reqObject) var ( def fmt.Stringer = &reqObject.ToolDefs - programLoader loaderFunc = loader.ProgramFromSource + programLoader = loaderWithLocation(loader.ProgramFromSource, reqObject.Location) ) if reqObject.Content != "" { def = &reqObject.content diff --git a/pkg/sdkserver/run.go b/pkg/sdkserver/run.go index dc155557..0d055614 100644 --- a/pkg/sdkserver/run.go +++ b/pkg/sdkserver/run.go @@ -16,6 +16,14 @@ import ( type loaderFunc func(context.Context, string, string, ...loader.Options) (types.Program, error) +func loaderWithLocation(f loaderFunc, loc string) loaderFunc { + return func(ctx context.Context, s string, s2 string, options ...loader.Options) (types.Program, error) { + return f(ctx, s, s2, append(options, loader.Options{ + Location: loc, + })...) + } +} + func (s *server) execAndStream(ctx context.Context, programLoader loaderFunc, logger mvl.Logger, w http.ResponseWriter, opts gptscript.Options, chatState, input, subTool string, toolDef fmt.Stringer) { g, err := gptscript.New(ctx, s.gptscriptOpts, opts) if err != nil { diff --git a/pkg/sdkserver/types.go b/pkg/sdkserver/types.go index 6f940c8b..478c6565 100644 --- a/pkg/sdkserver/types.go +++ b/pkg/sdkserver/types.go @@ -61,6 +61,7 @@ type toolOrFileRequest struct { CredentialContext string `json:"credentialContext"` CredentialOverrides []string `json:"credentialOverrides"` Confirm bool `json:"confirm"` + Location string `json:"location,omitempty"` } type content struct { From 2676b35eff90ea05599c828e10bd9b4f7720668a Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 12 Jul 2024 22:21:47 -0700 Subject: [PATCH 16/38] bug: fix relative references when defaulting files from dirs --- pkg/loader/url.go | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/pkg/loader/url.go b/pkg/loader/url.go index bc4d5c9f..2035469e 100644 --- a/pkg/loader/url.go +++ b/pkg/loader/url.go @@ -111,11 +111,20 @@ func loadURL(ctx context.Context, cache *cache.Client, base *source, name string req.Header.Set("Authorization", "Bearer "+bearerToken) } - data, err := getWithDefaults(req) + data, defaulted, err := getWithDefaults(req) if err != nil { return nil, false, fmt.Errorf("error loading %s: %v", url, err) } + if defaulted != "" { + pathString = url + name = defaulted + if repo != nil { + repo.Path = path.Join(repo.Path, repo.Name) + repo.Name = defaulted + } + } + log.Debugf("opened %s", url) result := &source{ @@ -137,31 +146,32 @@ func loadURL(ctx context.Context, cache *cache.Client, base *source, name string return result, true, nil } -func getWithDefaults(req *http.Request) ([]byte, error) { +func getWithDefaults(req *http.Request) ([]byte, string, error) { originalPath := req.URL.Path // First, try to get the original path as is. It might be an OpenAPI definition. resp, err := http.DefaultClient.Do(req) if err != nil { - return nil, err + return nil, "", err } defer resp.Body.Close() if resp.StatusCode == http.StatusOK { - if toolBytes, err := io.ReadAll(resp.Body); err == nil && isOpenAPI(toolBytes) != 0 { - return toolBytes, nil - } + toolBytes, err := io.ReadAll(resp.Body) + return toolBytes, "", err + } + + base := path.Base(originalPath) + if strings.Contains(base, ".") { + return nil, "", fmt.Errorf("error loading %s: %s", req.URL.String(), resp.Status) } for i, def := range types.DefaultFiles { - base := path.Base(originalPath) - if !strings.Contains(base, ".") { - req.URL.Path = path.Join(originalPath, def) - } + req.URL.Path = path.Join(originalPath, def) resp, err := http.DefaultClient.Do(req) if err != nil { - return nil, err + return nil, "", err } defer resp.Body.Close() @@ -170,11 +180,13 @@ func getWithDefaults(req *http.Request) ([]byte, error) { } if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("error loading %s: %s", req.URL.String(), resp.Status) + return nil, "", fmt.Errorf("error loading %s: %s", req.URL.String(), resp.Status) } - return io.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) + return data, def, err } + panic("unreachable") } From 7e3b17632eadfc892e9665e3f859ab37dcbecb7f Mon Sep 17 00:00:00 2001 From: Atulpriya Sharma Date: Mon, 15 Jul 2024 17:52:18 +0530 Subject: [PATCH 17/38] Add GPTReview With GitHub Example --- examples/gptreview-ghaction/README.md | 21 ++++++++ examples/gptreview-ghaction/codereview.gpt | 26 ++++++++++ examples/gptreview-ghaction/workflow.yaml | 57 ++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 examples/gptreview-ghaction/README.md create mode 100644 examples/gptreview-ghaction/codereview.gpt create mode 100644 examples/gptreview-ghaction/workflow.yaml diff --git a/examples/gptreview-ghaction/README.md b/examples/gptreview-ghaction/README.md new file mode 100644 index 00000000..2c71acec --- /dev/null +++ b/examples/gptreview-ghaction/README.md @@ -0,0 +1,21 @@ +# GPTReview + +This folder contains an example of building and implementing your own code reviewer as part of GitHub Actions. + +Below are the files present here: + +- `codereview.gpt`: Contains the GPTScript code and prompts. +- `workflow.yaml`: The workflow file for the GitHub action. + +## Pre-requisites + +- GitHub Account +- OpenAI API Key + +## How To Run This Example + +- Create a new repository in your GitHub account and create a `codereview.gpt` file in that repo based on the contents provided in this file. +- Congfigure a GitHub Action for that repository and copy the contents from `workflow.yaml` to your `main.yaml`. +- Configure your `OPENAI_API_KEY` and `GH_TOKEN` as environment variables. +- Add some code file to the repository and open a new pull request. +- The GitHub Action will trigger and our GPTReview will review your code and provide review comments. diff --git a/examples/gptreview-ghaction/codereview.gpt b/examples/gptreview-ghaction/codereview.gpt new file mode 100644 index 00000000..f2502b50 --- /dev/null +++ b/examples/gptreview-ghaction/codereview.gpt @@ -0,0 +1,26 @@ +Name: Code Reviewer +Description: A tool to help you perform code review of open PRs +Context: learn-gh +Tools: sys.exec, sys.http.html2text?, sys.find, sys.read, sys.write +Args: PR_URL: The GitHub PR_URL + +You have the gh cli available to you. Use it to perform code review for a pr from the $(repo) provided. + +Perform the following steps in order: +1. Identify the files changed in the pull request ($PR_URL) using the pr number and perform a diff. + 1. Analyze the complete code of each identified file and perform a detailed line by line code review. + 2. Repeat the process for each changed file in the pr. +2. Share your review comments separately for each file. +3. In a new line write "Code: Approved" or "Code: Require Changes" based on the review comments. +--- +Name: learn-gh +Description: A tool to help you learn gh cli + +#!/usr/bin/env bash + +echo "The following is the help text for the gh cli and some of its sub-commands. Use these when figuring out how to construct new commands. Note that the --search flag is used for filtering and sorting as well; there is no dedicate --sort flag." +gh --help +gh repo --help +gh pr --help +gh pr checkout --help +gh pr diff --help diff --git a/examples/gptreview-ghaction/workflow.yaml b/examples/gptreview-ghaction/workflow.yaml new file mode 100644 index 00000000..21ade39b --- /dev/null +++ b/examples/gptreview-ghaction/workflow.yaml @@ -0,0 +1,57 @@ +name: PR Review with GPTScript + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + pr_review: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Get PR Details + id: pr_details + run: | + PR_URL=$(jq -r '.pull_request.html_url' $GITHUB_EVENT_PATH) + PR_NUMBER=$(jq -r '.pull_request.number' $GITHUB_EVENT_PATH) + PR_FILES=$(jq -r '.pull_request.changed_files' $GITHUB_EVENT_PATH) + echo "PR_URL=${PR_URL}" >> $GITHUB_ENV + echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV + echo "PR_FILES=${PR_FILES}" >> $GITHUB_ENV + + - name: Install GPTScript + run: curl https://get.gptscript.ai/install.sh | sh + + - name: Run GPTScript for Code Review + id: run_gptscript + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + run: | + { + echo 'REVIEW<> "$GITHUB_ENV" + + + - name: Post Review Comment + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + run: | + gh pr comment ${{ github.event.pull_request.number }} --body "$REVIEW" + + - name: Set PR Status Fail + if: contains(env.REVIEW, 'Require Changes') + run: | + echo "Code Requires Changes" + exit 1 + + - name: Set PR Status Pass + if: contains(env.REVIEW, 'Approved') + run: | + echo "Code Approved" + From b2b58bb17a2269e94c8d6541dd24dd9ffcbbc8c7 Mon Sep 17 00:00:00 2001 From: Nick Hale <4175918+njhale@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:12:46 -0400 Subject: [PATCH 18/38] chore: set the run file env var when starting the ui Set the `UI_RUN_FILE` env var before starting the UI tool when a run file is provided; e.g. `gptscript --ui `. This tells the UI to use the file's run page as the landing page on start. Signed-off-by: Nick Hale <4175918+njhale@users.noreply.github.com> --- pkg/cli/gptscript.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cli/gptscript.go b/pkg/cli/gptscript.go index 4820efd8..d7d57b36 100644 --- a/pkg/cli/gptscript.go +++ b/pkg/cli/gptscript.go @@ -371,7 +371,7 @@ func (r *GPTScript) Run(cmd *cobra.Command, args []string) (retErr error) { gptOpt.Env = append(gptOpt.Env, "GPTSCRIPT_SDKSERVER_CREDENTIAL_OVERRIDE="+strings.Join(r.CredentialOverride, ",")) } - args = append([]string{args[0]}, "--file="+file) + gptOpt.Env = append(gptOpt.Env, "UI_RUN_FILE="+file) if len(args) > 2 { args = append(args, args[2:]...) From 904e97fdcccc78e76c925912b99750aac38c69d4 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Mon, 15 Jul 2024 16:14:33 -0400 Subject: [PATCH 19/38] fix: set common UI env vars regardless of whether a file is passed Signed-off-by: Donnie Adams --- pkg/cli/gptscript.go | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/pkg/cli/gptscript.go b/pkg/cli/gptscript.go index d7d57b36..f539f516 100644 --- a/pkg/cli/gptscript.go +++ b/pkg/cli/gptscript.go @@ -332,16 +332,25 @@ func (r *GPTScript) Run(cmd *cobra.Command, args []string) (retErr error) { // If the user is trying to launch the chat-builder UI, then set up the tool and options here. if r.UI { - args = append([]string{uiTool()}, args...) + if os.Getenv(system.BinEnvVar) == "" { + gptOpt.Env = append(gptOpt.Env, system.BinEnvVar+"="+system.Bin()) + } + + // Pass the corrected environment variables for SDK server options + if r.DefaultModel != "" { + gptOpt.Env = append(gptOpt.Env, "GPTSCRIPT_SDKSERVER_DEFAULT_MODEL="+r.DefaultModel) + } + if len(r.CredentialOverride) > 0 { + gptOpt.Env = append(gptOpt.Env, "GPTSCRIPT_SDKSERVER_CREDENTIAL_OVERRIDE="+strings.Join(r.CredentialOverride, ",")) + } // If args has more than one element, then the user has provided a file. - if len(args) > 1 { - if args[1] == "-" { + if len(args) > 0 { + file := args[0] + if file == "-" { return fmt.Errorf("chat UI only supports files, cannot read from stdin") } - file := args[1] - // If the file is external, then set the SCRIPTS_PATH to the current working directory. Otherwise, // set it to the directory of the script and set the file to the base. if !(strings.HasPrefix(file, "http://") || strings.HasPrefix(file, "https://") || strings.HasPrefix(file, "github.com")) { @@ -359,23 +368,9 @@ func (r *GPTScript) Run(cmd *cobra.Command, args []string) (retErr error) { gptOpt.Env = append(gptOpt.Env, "SCRIPTS_PATH="+cwd) } - if os.Getenv(system.BinEnvVar) == "" { - gptOpt.Env = append(gptOpt.Env, system.BinEnvVar+"="+system.Bin()) - } - - // Pass the corrected environment variables for SDK server options - if r.DefaultModel != "" { - gptOpt.Env = append(gptOpt.Env, "GPTSCRIPT_SDKSERVER_DEFAULT_MODEL="+r.DefaultModel) - } - if len(r.CredentialOverride) > 0 { - gptOpt.Env = append(gptOpt.Env, "GPTSCRIPT_SDKSERVER_CREDENTIAL_OVERRIDE="+strings.Join(r.CredentialOverride, ",")) - } - gptOpt.Env = append(gptOpt.Env, "UI_RUN_FILE="+file) - - if len(args) > 2 { - args = append(args, args[2:]...) - } + // Remove the file from args because the above line will pass it to the UI tool. + args = args[1:] } else { cwd, err := os.Getwd() if err != nil { @@ -386,6 +381,8 @@ func (r *GPTScript) Run(cmd *cobra.Command, args []string) (retErr error) { // The UI must run in daemon mode. r.Daemon = true + // Use the UI tool as the first argument. + args = append([]string{uiTool()}, args...) } ctx := cmd.Context() From 5fb849fa33d27fac1771c5fee8219a26f6c5a32e Mon Sep 17 00:00:00 2001 From: Atulpriya Sharma Date: Tue, 16 Jul 2024 05:35:20 +0530 Subject: [PATCH 20/38] Fixed review comments --- examples/gptreview-ghaction/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/gptreview-ghaction/README.md b/examples/gptreview-ghaction/README.md index 2c71acec..fe793a92 100644 --- a/examples/gptreview-ghaction/README.md +++ b/examples/gptreview-ghaction/README.md @@ -14,8 +14,8 @@ Below are the files present here: ## How To Run This Example -- Create a new repository in your GitHub account and create a `codereview.gpt` file in that repo based on the contents provided in this file. -- Congfigure a GitHub Action for that repository and copy the contents from `workflow.yaml` to your `main.yaml`. -- Configure your `OPENAI_API_KEY` and `GH_TOKEN` as environment variables. -- Add some code file to the repository and open a new pull request. +- Create a new repository in your GitHub account and create a `codereview.gpt` file in the root of that repo based on the contents provided in this file. +- Congfigure a GitHub Action for that repository. To do so, navigate to the "Actions" tab and then click on "setup a workflow yourself" link. This will create a new `main.yaml` inside `.github/workflows` path. Copy the contents from `workflow.yaml` to your `main.yaml`. +- Configure your `OPENAI_API_KEY` and `GH_TOKEN` as environment variables in your GitHub repo. Refer to [these steps](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository) to create environment variables for your repository. +- Create a new branch, and add some code file to the repository and open a new pull request. - The GitHub Action will trigger and our GPTReview will review your code and provide review comments. From 5d9dfb48db6bf08ea1670c8146f29893a63ddaee Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 15 Jul 2024 22:37:29 -0700 Subject: [PATCH 21/38] chore: improve reliability with bad tool names --- go.mod | 4 ++-- go.sum | 8 ++++---- pkg/engine/engine.go | 2 +- pkg/openai/client.go | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index fe1b3fa6..f0213f7e 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/gptscript-ai/broadcaster v0.0.0-20240625175512-c43682019b86 github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf0379 github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d - github.com/gptscript-ai/tui v0.0.0-20240702222655-901e7ec1faf5 + github.com/gptscript-ai/tui v0.0.0-20240716053605-ecddbcf60eac github.com/hexops/autogold/v2 v2.2.1 github.com/hexops/valast v1.4.4 github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 @@ -63,7 +63,7 @@ require ( github.com/google/go-cmp v0.6.0 // indirect github.com/gookit/color v1.5.4 // indirect github.com/gorilla/css v1.0.0 // indirect - github.com/gptscript-ai/go-gptscript v0.9.1 // indirect + github.com/gptscript-ai/go-gptscript v0.9.3-0.20240715172623-8176fb20c5cb // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hexops/autogold v1.3.1 // indirect diff --git a/go.sum b/go.sum index 9f29c3e4..598a161e 100644 --- a/go.sum +++ b/go.sum @@ -171,10 +171,10 @@ github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf037 github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf0379/go.mod h1:7P/o6/IWa1KqsntVf68hSnLKuu3+xuqm6lYhch1w4jo= github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d h1:sKf7T7twhGXs6AVbvD9pKDVewykkwSAPwEpmIEQIR/4= github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d/go.mod h1:DJAo1xTht1LDkNYFNydVjTHd576TC7MlpsVRl3oloVw= -github.com/gptscript-ai/go-gptscript v0.9.1 h1:O9oSmYvzQ2GZkPfDhXpiMGdtO9BMCVGeWLdJH88AJzg= -github.com/gptscript-ai/go-gptscript v0.9.1/go.mod h1:Dh6vYRAiVcyC3ElZIGzTvNF1FxtYwA07BHfSiFKQY7s= -github.com/gptscript-ai/tui v0.0.0-20240702222655-901e7ec1faf5 h1:qCNJVFDHT2p0cuLo920DmUQoUngAuXGgqldYNwmC/R0= -github.com/gptscript-ai/tui v0.0.0-20240702222655-901e7ec1faf5/go.mod h1:mYzM8AwIiAdImy2g0BsdTPPuSbsONTMw5GIHDc/2o7g= +github.com/gptscript-ai/go-gptscript v0.9.3-0.20240715172623-8176fb20c5cb h1:xeSbO4mLYnoTg7diNW0tpxY/0yDSSdgjohMzwE4Za6k= +github.com/gptscript-ai/go-gptscript v0.9.3-0.20240715172623-8176fb20c5cb/go.mod h1:Dh6vYRAiVcyC3ElZIGzTvNF1FxtYwA07BHfSiFKQY7s= +github.com/gptscript-ai/tui v0.0.0-20240716053605-ecddbcf60eac h1:zZ993dp2mx/63JD4THwMeBcn3C8SogcLeQRJUZsMSM4= +github.com/gptscript-ai/tui v0.0.0-20240716053605-ecddbcf60eac/go.mod h1:Ex2xQMzTMfb5UgLz9rctATPps8DnfPeJQh8o/AiQCoE= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 43c1da99..250e9578 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -389,7 +389,7 @@ func (e *Engine) complete(ctx context.Context, state *State) (*Return, error) { if content.ToolCall != nil { var toolID string for _, tool := range state.Completion.Tools { - if tool.Function.Name == content.ToolCall.Function.Name { + if strings.EqualFold(tool.Function.Name, content.ToolCall.Function.Name) { toolID = tool.Function.ToolID } } diff --git a/pkg/openai/client.go b/pkg/openai/client.go index 4ade654a..53252895 100644 --- a/pkg/openai/client.go +++ b/pkg/openai/client.go @@ -450,8 +450,9 @@ func appendMessage(msg types.CompletionMessage, response openai.ChatCompletionSt if tc.ToolCall.Function.Name != tool.Function.Name { tc.ToolCall.Function.Name += tool.Function.Name } - // OpenAI like to sometimes add this prefix for no good reason + // OpenAI like to sometimes add these prefix because it's confused tc.ToolCall.Function.Name = strings.TrimPrefix(tc.ToolCall.Function.Name, "namespace.") + tc.ToolCall.Function.Name = strings.TrimPrefix(tc.ToolCall.Function.Name, "@") tc.ToolCall.Function.Arguments += tool.Function.Arguments msg.Content[idx] = tc From 87e4c801e15fbef8722d60a9fb4ba8f07e60c1f5 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Tue, 16 Jul 2024 16:07:10 -0400 Subject: [PATCH 22/38] fix: respect absolute paths for loading local tools Signed-off-by: Donnie Adams --- pkg/loader/loader.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/loader/loader.go b/pkg/loader/loader.go index f60f09a1..d7634058 100644 --- a/pkg/loader/loader.go +++ b/pkg/loader/loader.go @@ -72,7 +72,11 @@ func openFile(path string) (io.ReadCloser, bool, error) { func loadLocal(base *source, name string) (*source, bool, error) { // We want to keep all strings in / format, and only convert to platform specific when reading - filePath := path.Join(base.Path, name) + // This is why we use path instead of filepath. + filePath := name + if !path.IsAbs(name) { + filePath = path.Join(base.Path, name) + } if s, err := fs.Stat(internal.FS, filepath.Clean(filePath)); err == nil && s.IsDir() { for _, def := range types.DefaultFiles { From c2d65e2c0e051d19687514c87b1572ab4143b694 Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Tue, 16 Jul 2024 15:38:12 -0700 Subject: [PATCH 23/38] chore: strip leading and trailing whitespace characters from credential values Signed-off-by: Taylor Price --- pkg/credentials/credential.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/credentials/credential.go b/pkg/credentials/credential.go index c81adf2b..605208a0 100644 --- a/pkg/credentials/credential.go +++ b/pkg/credentials/credential.go @@ -35,6 +35,9 @@ func (c Credential) IsExpired() bool { } func (c Credential) toDockerAuthConfig() (types.AuthConfig, error) { + for k, v := range c.Env { + c.Env[k] = strings.TrimSpace(v) + } cred, err := json.Marshal(c) if err != nil { return types.AuthConfig{}, err From ecca52cd7e2a08f87d3465ba878b1839d1f41b7f Mon Sep 17 00:00:00 2001 From: Taylor Price Date: Tue, 16 Jul 2024 16:10:06 -0700 Subject: [PATCH 24/38] fix: expand tilde and relative paths to be absolute for cache-dir Signed-off-by: Taylor Price --- pkg/cache/cache.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index bc499aef..031bd166 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -9,7 +9,9 @@ import ( "errors" "io/fs" "os" + "os/user" "path/filepath" + "strings" "github.com/adrg/xdg" "github.com/getkin/kin-openapi/openapi3" @@ -40,10 +42,28 @@ func Complete(opts ...Options) (result Options) { } if result.CacheDir == "" { result.CacheDir = filepath.Join(xdg.CacheHome, version.ProgramName) + } else if !filepath.IsAbs(result.CacheDir) { + var err error + result.CacheDir, err = makeAbsolute(result.CacheDir) + if err != nil { + result.CacheDir = filepath.Join(xdg.CacheHome, version.ProgramName) + } } return } +func makeAbsolute(path string) (string, error) { + if strings.HasPrefix(path, "~"+string(filepath.Separator)) { + usr, err := user.Current() + if err != nil { + return "", err + } + + return filepath.Join(usr.HomeDir, path[2:]), nil + } + return filepath.Abs(path) +} + type noCacheKey struct{} func IsNoCache(ctx context.Context) bool { From 3055632582ead7338a322b209da0921c717cc7d1 Mon Sep 17 00:00:00 2001 From: Grant Linville Date: Wed, 17 Jul 2024 14:52:21 -0400 Subject: [PATCH 25/38] enhance: share credential (#634) Signed-off-by: Grant Linville --- integration/cred_test.go | 16 +++ integration/helpers.go | 4 + integration/scripts/credscopes.gpt | 160 +++++++++++++++++++++++++++++ pkg/parser/parser.go | 2 + pkg/runner/runner.go | 41 ++++---- pkg/types/tool.go | 24 +++++ 6 files changed, 228 insertions(+), 19 deletions(-) create mode 100644 integration/scripts/credscopes.gpt diff --git a/integration/cred_test.go b/integration/cred_test.go index b92ccd55..67298ef8 100644 --- a/integration/cred_test.go +++ b/integration/cred_test.go @@ -11,3 +11,19 @@ func TestGPTScriptCredential(t *testing.T) { require.NoError(t, err) require.Contains(t, out, "CREDENTIAL") } + +// TestCredentialScopes makes sure that environment variables set by credential tools and shared credential tools +// are only available to the correct tools. See scripts/credscopes.gpt for more details. +func TestCredentialScopes(t *testing.T) { + out, err := RunScript("scripts/credscopes.gpt", "--sub-tool", "oneOne") + require.NoError(t, err) + require.Contains(t, out, "good") + + out, err = RunScript("scripts/credscopes.gpt", "--sub-tool", "twoOne") + require.NoError(t, err) + require.Contains(t, out, "good") + + out, err = RunScript("scripts/credscopes.gpt", "--sub-tool", "twoTwo") + require.NoError(t, err) + require.Contains(t, out, "good") +} diff --git a/integration/helpers.go b/integration/helpers.go index 8af581c3..33304676 100644 --- a/integration/helpers.go +++ b/integration/helpers.go @@ -14,3 +14,7 @@ func GPTScriptExec(args ...string) (string, error) { out, err := cmd.CombinedOutput() return string(out), err } + +func RunScript(script string, options ...string) (string, error) { + return GPTScriptExec(append(options, "--quiet", script)...) +} diff --git a/integration/scripts/credscopes.gpt b/integration/scripts/credscopes.gpt new file mode 100644 index 00000000..7319f163 --- /dev/null +++ b/integration/scripts/credscopes.gpt @@ -0,0 +1,160 @@ +# This script sets up a chain of tools in a tree structure. +# The root is oneOne, with children twoOne and twoTwo, with children threeOne, threeTwo, and threeThree, with only +# threeTwo shared between them. +# Each tool should only have access to any credentials it defines and any credentials exported/shared by its +# immediate children (but not grandchildren). +# This script checks to make sure that this is working properly. +name: oneOne +tools: twoOne, twoTwo +cred: getcred with oneOne as var and 11 as val + +#!python3 + +import os + +oneOne = os.getenv('oneOne') +twoOne = os.getenv('twoOne') +twoTwo = os.getenv('twoTwo') +threeOne = os.getenv('threeOne') +threeTwo = os.getenv('threeTwo') +threeThree = os.getenv('threeThree') + +if oneOne != '11': + print('error: oneOne is not 11') + exit(1) + +if twoOne != '21': + print('error: twoOne is not 21') + exit(1) + +if twoTwo != '22': + print('error: twoTwo is not 22') + exit(1) + +if threeOne is not None: + print('error: threeOne is not None') + exit(1) + +if threeTwo is not None: + print('error: threeTwo is not None') + exit(1) + +if threeThree is not None: + print('error: threeThree is not None') + exit(1) + +print('good') + +--- +name: twoOne +tools: threeOne, threeTwo +sharecred: getcred with twoOne as var and 21 as val + +#!python3 + +import os + +oneOne = os.getenv('oneOne') +twoOne = os.getenv('twoOne') +twoTwo = os.getenv('twoTwo') +threeOne = os.getenv('threeOne') +threeTwo = os.getenv('threeTwo') +threeThree = os.getenv('threeThree') + +if oneOne is not None: + print('error: oneOne is not None') + exit(1) + +if twoOne is not None: + print('error: twoOne is not None') + exit(1) + +if twoTwo is not None: + print('error: twoTwo is not None') + exit(1) + +if threeOne != '31': + print('error: threeOne is not 31') + exit(1) + +if threeTwo != '32': + print('error: threeTwo is not 32') + exit(1) + +if threeThree is not None: + print('error: threeThree is not None') + exit(1) + +print('good') + +--- +name: twoTwo +tools: threeTwo, threeThree +sharecred: getcred with twoTwo as var and 22 as val + +#!python3 + +import os + +oneOne = os.getenv('oneOne') +twoOne = os.getenv('twoOne') +twoTwo = os.getenv('twoTwo') +threeOne = os.getenv('threeOne') +threeTwo = os.getenv('threeTwo') +threeThree = os.getenv('threeThree') + +if oneOne is not None: + print('error: oneOne is not None') + exit(1) + +if twoOne is not None: + print('error: twoOne is not None') + exit(1) + +if twoTwo is not None: + print('error: twoTwo is not None') + exit(1) + +if threeOne is not None: + print('error: threeOne is not None') + exit(1) + +if threeTwo != '32': + print('error: threeTwo is not 32') + exit(1) + +if threeThree != '33': + print('error: threeThree is not 33') + exit(1) + +print('good') + +--- +name: threeOne +sharecred: getcred with threeOne as var and 31 as val + +--- +name: threeTwo +sharecred: getcred with threeTwo as var and 32 as val + +--- +name: threeThree +sharecred: getcred with threeThree as var and 33 as val + +--- +name: getcred + +#!python3 + +import os +import json + +var = os.getenv('var') +val = os.getenv('val') + +output = { + "env": { + var: val + } +} +print(json.dumps(output)) diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index 22cd5e9e..f7c750c1 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -148,6 +148,8 @@ func isParam(line string, tool *types.Tool) (_ bool, err error) { } case "credentials", "creds", "credential", "cred": tool.Parameters.Credentials = append(tool.Parameters.Credentials, value) + case "sharecredentials", "sharecreds", "sharecredential", "sharecred": + tool.Parameters.ExportCredentials = append(tool.Parameters.ExportCredentials, value) default: return false, nil } diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index cc5a3927..36bac826 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -419,9 +419,13 @@ func (r *Runner) start(callCtx engine.Context, state *State, monitor Monitor, en return nil, err } - if len(callCtx.Tool.Credentials) > 0 { + credTools, err := callCtx.Tool.GetCredentialTools(*callCtx.Program, callCtx.AgentGroup) + if err != nil { + return nil, err + } + if len(credTools) > 0 { var err error - env, err = r.handleCredentials(callCtx, monitor, env) + env, err = r.handleCredentials(callCtx, monitor, env, credTools) if err != nil { return nil, err } @@ -552,9 +556,13 @@ func (r *Runner) resume(callCtx engine.Context, monitor Monitor, env []string, s progress, progressClose := streamProgress(&callCtx, monitor) defer progressClose() - if len(callCtx.Tool.Credentials) > 0 { + credTools, err := callCtx.Tool.GetCredentialTools(*callCtx.Program, callCtx.AgentGroup) + if err != nil { + return nil, err + } + if len(credTools) > 0 { var err error - env, err = r.handleCredentials(callCtx, monitor, env) + env, err = r.handleCredentials(callCtx, monitor, env, credTools) if err != nil { return nil, err } @@ -828,7 +836,7 @@ func getEventContent(content string, callCtx engine.Context) string { return content } -func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env []string) ([]string, error) { +func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env []string, credToolRefs []types.ToolReference) ([]string, error) { // Since credential tools (usually) prompt the user, we want to only run one at a time. r.credMutex.Lock() defer r.credMutex.Unlock() @@ -845,10 +853,10 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env } } - for _, credToolName := range callCtx.Tool.Credentials { - toolName, credentialAlias, args, err := types.ParseCredentialArgs(credToolName, callCtx.Input) + for _, ref := range credToolRefs { + toolName, credentialAlias, args, err := types.ParseCredentialArgs(ref.Reference, callCtx.Input) if err != nil { - return nil, fmt.Errorf("failed to parse credential tool %q: %w", credToolName, err) + return nil, fmt.Errorf("failed to parse credential tool %q: %w", ref.Reference, err) } credName := toolName @@ -895,11 +903,6 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env // If the credential doesn't already exist in the store, run the credential tool in order to get the value, // and save it in the store. if !exists || c.IsExpired() { - credToolRefs, ok := callCtx.Tool.ToolMapping[credToolName] - if !ok || len(credToolRefs) != 1 { - return nil, fmt.Errorf("failed to find ID for tool %s", credToolName) - } - // If the existing credential is expired, we need to provide it to the cred tool through the environment. if exists && c.IsExpired() { credJSON, err := json.Marshal(c) @@ -914,22 +917,22 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env if args != nil { inputBytes, err := json.Marshal(args) if err != nil { - return nil, fmt.Errorf("failed to marshal args for tool %s: %w", credToolName, err) + return nil, fmt.Errorf("failed to marshal args for tool %s: %w", ref.Reference, err) } input = string(inputBytes) } - res, err := r.subCall(callCtx.Ctx, callCtx, monitor, env, credToolRefs[0].ToolID, input, "", engine.CredentialToolCategory) + res, err := r.subCall(callCtx.Ctx, callCtx, monitor, env, ref.ToolID, input, "", engine.CredentialToolCategory) if err != nil { - return nil, fmt.Errorf("failed to run credential tool %s: %w", credToolName, err) + return nil, fmt.Errorf("failed to run credential tool %s: %w", ref.Reference, err) } if res.Result == nil { - return nil, fmt.Errorf("invalid state: credential tool [%s] can not result in a continuation", credToolName) + return nil, fmt.Errorf("invalid state: credential tool [%s] can not result in a continuation", ref.Reference) } if err := json.Unmarshal([]byte(*res.Result), &c); err != nil { - return nil, fmt.Errorf("failed to unmarshal credential tool %s response: %w", credToolName, err) + return nil, fmt.Errorf("failed to unmarshal credential tool %s response: %w", ref.Reference, err) } c.ToolName = credName c.Type = credentials.CredentialTypeTool @@ -943,7 +946,7 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env } // Only store the credential if the tool is on GitHub or has an alias, and the credential is non-empty. - if (isGitHubTool(toolName) && callCtx.Program.ToolSet[credToolRefs[0].ToolID].Source.Repo != nil) || credentialAlias != "" { + if (isGitHubTool(toolName) && callCtx.Program.ToolSet[ref.ToolID].Source.Repo != nil) || credentialAlias != "" { if isEmpty { log.Warnf("Not saving empty credential for tool %s", toolName) } else if err := r.credStore.Add(callCtx.Ctx, *c); err != nil { diff --git a/pkg/types/tool.go b/pkg/types/tool.go index e4b3424a..ad483984 100644 --- a/pkg/types/tool.go +++ b/pkg/types/tool.go @@ -139,6 +139,7 @@ type Parameters struct { Export []string `json:"export,omitempty"` Agents []string `json:"agents,omitempty"` Credentials []string `json:"credentials,omitempty"` + ExportCredentials []string `json:"exportCredentials,omitempty"` InputFilters []string `json:"inputFilters,omitempty"` ExportInputFilters []string `json:"exportInputFilters,omitempty"` OutputFilters []string `json:"outputFilters,omitempty"` @@ -154,6 +155,7 @@ func (p Parameters) ToolRefNames() []string { p.ExportContext, p.Context, p.Credentials, + p.ExportCredentials, p.InputFilters, p.ExportInputFilters, p.OutputFilters, @@ -466,6 +468,11 @@ func (t ToolDef) String() string { _, _ = fmt.Fprintf(buf, "Credential: %s\n", cred) } } + if len(t.Parameters.ExportCredentials) > 0 { + for _, exportCred := range t.Parameters.ExportCredentials { + _, _ = fmt.Fprintf(buf, "Share Credential: %s\n", exportCred) + } + } if t.Parameters.Chat { _, _ = fmt.Fprintf(buf, "Chat: true\n") } @@ -675,6 +682,23 @@ func (t Tool) getCompletionToolRefs(prg Program, agentGroup []ToolReference) ([] return result.List() } +func (t Tool) GetCredentialTools(prg Program, agentGroup []ToolReference) ([]ToolReference, error) { + result := toolRefSet{} + + result.AddAll(t.GetToolRefsFromNames(t.Credentials)) + + toolRefs, err := t.getCompletionToolRefs(prg, agentGroup) + if err != nil { + return nil, err + } + for _, toolRef := range toolRefs { + referencedTool := prg.ToolSet[toolRef.ToolID] + result.AddAll(referencedTool.GetToolRefsFromNames(referencedTool.ExportCredentials)) + } + + return result.List() +} + func toolRefsToCompletionTools(completionTools []ToolReference, prg Program) (result []CompletionTool) { toolNames := map[string]struct{}{} From 19a51890efe613918d573d91ee268797c2c7ad2f Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 19 Jul 2024 10:46:26 -0700 Subject: [PATCH 26/38] chore: return missing tool call to LLM, don't fail --- pkg/engine/engine.go | 24 +++++--- pkg/runner/runner.go | 12 ++++ pkg/tests/runner_test.go | 15 +++++ .../TestMissingTool/call1-resp.golden | 14 +++++ .../testdata/TestMissingTool/call1.golden | 32 ++++++++++ .../TestMissingTool/call2-resp.golden | 9 +++ .../testdata/TestMissingTool/call2.golden | 61 +++++++++++++++++++ pkg/tests/testdata/TestMissingTool/test.gpt | 10 +++ pkg/tests/tester/runner.go | 15 ++++- 9 files changed, 181 insertions(+), 11 deletions(-) create mode 100644 pkg/tests/testdata/TestMissingTool/call1-resp.golden create mode 100644 pkg/tests/testdata/TestMissingTool/call1.golden create mode 100644 pkg/tests/testdata/TestMissingTool/call2-resp.golden create mode 100644 pkg/tests/testdata/TestMissingTool/call2.golden create mode 100644 pkg/tests/testdata/TestMissingTool/test.gpt diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 250e9578..0ea72ff6 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -45,8 +45,9 @@ type Return struct { } type Call struct { - ToolID string `json:"toolID,omitempty"` - Input string `json:"input,omitempty"` + Missing bool `json:"missing,omitempty"` + ToolID string `json:"toolID,omitempty"` + Input string `json:"input,omitempty"` } type CallResult struct { @@ -216,10 +217,7 @@ func NewContext(ctx context.Context, prg *types.Program, input string) (Context, } func (c *Context) SubCallContext(ctx context.Context, input, toolID, callID string, toolCategory ToolCategory) (Context, error) { - tool, ok := c.Program.ToolSet[toolID] - if !ok { - return Context{}, fmt.Errorf("failed to file tool for id [%s]", toolID) - } + tool := c.Program.ToolSet[toolID] if callID == "" { callID = counter.Next() @@ -387,19 +385,25 @@ func (e *Engine) complete(ctx context.Context, state *State) (*Return, error) { state.Pending = map[string]types.CompletionToolCall{} for _, content := range resp.Content { if content.ToolCall != nil { - var toolID string + var ( + toolID string + missing bool + ) for _, tool := range state.Completion.Tools { if strings.EqualFold(tool.Function.Name, content.ToolCall.Function.Name) { toolID = tool.Function.ToolID } } if toolID == "" { - return nil, fmt.Errorf("failed to find tool id for tool %s in tool_call result", content.ToolCall.Function.Name) + log.Debugf("failed to find tool id for tool %s in tool_call result", content.ToolCall.Function.Name) + toolID = content.ToolCall.Function.Name + missing = true } state.Pending[content.ToolCall.ID] = *content.ToolCall ret.Calls[content.ToolCall.ID] = Call{ - ToolID: toolID, - Input: content.ToolCall.Function.Arguments, + ToolID: toolID, + Missing: missing, + Input: content.ToolCall.Function.Arguments, } } else { cp := content.Text diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 36bac826..9e8695a7 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -802,6 +802,18 @@ func (r *Runner) subCalls(callCtx engine.Context, monitor Monitor, env []string, for _, id := range ids { call := state.Continuation.Calls[id] + if call.Missing { + resultLock.Lock() + callResults = append(callResults, SubCallResult{ + ToolID: call.ToolID, + CallID: id, + State: &State{ + Result: &[]string{fmt.Sprintf("ERROR: can not call unknown tool named [%s]", call.ToolID)}[0], + }, + }) + resultLock.Unlock() + continue + } d.Run(func(ctx context.Context) error { result, err := r.subCall(ctx, callCtx, monitor, env, call.ToolID, call.Input, id, toolCategory) if err != nil { diff --git a/pkg/tests/runner_test.go b/pkg/tests/runner_test.go index 0b75c8a2..a38de6a2 100644 --- a/pkg/tests/runner_test.go +++ b/pkg/tests/runner_test.go @@ -948,3 +948,18 @@ func TestSysContext(t *testing.T) { require.Len(t, context.Call.AgentGroup, 1) assert.Equal(t, context.Call.AgentGroup[0].Named, "iAmSuperman") } + +func TestMissingTool(t *testing.T) { + r := tester.NewRunner(t) + + r.RespondWith(tester.Result{ + Func: types.CompletionFunctionCall{ + Name: "not bob", + }, + }) + + resp, err := r.Run("", "Input 1") + require.NoError(t, err) + r.AssertResponded(t) + autogold.Expect("TEST RESULT CALL: 2").Equal(t, resp) +} diff --git a/pkg/tests/testdata/TestMissingTool/call1-resp.golden b/pkg/tests/testdata/TestMissingTool/call1-resp.golden new file mode 100644 index 00000000..c9799ee8 --- /dev/null +++ b/pkg/tests/testdata/TestMissingTool/call1-resp.golden @@ -0,0 +1,14 @@ +`{ + "role": "assistant", + "content": [ + { + "toolCall": { + "id": "call_1", + "function": { + "name": "not bob" + } + } + } + ], + "usage": {} +}` diff --git a/pkg/tests/testdata/TestMissingTool/call1.golden b/pkg/tests/testdata/TestMissingTool/call1.golden new file mode 100644 index 00000000..f1bcc4f0 --- /dev/null +++ b/pkg/tests/testdata/TestMissingTool/call1.golden @@ -0,0 +1,32 @@ +`{ + "model": "gpt-4o", + "tools": [ + { + "function": { + "toolID": "testdata/TestMissingTool/test.gpt:Bob", + "name": "Bob", + "parameters": null + } + } + ], + "messages": [ + { + "role": "system", + "content": [ + { + "text": "Call tool Bob" + } + ], + "usage": {} + }, + { + "role": "user", + "content": [ + { + "text": "Input 1" + } + ], + "usage": {} + } + ] +}` diff --git a/pkg/tests/testdata/TestMissingTool/call2-resp.golden b/pkg/tests/testdata/TestMissingTool/call2-resp.golden new file mode 100644 index 00000000..997ca1b9 --- /dev/null +++ b/pkg/tests/testdata/TestMissingTool/call2-resp.golden @@ -0,0 +1,9 @@ +`{ + "role": "assistant", + "content": [ + { + "text": "TEST RESULT CALL: 2" + } + ], + "usage": {} +}` diff --git a/pkg/tests/testdata/TestMissingTool/call2.golden b/pkg/tests/testdata/TestMissingTool/call2.golden new file mode 100644 index 00000000..2fe99e81 --- /dev/null +++ b/pkg/tests/testdata/TestMissingTool/call2.golden @@ -0,0 +1,61 @@ +`{ + "model": "gpt-4o", + "tools": [ + { + "function": { + "toolID": "testdata/TestMissingTool/test.gpt:Bob", + "name": "Bob", + "parameters": null + } + } + ], + "messages": [ + { + "role": "system", + "content": [ + { + "text": "Call tool Bob" + } + ], + "usage": {} + }, + { + "role": "user", + "content": [ + { + "text": "Input 1" + } + ], + "usage": {} + }, + { + "role": "assistant", + "content": [ + { + "toolCall": { + "id": "call_1", + "function": { + "name": "not bob" + } + } + } + ], + "usage": {} + }, + { + "role": "tool", + "content": [ + { + "text": "ERROR: can not call unknown tool named [not bob]" + } + ], + "toolCall": { + "id": "call_1", + "function": { + "name": "not bob" + } + }, + "usage": {} + } + ] +}` diff --git a/pkg/tests/testdata/TestMissingTool/test.gpt b/pkg/tests/testdata/TestMissingTool/test.gpt new file mode 100644 index 00000000..2613ffd2 --- /dev/null +++ b/pkg/tests/testdata/TestMissingTool/test.gpt @@ -0,0 +1,10 @@ +tools: Bob + +Call tool Bob + +--- +name: Bob + +#!sys.echo + +You called? \ No newline at end of file diff --git a/pkg/tests/tester/runner.go b/pkg/tests/tester/runner.go index fe21ba92..775f0248 100644 --- a/pkg/tests/tester/runner.go +++ b/pkg/tests/tester/runner.go @@ -104,7 +104,20 @@ func (c *Client) Call(_ context.Context, messageRequest types.CompletionRequest, } if result.Func.Name != "" { - c.t.Fatalf("failed to find tool %s", result.Func.Name) + return &types.CompletionMessage{ + Role: types.CompletionMessageRoleTypeAssistant, + Content: []types.ContentPart{ + { + ToolCall: &types.CompletionToolCall{ + ID: fmt.Sprintf("call_%d", c.id), + Function: types.CompletionFunctionCall{ + Name: result.Func.Name, + Arguments: result.Func.Arguments, + }, + }, + }, + }, + }, nil } return &types.CompletionMessage{ From 3c53e2aa3f4cae850557ef231c4949fd43750f21 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Fri, 19 Jul 2024 21:54:01 -0400 Subject: [PATCH 27/38] feat: improve SDK server start up Additionally, this change includes a way to run the server embeddedly in another process that may use stdin. Signed-off-by: Donnie Adams --- pkg/cli/sdk_server.go | 4 +-- pkg/sdkserver/server.go | 74 +++++++++++++++++++++++++++++------------ 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/pkg/cli/sdk_server.go b/pkg/cli/sdk_server.go index a2ac8488..c9cf480f 100644 --- a/pkg/cli/sdk_server.go +++ b/pkg/cli/sdk_server.go @@ -29,11 +29,11 @@ func (c *SDKServer) Run(cmd *cobra.Command, _ []string) error { // Don't use cmd.Context() as we don't want to die on ctrl+c ctx := context.Background() if term.IsTerminal(int(os.Stdin.Fd())) { - // Only support CTRL+C if stdin is the terminal. When ran as a SDK it will be a pipe + // Only support CTRL+C if stdin is the terminal. When ran as an SDK it will be a pipe ctx = cmd.Context() } - return sdkserver.Start(ctx, sdkserver.Options{ + return sdkserver.Run(ctx, sdkserver.Options{ Options: opts, ListenAddress: c.ListenAddress, Debug: c.Debug, diff --git a/pkg/sdkserver/server.go b/pkg/sdkserver/server.go index 4556f69e..d0ca5a5f 100644 --- a/pkg/sdkserver/server.go +++ b/pkg/sdkserver/server.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io" - "log/slog" "net" "net/http" "os" @@ -29,7 +28,18 @@ type Options struct { Debug bool } -func Start(ctx context.Context, opts Options) error { +// Run will start the server and block until the server is shut down. +func Run(ctx context.Context, opts Options) error { + listener, err := newListener(opts) + if err != nil { + return err + } + + _, err = io.WriteString(os.Stderr, listener.Addr().String()+"\n") + if err != nil { + return fmt.Errorf("failed to write to address to stderr: %w", err) + } + sigCtx, cancel := signal.NotifyContext(ctx, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGKILL) defer cancel() go func() { @@ -40,6 +50,34 @@ func Start(ctx context.Context, opts Options) error { cancel() }() + return run(sigCtx, listener, opts) +} + +// EmbeddedStart allows running the server as an embedded process that may use Stdin for input. +// It returns the address the server is listening on. +func EmbeddedStart(ctx context.Context, opts Options) (string, error) { + listener, err := newListener(opts) + if err != nil { + return "", err + } + + go func() { + _ = run(ctx, listener, opts) + }() + + return listener.Addr().String(), nil +} + +func (s *server) close() { + s.client.Close(true) + s.events.Close() +} + +func newListener(opts Options) (net.Listener, error) { + return net.Listen("tcp", opts.ListenAddress) +} + +func run(ctx context.Context, listener net.Listener, opts Options) error { if opts.Debug { mvl.SetDebug() } @@ -58,11 +96,6 @@ func Start(ctx context.Context, opts Options) error { return err } - listener, err := net.Listen("tcp", opts.ListenAddress) - if err != nil { - return fmt.Errorf("failed to listen on %s: %w", opts.ListenAddress, err) - } - s := &server{ gptscriptOpts: opts.Options, address: listener.Addr().String(), @@ -72,11 +105,11 @@ func Start(ctx context.Context, opts Options) error { waitingToConfirm: make(map[string]chan runner.AuthorizerResponse), waitingToPrompt: make(map[string]chan map[string]string), } - defer s.Close() + defer s.close() s.addRoutes(http.DefaultServeMux) - server := http.Server{ + httpServer := &http.Server{ Handler: apply(http.DefaultServeMux, contentType("application/json"), addRequestID, @@ -86,25 +119,22 @@ func Start(ctx context.Context, opts Options) error { ), } - slog.Info("Starting server", "addr", s.address) - - context.AfterFunc(sigCtx, func() { - ctx, cancel := context.WithTimeout(ctx, 15*time.Second) + logger := mvl.Package() + done := make(chan struct{}) + context.AfterFunc(ctx, func() { + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() - slog.Info("Shutting down server") - _ = server.Shutdown(ctx) - slog.Info("Server stopped") + logger.Infof("Shutting down server") + _ = httpServer.Shutdown(ctx) + logger.Infof("Server stopped") + close(done) }) - if err := server.Serve(listener); err != nil && !errors.Is(err, http.ErrServerClosed) { + if err = httpServer.Serve(listener); !errors.Is(err, http.ErrServerClosed) { return fmt.Errorf("server error: %w", err) } + <-done return nil } - -func (s *server) Close() { - s.client.Close(true) - s.events.Close() -} From f602040671a1f967c72b8598b838a6c7d2b9f211 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 19 Jul 2024 10:45:50 -0700 Subject: [PATCH 28/38] chore: already cached performance improvements --- go.mod | 4 ++-- go.sum | 8 ++++---- pkg/engine/cmd.go | 2 +- pkg/env/env.go | 4 ++++ pkg/llm/registry.go | 29 +++++++++++++++++++++++++++++ pkg/loader/url.go | 19 ++++++++++++++++++- 6 files changed, 58 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index f0213f7e..1e379045 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/gptscript-ai/broadcaster v0.0.0-20240625175512-c43682019b86 github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf0379 github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d - github.com/gptscript-ai/tui v0.0.0-20240716053605-ecddbcf60eac + github.com/gptscript-ai/tui v0.0.0-20240722014329-d50b5ac5db74 github.com/hexops/autogold/v2 v2.2.1 github.com/hexops/valast v1.4.4 github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 @@ -63,7 +63,7 @@ require ( github.com/google/go-cmp v0.6.0 // indirect github.com/gookit/color v1.5.4 // indirect github.com/gorilla/css v1.0.0 // indirect - github.com/gptscript-ai/go-gptscript v0.9.3-0.20240715172623-8176fb20c5cb // indirect + github.com/gptscript-ai/go-gptscript v0.9.3-0.20240722014125-d757d09f606b // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hexops/autogold v1.3.1 // indirect diff --git a/go.sum b/go.sum index 598a161e..881c5073 100644 --- a/go.sum +++ b/go.sum @@ -171,10 +171,10 @@ github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf037 github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf0379/go.mod h1:7P/o6/IWa1KqsntVf68hSnLKuu3+xuqm6lYhch1w4jo= github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d h1:sKf7T7twhGXs6AVbvD9pKDVewykkwSAPwEpmIEQIR/4= github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d/go.mod h1:DJAo1xTht1LDkNYFNydVjTHd576TC7MlpsVRl3oloVw= -github.com/gptscript-ai/go-gptscript v0.9.3-0.20240715172623-8176fb20c5cb h1:xeSbO4mLYnoTg7diNW0tpxY/0yDSSdgjohMzwE4Za6k= -github.com/gptscript-ai/go-gptscript v0.9.3-0.20240715172623-8176fb20c5cb/go.mod h1:Dh6vYRAiVcyC3ElZIGzTvNF1FxtYwA07BHfSiFKQY7s= -github.com/gptscript-ai/tui v0.0.0-20240716053605-ecddbcf60eac h1:zZ993dp2mx/63JD4THwMeBcn3C8SogcLeQRJUZsMSM4= -github.com/gptscript-ai/tui v0.0.0-20240716053605-ecddbcf60eac/go.mod h1:Ex2xQMzTMfb5UgLz9rctATPps8DnfPeJQh8o/AiQCoE= +github.com/gptscript-ai/go-gptscript v0.9.3-0.20240722014125-d757d09f606b h1:Hxu8oPE43uQ2sZ7P+9yGSX9bXh0RoJfOgvY/SlCwFlM= +github.com/gptscript-ai/go-gptscript v0.9.3-0.20240722014125-d757d09f606b/go.mod h1:Dh6vYRAiVcyC3ElZIGzTvNF1FxtYwA07BHfSiFKQY7s= +github.com/gptscript-ai/tui v0.0.0-20240722014329-d50b5ac5db74 h1:69BENZCN2y4BCxmPjMRp+ZQ47ay4i5gRgREKZatu5oE= +github.com/gptscript-ai/tui v0.0.0-20240722014329-d50b5ac5db74/go.mod h1:sP/9g7+nLq65aGef5F30AEG+Cuu4BwlglUYv1Pzps4Y= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= diff --git a/pkg/engine/cmd.go b/pkg/engine/cmd.go index e0ea5e3a..9e4b94fc 100644 --- a/pkg/engine/cmd.go +++ b/pkg/engine/cmd.go @@ -96,7 +96,7 @@ func (e *Engine) runCommand(ctx Context, tool types.Tool, input string, toolCate instructions = append(instructions, inputContext.Content) } var extraEnv = []string{ - strings.TrimSpace(fmt.Sprintf("GPTSCRIPT_CONTEXT=%s", strings.Join(instructions, "\n"))), + strings.TrimSpace("GPTSCRIPT_CONTEXT=" + strings.Join(instructions, "\n")), } cmd, stop, err := e.newCommand(ctx.Ctx, extraEnv, tool, input) diff --git a/pkg/env/env.go b/pkg/env/env.go index 7c8bd7c7..bedd5f9d 100644 --- a/pkg/env/env.go +++ b/pkg/env/env.go @@ -60,6 +60,10 @@ func AppendPath(env []string, binPath string) []string { // Lookup will try to find bin in the PATH in env. It will refer to PATHEXT for Windows support. // If bin can not be resolved to anything the original bin string is returned. func Lookup(env []string, bin string) string { + if strings.Contains(bin, string(filepath.Separator)) { + return bin + } + for _, env := range env { for _, prefix := range []string{"PATH=", "Path="} { suffix, ok := strings.CutPrefix(env, prefix) diff --git a/pkg/llm/registry.go b/pkg/llm/registry.go index ba648f58..c568b43c 100644 --- a/pkg/llm/registry.go +++ b/pkg/llm/registry.go @@ -7,6 +7,7 @@ import ( "sort" "github.com/gptscript-ai/gptscript/pkg/openai" + "github.com/gptscript-ai/gptscript/pkg/remote" "github.com/gptscript-ai/gptscript/pkg/types" ) @@ -41,11 +42,39 @@ func (r *Registry) ListModels(ctx context.Context, providers ...string) (result return result, nil } +func (r *Registry) fastPath(modelName string) Client { + // This is optimization hack to avoid doing List Models + if len(r.clients) != 2 { + return nil + } + + _, modelFromProvider := types.SplitToolRef(modelName) + if modelFromProvider != "" { + return nil + } + + _, ok := r.clients[0].(*openai.Client) + if !ok { + return nil + } + + _, ok = r.clients[1].(*remote.Client) + if !ok { + return nil + } + + return r.clients[0] +} + func (r *Registry) Call(ctx context.Context, messageRequest types.CompletionRequest, status chan<- types.CompletionStatus) (*types.CompletionMessage, error) { if messageRequest.Model == "" { return nil, fmt.Errorf("model is required") } + if c := r.fastPath(messageRequest.Model); c != nil { + return c.Call(ctx, messageRequest, status) + } + var errs []error var oaiClient *openai.Client for _, client := range r.clients { diff --git a/pkg/loader/url.go b/pkg/loader/url.go index 2035469e..41400790 100644 --- a/pkg/loader/url.go +++ b/pkg/loader/url.go @@ -7,6 +7,7 @@ import ( "net/http" url2 "net/url" "path" + "regexp" "strings" "time" @@ -33,6 +34,14 @@ type cacheValue struct { Time time.Time } +func (c *cacheKey) isStatic() bool { + return c.Repo != nil && + c.Repo.Revision != "" && + stableRef.MatchString(c.Repo.Revision) +} + +var stableRef = regexp.MustCompile("^([a-f0-9]{7,40}$|v[0-9]|[0-9])") + func loadURL(ctx context.Context, cache *cache.Client, base *source, name string) (*source, bool, error) { var ( repo *types.Repo @@ -47,9 +56,17 @@ func loadURL(ctx context.Context, cache *cache.Client, base *source, name string cachedValue cacheValue ) + if cachedKey.Repo == nil { + if _, rev, ok := strings.Cut(name, "@"); ok && stableRef.MatchString(rev) { + cachedKey.Repo = &types.Repo{ + Revision: rev, + } + } + } + if ok, err := cache.Get(ctx, cachedKey, &cachedValue); err != nil { return nil, false, err - } else if ok && time.Since(cachedValue.Time) < CacheTimeout { + } else if ok && (cachedKey.isStatic() || time.Since(cachedValue.Time) < CacheTimeout) { return cachedValue.Source, true, nil } From 3c5d2903a4d8fb26d64fe2b5ab6f79a04c6d17bb Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 21 Jul 2024 18:44:38 -0700 Subject: [PATCH 29/38] chore: only add agent tools for chat tools --- 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 ad483984..82effad4 100644 --- a/pkg/types/tool.go +++ b/pkg/types/tool.go @@ -660,10 +660,12 @@ func (t Tool) addContextExportedTools(prg Program, result *toolRefSet) error { func (t Tool) getCompletionToolRefs(prg Program, agentGroup []ToolReference) ([]ToolReference, error) { result := toolRefSet{} - for _, agent := range agentGroup { - // don't add yourself - if agent.ToolID != t.ID { - result.Add(agent) + if t.Chat { + for _, agent := range agentGroup { + // don't add yourself + if agent.ToolID != t.ID { + result.Add(agent) + } } } From f3194f7d599f5b3c575ce9ec83e37510af9e344c Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 21 Jul 2024 22:03:48 -0700 Subject: [PATCH 30/38] chore: add log message for installing uv --- pkg/repos/runtimes/python/python.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/repos/runtimes/python/python.go b/pkg/repos/runtimes/python/python.go index a5268f31..c031cb16 100644 --- a/pkg/repos/runtimes/python/python.go +++ b/pkg/repos/runtimes/python/python.go @@ -22,7 +22,7 @@ import ( //go:embed python.json var releasesData []byte -const uvVersion = "uv==0.2.3" +const uvVersion = "uv==0.2.27" type Release struct { OS string `json:"os,omitempty"` @@ -185,6 +185,7 @@ func (r *Runtime) runPip(ctx context.Context, toolSource, binDir string, env []s } func (r *Runtime) setupUV(ctx context.Context, tmp string) error { + log.InfofCtx(ctx, "Install uv %s", uvVersion) cmd := debugcmd.New(ctx, pythonCmd(tmp), "-m", "pip", "install", uvVersion) return cmd.Run() } From 13c31fd93ec0a559c1df0a8493808c2bbf597869 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Mon, 22 Jul 2024 12:28:27 -0400 Subject: [PATCH 31/38] fix: use default config in embedded SDK server Signed-off-by: Donnie Adams --- pkg/gptscript/gptscript.go | 4 ++-- pkg/sdkserver/server.go | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pkg/gptscript/gptscript.go b/pkg/gptscript/gptscript.go index d25915b1..462ee8b5 100644 --- a/pkg/gptscript/gptscript.go +++ b/pkg/gptscript/gptscript.go @@ -51,7 +51,7 @@ type Options struct { Env []string } -func complete(opts ...Options) Options { +func Complete(opts ...Options) Options { var result Options for _, opt := range opts { result.Cache = cache.Complete(result.Cache, opt.Cache) @@ -80,7 +80,7 @@ func complete(opts ...Options) Options { } func New(ctx context.Context, o ...Options) (*GPTScript, error) { - opts := complete(o...) + opts := Complete(o...) registry := llm.NewRegistry() cacheClient, err := cache.New(opts.Cache) diff --git a/pkg/sdkserver/server.go b/pkg/sdkserver/server.go index d0ca5a5f..26e449fe 100644 --- a/pkg/sdkserver/server.go +++ b/pkg/sdkserver/server.go @@ -55,7 +55,9 @@ func Run(ctx context.Context, opts Options) error { // EmbeddedStart allows running the server as an embedded process that may use Stdin for input. // It returns the address the server is listening on. -func EmbeddedStart(ctx context.Context, opts Options) (string, error) { +func EmbeddedStart(ctx context.Context, options ...Options) (string, error) { + opts := complete(options...) + listener, err := newListener(opts) if err != nil { return "", err @@ -138,3 +140,19 @@ func run(ctx context.Context, listener net.Listener, opts Options) error { <-done return nil } + +func complete(opts ...Options) Options { + var result Options + + for _, opt := range opts { + result.Options = gptscript.Complete(result.Options, opt.Options) + result.ListenAddress = types.FirstSet(opt.ListenAddress, result.ListenAddress) + result.Debug = types.FirstSet(opt.Debug, result.Debug) + } + + if result.ListenAddress == "" { + result.ListenAddress = "127.0.0.1:0" + } + + return result +} From 78b02e33c3bea5fad77e24eeefd3289f14b68c3a Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Mon, 22 Jul 2024 15:19:09 -0400 Subject: [PATCH 32/38] feat: add ability to disable server error logging Signed-off-by: Donnie Adams --- pkg/sdkserver/server.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/sdkserver/server.go b/pkg/sdkserver/server.go index 26e449fe..b1dffdef 100644 --- a/pkg/sdkserver/server.go +++ b/pkg/sdkserver/server.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "log" "net" "net/http" "os" @@ -24,8 +25,9 @@ import ( type Options struct { gptscript.Options - ListenAddress string - Debug bool + ListenAddress string + Debug bool + DisableServerErrorLogging bool } // Run will start the server and block until the server is shut down. @@ -121,6 +123,10 @@ func run(ctx context.Context, listener net.Listener, opts Options) error { ), } + if opts.DisableServerErrorLogging { + httpServer.ErrorLog = log.New(io.Discard, "", 0) + } + logger := mvl.Package() done := make(chan struct{}) context.AfterFunc(ctx, func() { From b5f2aebf9a75799fd38e10f86a07bf4f1d07b6cc Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Mon, 22 Jul 2024 18:19:03 -0400 Subject: [PATCH 33/38] feat: add a "contact us" link to the docs nav bar Signed-off-by: Donnie Adams --- docs/docusaurus.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index c48b8ac9..6a0eb3bc 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -65,6 +65,11 @@ const config = { label: "Discord", position: "right", }, + { + href: "mailto:info@acorn.io?subject=Reaching out from GPTScript Docs", + label: "Contact Us", + position: "right", + }, { href: "https://tools.gptscript.ai/", label: "Tool Search", From d54d11b7d57762f706e8d864acaf8a68cf3260bd Mon Sep 17 00:00:00 2001 From: Grant Linville Date: Tue, 23 Jul 2024 15:08:01 -0400 Subject: [PATCH 34/38] fix: normalize LLM-hallucinated tool names (#656) Signed-off-by: Grant Linville --- pkg/engine/engine.go | 2 +- pkg/tests/runner_test.go | 2 +- pkg/tests/testdata/TestMissingTool/call1-resp.golden | 2 +- pkg/tests/testdata/TestMissingTool/call2.golden | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 0ea72ff6..d3daa674 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -396,7 +396,7 @@ func (e *Engine) complete(ctx context.Context, state *State) (*Return, error) { } if toolID == "" { log.Debugf("failed to find tool id for tool %s in tool_call result", content.ToolCall.Function.Name) - toolID = content.ToolCall.Function.Name + toolID = types.ToolNormalizer(content.ToolCall.Function.Name) missing = true } state.Pending[content.ToolCall.ID] = *content.ToolCall diff --git a/pkg/tests/runner_test.go b/pkg/tests/runner_test.go index a38de6a2..70d5346c 100644 --- a/pkg/tests/runner_test.go +++ b/pkg/tests/runner_test.go @@ -954,7 +954,7 @@ func TestMissingTool(t *testing.T) { r.RespondWith(tester.Result{ Func: types.CompletionFunctionCall{ - Name: "not bob", + Name: "not.bob", }, }) diff --git a/pkg/tests/testdata/TestMissingTool/call1-resp.golden b/pkg/tests/testdata/TestMissingTool/call1-resp.golden index c9799ee8..4f4e82a0 100644 --- a/pkg/tests/testdata/TestMissingTool/call1-resp.golden +++ b/pkg/tests/testdata/TestMissingTool/call1-resp.golden @@ -5,7 +5,7 @@ "toolCall": { "id": "call_1", "function": { - "name": "not bob" + "name": "not.bob" } } } diff --git a/pkg/tests/testdata/TestMissingTool/call2.golden b/pkg/tests/testdata/TestMissingTool/call2.golden index 2fe99e81..c24d83f8 100644 --- a/pkg/tests/testdata/TestMissingTool/call2.golden +++ b/pkg/tests/testdata/TestMissingTool/call2.golden @@ -35,7 +35,7 @@ "toolCall": { "id": "call_1", "function": { - "name": "not bob" + "name": "not.bob" } } } @@ -46,13 +46,13 @@ "role": "tool", "content": [ { - "text": "ERROR: can not call unknown tool named [not bob]" + "text": "ERROR: can not call unknown tool named [notBob]" } ], "toolCall": { "id": "call_1", "function": { - "name": "not bob" + "name": "not.bob" } }, "usage": {} From 777f80815434ce62653db241ac2c35401919ba6c Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Tue, 23 Jul 2024 15:42:29 -0400 Subject: [PATCH 35/38] fix: set disable error logging when completing sdk server config Signed-off-by: Donnie Adams --- pkg/sdkserver/server.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/sdkserver/server.go b/pkg/sdkserver/server.go index b1dffdef..4ef28267 100644 --- a/pkg/sdkserver/server.go +++ b/pkg/sdkserver/server.go @@ -154,6 +154,7 @@ func complete(opts ...Options) Options { result.Options = gptscript.Complete(result.Options, opt.Options) result.ListenAddress = types.FirstSet(opt.ListenAddress, result.ListenAddress) result.Debug = types.FirstSet(opt.Debug, result.Debug) + result.DisableServerErrorLogging = types.FirstSet(opt.DisableServerErrorLogging, result.DisableServerErrorLogging) } if result.ListenAddress == "" { From 1b6811916413be5e0516b419e14edbd8736df8d1 Mon Sep 17 00:00:00 2001 From: Sangeetha Hariharan Date: Wed, 17 Jul 2024 16:51:38 -0700 Subject: [PATCH 36/38] Add faq for github rate limit --- docs/docs/09-faqs.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/docs/09-faqs.md b/docs/docs/09-faqs.md index b849e1d0..00f26700 100644 --- a/docs/docs/09-faqs.md +++ b/docs/docs/09-faqs.md @@ -53,3 +53,11 @@ This tells the LLM (by way of a [system message](https://platform.openai.com/doc This context also automatically shares the `sys.ls`, `sys.read`, and `sys.write` tools with the tool that is using it as a context. This is because if a tool intends to interact with the workspace, it minimally needs these tools. +### I'm hitting GitHub's rate limit for unauthenticated requests when using GPTScript. + +By default, GPTScript makes unauthenticated requests to GitHub when pulling tools. Since GitHub's rate limits for unauthenticated requests are fairly low, running into them when developing with GPTScript is a common issue. To avoid this, you can get GPTScript to make authenticated requests -- which have higher rate limits -- by setting the `GITHUB_AUTH_TOKEN` environment variable to your github account's PAT (Personal Access Token). +If you're already authenticated with the `gh` CLI, you can use its token by running: + +```bash +export GITHUB_AUTH_TOKEN="$(gh auth token)" +``` From 9d739fc7086d3f7abfffbf1378422e3ef6ca5616 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Sat, 27 Jul 2024 11:42:18 -0400 Subject: [PATCH 37/38] feat: add force sequential option to SDK server Signed-off-by: Donnie Adams --- pkg/sdkserver/routes.go | 1 + pkg/sdkserver/types.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/sdkserver/routes.go b/pkg/sdkserver/routes.go index e17a2d1a..e0977c9e 100644 --- a/pkg/sdkserver/routes.go +++ b/pkg/sdkserver/routes.go @@ -202,6 +202,7 @@ func (s *server) execHandler(w http.ResponseWriter, r *http.Request) { // Set the monitor factory so that we can get events from the server. MonitorFactory: NewSessionFactory(s.events), CredentialOverrides: reqObject.CredentialOverrides, + Sequential: reqObject.ForceSequential, }, } diff --git a/pkg/sdkserver/types.go b/pkg/sdkserver/types.go index 478c6565..06119c35 100644 --- a/pkg/sdkserver/types.go +++ b/pkg/sdkserver/types.go @@ -62,6 +62,7 @@ type toolOrFileRequest struct { CredentialOverrides []string `json:"credentialOverrides"` Confirm bool `json:"confirm"` Location string `json:"location,omitempty"` + ForceSequential bool `json:"forceSequential"` } type content struct { From 36c961cf2d06fec872b62547d617233fd2451c80 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 27 Jul 2024 21:57:06 -0700 Subject: [PATCH 38/38] chore: bump tui --- go.mod | 4 ++-- go.sum | 8 ++++---- pkg/cli/gptscript.go | 9 ++++++--- pkg/parser/parser.go | 10 +++++----- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 1e379045..9feaef4f 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,8 @@ require ( github.com/gptscript-ai/broadcaster v0.0.0-20240625175512-c43682019b86 github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf0379 github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d - github.com/gptscript-ai/tui v0.0.0-20240722014329-d50b5ac5db74 + github.com/gptscript-ai/go-gptscript v0.9.3-0.20240728044543-20d868b5baa6 + github.com/gptscript-ai/tui v0.0.0-20240728045051-19ba83cd96c1 github.com/hexops/autogold/v2 v2.2.1 github.com/hexops/valast v1.4.4 github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 @@ -63,7 +64,6 @@ require ( github.com/google/go-cmp v0.6.0 // indirect github.com/gookit/color v1.5.4 // indirect github.com/gorilla/css v1.0.0 // indirect - github.com/gptscript-ai/go-gptscript v0.9.3-0.20240722014125-d757d09f606b // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hexops/autogold v1.3.1 // indirect diff --git a/go.sum b/go.sum index 881c5073..9c288064 100644 --- a/go.sum +++ b/go.sum @@ -171,10 +171,10 @@ github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf037 github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf0379/go.mod h1:7P/o6/IWa1KqsntVf68hSnLKuu3+xuqm6lYhch1w4jo= github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d h1:sKf7T7twhGXs6AVbvD9pKDVewykkwSAPwEpmIEQIR/4= github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d/go.mod h1:DJAo1xTht1LDkNYFNydVjTHd576TC7MlpsVRl3oloVw= -github.com/gptscript-ai/go-gptscript v0.9.3-0.20240722014125-d757d09f606b h1:Hxu8oPE43uQ2sZ7P+9yGSX9bXh0RoJfOgvY/SlCwFlM= -github.com/gptscript-ai/go-gptscript v0.9.3-0.20240722014125-d757d09f606b/go.mod h1:Dh6vYRAiVcyC3ElZIGzTvNF1FxtYwA07BHfSiFKQY7s= -github.com/gptscript-ai/tui v0.0.0-20240722014329-d50b5ac5db74 h1:69BENZCN2y4BCxmPjMRp+ZQ47ay4i5gRgREKZatu5oE= -github.com/gptscript-ai/tui v0.0.0-20240722014329-d50b5ac5db74/go.mod h1:sP/9g7+nLq65aGef5F30AEG+Cuu4BwlglUYv1Pzps4Y= +github.com/gptscript-ai/go-gptscript v0.9.3-0.20240728044543-20d868b5baa6 h1:hF9Q8KdQhuoXSGKVh4ywRvwn5RJt9rbPraigpXqbGYU= +github.com/gptscript-ai/go-gptscript v0.9.3-0.20240728044543-20d868b5baa6/go.mod h1:Dh6vYRAiVcyC3ElZIGzTvNF1FxtYwA07BHfSiFKQY7s= +github.com/gptscript-ai/tui v0.0.0-20240728045051-19ba83cd96c1 h1:gJXswjjwoiWdOS+s73mliWbN9dyJpiUkb3T+EiV7EFc= +github.com/gptscript-ai/tui v0.0.0-20240728045051-19ba83cd96c1/go.mod h1:Llh3vi87gyry6j/sgJxhkHHvgv9uQRzEiMWuQtmpW1w= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= diff --git a/pkg/cli/gptscript.go b/pkg/cli/gptscript.go index f539f516..c22a25d2 100644 --- a/pkg/cli/gptscript.go +++ b/pkg/cli/gptscript.go @@ -13,6 +13,7 @@ import ( "github.com/fatih/color" "github.com/gptscript-ai/cmd" + gptscript2 "github.com/gptscript-ai/go-gptscript" "github.com/gptscript-ai/gptscript/pkg/assemble" "github.com/gptscript-ai/gptscript/pkg/auth" "github.com/gptscript-ai/gptscript/pkg/builtin" @@ -464,9 +465,11 @@ func (r *GPTScript) Run(cmd *cobra.Command, args []string) (retErr error) { if !r.DisableTUI && !r.Debug && !r.DebugMessages && !r.NoTrunc { // Don't use cmd.Context() because then sigint will cancel everything return tui.Run(context.Background(), args[0], tui.RunOptions{ - OpenAIAPIKey: r.OpenAIOptions.APIKey, - OpenAIBaseURL: r.OpenAIOptions.BaseURL, - DefaultModel: r.DefaultModel, + ClientOpts: &gptscript2.GlobalOptions{ + OpenAIAPIKey: r.OpenAIOptions.APIKey, + OpenAIBaseURL: r.OpenAIOptions.BaseURL, + DefaultModel: r.DefaultModel, + }, TrustedRepoPrefixes: []string{"github.com/gptscript-ai"}, DisableCache: r.DisableCache, CredentialOverrides: r.CredentialOverride, diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index f7c750c1..d12f838e 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -101,23 +101,23 @@ func isParam(line string, tool *types.Tool) (_ bool, err error) { return false, err } tool.Parameters.Chat = v - case "export", "exporttool", "exports", "exporttools", "sharetool", "sharetools": + case "export", "exporttool", "exports", "exporttools", "sharetool", "sharetools", "sharedtool", "sharedtools": tool.Parameters.Export = append(tool.Parameters.Export, csv(value)...) case "tool", "tools": tool.Parameters.Tools = append(tool.Parameters.Tools, csv(value)...) case "inputfilter", "inputfilters": tool.Parameters.InputFilters = append(tool.Parameters.InputFilters, csv(value)...) - case "shareinputfilter", "shareinputfilters": + case "shareinputfilter", "shareinputfilters", "sharedinputfilter", "sharedinputfilters": tool.Parameters.ExportInputFilters = append(tool.Parameters.ExportInputFilters, csv(value)...) case "outputfilter", "outputfilters": tool.Parameters.OutputFilters = append(tool.Parameters.OutputFilters, csv(value)...) - case "shareoutputfilter", "shareoutputfilters": + case "shareoutputfilter", "shareoutputfilters", "sharedoutputfilter", "sharedoutputfilters": tool.Parameters.ExportOutputFilters = append(tool.Parameters.ExportOutputFilters, csv(value)...) case "agent", "agents": tool.Parameters.Agents = append(tool.Parameters.Agents, csv(value)...) case "globaltool", "globaltools": tool.Parameters.GlobalTools = append(tool.Parameters.GlobalTools, csv(value)...) - case "exportcontext", "exportcontexts", "sharecontext", "sharecontexts": + case "exportcontext", "exportcontexts", "sharecontext", "sharecontexts", "sharedcontext", "sharedcontexts": tool.Parameters.ExportContext = append(tool.Parameters.ExportContext, csv(value)...) case "context": tool.Parameters.Context = append(tool.Parameters.Context, csv(value)...) @@ -148,7 +148,7 @@ func isParam(line string, tool *types.Tool) (_ bool, err error) { } case "credentials", "creds", "credential", "cred": tool.Parameters.Credentials = append(tool.Parameters.Credentials, value) - case "sharecredentials", "sharecreds", "sharecredential", "sharecred": + case "sharecredentials", "sharecreds", "sharecredential", "sharecred", "sharedcredentials", "sharedcreds", "sharedcredential", "sharedcred": tool.Parameters.ExportCredentials = append(tool.Parameters.ExportCredentials, value) default: return false, nil