beeai-framework 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/vercel/backend/chat.cjs +0 -1
- package/dist/adapters/vercel/backend/chat.cjs.map +1 -1
- package/dist/adapters/vercel/backend/chat.js +0 -1
- package/dist/adapters/vercel/backend/chat.js.map +1 -1
- package/dist/adapters/watsonx/backend/chat.cjs +6 -2
- package/dist/adapters/watsonx/backend/chat.cjs.map +1 -1
- package/dist/adapters/watsonx/backend/chat.d.cts +1 -1
- package/dist/adapters/watsonx/backend/chat.d.ts +1 -1
- package/dist/adapters/watsonx/backend/chat.js +6 -2
- package/dist/adapters/watsonx/backend/chat.js.map +1 -1
- package/dist/agent-Bf2FaCKy.d.ts +84 -0
- package/dist/agent-Bpt7IFa_.d.cts +84 -0
- package/dist/agents/experimental/remote/agent.cjs +25 -18
- package/dist/agents/experimental/remote/agent.cjs.map +1 -1
- package/dist/agents/experimental/remote/agent.d.cts +4 -3
- package/dist/agents/experimental/remote/agent.d.ts +4 -3
- package/dist/agents/experimental/remote/agent.js +26 -19
- package/dist/agents/experimental/remote/agent.js.map +1 -1
- package/dist/agents/{bee → react}/agent.cjs +5 -5
- package/dist/agents/react/agent.cjs.map +1 -0
- package/dist/agents/{bee → react}/agent.d.cts +1 -1
- package/dist/agents/{bee → react}/agent.d.ts +1 -1
- package/dist/agents/{bee → react}/agent.js +5 -5
- package/dist/agents/react/agent.js.map +1 -0
- package/dist/agents/{bee → react}/prompts.cjs +18 -18
- package/dist/agents/react/prompts.cjs.map +1 -0
- package/dist/agents/{bee → react}/prompts.d.cts +10 -10
- package/dist/agents/{bee → react}/prompts.d.ts +10 -10
- package/dist/agents/{bee → react}/prompts.js +10 -10
- package/dist/agents/react/prompts.js.map +1 -0
- package/dist/agents/{bee → react}/runners/base.cjs +1 -1
- package/dist/agents/{bee → react}/runners/base.cjs.map +1 -1
- package/dist/agents/{bee → react}/runners/base.d.cts +1 -1
- package/dist/agents/{bee → react}/runners/base.d.ts +1 -1
- package/dist/agents/{bee → react}/runners/base.js +1 -1
- package/dist/agents/{bee → react}/runners/base.js.map +1 -1
- package/dist/agents/{bee → react}/runners/deep-think/prompts.cjs +14 -14
- package/dist/agents/react/runners/deep-think/prompts.cjs.map +1 -0
- package/dist/agents/{bee/runners/granite → react/runners/deep-think}/prompts.d.cts +8 -8
- package/dist/agents/{bee/runners/granite → react/runners/deep-think}/prompts.d.ts +8 -8
- package/dist/agents/{bee → react}/runners/deep-think/prompts.js +9 -9
- package/dist/agents/react/runners/deep-think/prompts.js.map +1 -0
- package/dist/agents/{bee → react}/runners/deep-think/runner.cjs +10 -10
- package/dist/agents/react/runners/deep-think/runner.cjs.map +1 -0
- package/dist/agents/{bee → react}/runners/deep-think/runner.d.cts +4 -4
- package/dist/agents/{bee → react}/runners/deep-think/runner.d.ts +4 -4
- package/dist/agents/{bee → react}/runners/deep-think/runner.js +12 -12
- package/dist/agents/react/runners/deep-think/runner.js.map +1 -0
- package/dist/agents/{bee → react}/runners/default/runner.cjs +10 -10
- package/dist/agents/react/runners/default/runner.cjs.map +1 -0
- package/dist/agents/{bee → react}/runners/default/runner.d.cts +7 -7
- package/dist/agents/{bee → react}/runners/default/runner.d.ts +7 -7
- package/dist/agents/{bee → react}/runners/default/runner.js +11 -11
- package/dist/agents/react/runners/default/runner.js.map +1 -0
- package/dist/agents/{bee → react}/runners/default/runner.spec.cjs +5 -5
- package/dist/agents/react/runners/default/runner.spec.cjs.map +1 -0
- package/dist/agents/{bee → react}/runners/default/runner.spec.js +6 -6
- package/dist/agents/react/runners/default/runner.spec.js.map +1 -0
- package/dist/agents/{bee → react}/runners/granite/prompts.cjs +14 -14
- package/dist/agents/react/runners/granite/prompts.cjs.map +1 -0
- package/dist/agents/{bee/runners/deep-think → react/runners/granite}/prompts.d.cts +8 -8
- package/dist/agents/{bee/runners/deep-think → react/runners/granite}/prompts.d.ts +8 -8
- package/dist/agents/{bee → react}/runners/granite/prompts.js +9 -9
- package/dist/agents/react/runners/granite/prompts.js.map +1 -0
- package/dist/agents/{bee → react}/runners/granite/runner.cjs +10 -10
- package/dist/agents/react/runners/granite/runner.cjs.map +1 -0
- package/dist/agents/{bee → react}/runners/granite/runner.d.cts +4 -4
- package/dist/agents/{bee → react}/runners/granite/runner.d.ts +4 -4
- package/dist/agents/{bee → react}/runners/granite/runner.js +12 -12
- package/dist/agents/react/runners/granite/runner.js.map +1 -0
- package/dist/agents/{bee → react}/types.d.cts +45 -45
- package/dist/agents/{bee → react}/types.d.ts +45 -45
- package/dist/agents/toolCalling/agent.cjs +208 -0
- package/dist/agents/toolCalling/agent.cjs.map +1 -0
- package/dist/agents/toolCalling/agent.d.cts +70 -0
- package/dist/agents/toolCalling/agent.d.ts +70 -0
- package/dist/agents/toolCalling/agent.js +206 -0
- package/dist/agents/toolCalling/agent.js.map +1 -0
- package/dist/agents/toolCalling/prompts.cjs +65 -0
- package/dist/agents/toolCalling/prompts.cjs.map +1 -0
- package/dist/agents/toolCalling/prompts.d.cts +49 -0
- package/dist/agents/toolCalling/prompts.d.ts +49 -0
- package/dist/agents/toolCalling/prompts.js +62 -0
- package/dist/agents/toolCalling/prompts.js.map +1 -0
- package/dist/agents/toolCalling/types.cjs +4 -0
- package/dist/agents/toolCalling/types.cjs.map +1 -0
- package/dist/agents/toolCalling/types.d.cts +66 -0
- package/dist/agents/toolCalling/types.d.ts +66 -0
- package/dist/agents/toolCalling/types.js +3 -0
- package/dist/agents/toolCalling/types.js.map +1 -0
- package/dist/backend/chat.cjs +3 -0
- package/dist/backend/chat.cjs.map +1 -1
- package/dist/backend/chat.d.cts +2 -1
- package/dist/backend/chat.d.ts +2 -1
- package/dist/backend/chat.js +3 -0
- package/dist/backend/chat.js.map +1 -1
- package/dist/backend/message.cjs +9 -0
- package/dist/backend/message.cjs.map +1 -1
- package/dist/backend/message.d.cts +2 -0
- package/dist/backend/message.d.ts +2 -0
- package/dist/backend/message.js +9 -0
- package/dist/backend/message.js.map +1 -1
- package/dist/instrumentation/create-telemetry-middleware.cjs.map +1 -1
- package/dist/instrumentation/create-telemetry-middleware.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist/workflows/agent.cjs +2 -2
- package/dist/workflows/agent.cjs.map +1 -1
- package/dist/workflows/agent.d.cts +4 -4
- package/dist/workflows/agent.d.ts +4 -4
- package/dist/workflows/agent.js +2 -2
- package/dist/workflows/agent.js.map +1 -1
- package/package.json +3 -3
- package/dist/agent-BZ-_ATuJ.d.cts +0 -84
- package/dist/agent-BqoZ6FbM.d.ts +0 -84
- package/dist/agents/bee/agent.cjs.map +0 -1
- package/dist/agents/bee/agent.js.map +0 -1
- package/dist/agents/bee/prompts.cjs.map +0 -1
- package/dist/agents/bee/prompts.js.map +0 -1
- package/dist/agents/bee/runners/deep-think/prompts.cjs.map +0 -1
- package/dist/agents/bee/runners/deep-think/prompts.js.map +0 -1
- package/dist/agents/bee/runners/deep-think/runner.cjs.map +0 -1
- package/dist/agents/bee/runners/deep-think/runner.js.map +0 -1
- package/dist/agents/bee/runners/default/runner.cjs.map +0 -1
- package/dist/agents/bee/runners/default/runner.js.map +0 -1
- package/dist/agents/bee/runners/default/runner.spec.cjs.map +0 -1
- package/dist/agents/bee/runners/default/runner.spec.js.map +0 -1
- package/dist/agents/bee/runners/granite/prompts.cjs.map +0 -1
- package/dist/agents/bee/runners/granite/prompts.js.map +0 -1
- package/dist/agents/bee/runners/granite/runner.cjs.map +0 -1
- package/dist/agents/bee/runners/granite/runner.js.map +0 -1
- /package/dist/agents/{bee → react}/runners/default/runner.spec.d.cts +0 -0
- /package/dist/agents/{bee → react}/runners/default/runner.spec.d.ts +0 -0
- /package/dist/agents/{bee → react}/types.cjs +0 -0
- /package/dist/agents/{bee → react}/types.cjs.map +0 -0
- /package/dist/agents/{bee → react}/types.js +0 -0
- /package/dist/agents/{bee → react}/types.js.map +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DefaultRunner } from './runner.js';
|
|
2
2
|
import { UnconstrainedMemory } from '../../../../memory/unconstrainedMemory.js';
|
|
3
3
|
import { UserMessage, AssistantMessage, Role } from '../../../../backend/message.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ReActAgentUserPrompt } from '../../prompts.js';
|
|
5
5
|
import { zip } from 'remeda';
|
|
6
6
|
import { RunContext } from '../../../../context.js';
|
|
7
7
|
|
|
@@ -19,7 +19,7 @@ vi.mock("@/memory/tokenMemory.js", async () => {
|
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
21
|
vi.mock("@/context.js");
|
|
22
|
-
describe("
|
|
22
|
+
describe("ReAct Agent Runner", () => {
|
|
23
23
|
beforeEach(() => {
|
|
24
24
|
vi.useRealTimers();
|
|
25
25
|
});
|
|
@@ -57,22 +57,22 @@ describe("Bee Agent Runner", () => {
|
|
|
57
57
|
expect(instance.memory.messages).toEqual(instance2.memory.messages);
|
|
58
58
|
});
|
|
59
59
|
it.each([
|
|
60
|
-
|
|
60
|
+
ReActAgentUserPrompt.fork((old) => ({
|
|
61
61
|
...old,
|
|
62
62
|
functions: {
|
|
63
63
|
...old.functions,
|
|
64
64
|
formatMeta: /* @__PURE__ */ __name(() => "", "formatMeta")
|
|
65
65
|
}
|
|
66
66
|
})),
|
|
67
|
-
|
|
67
|
+
ReActAgentUserPrompt.fork((old) => ({
|
|
68
68
|
...old,
|
|
69
69
|
template: `{{input}}`
|
|
70
70
|
})),
|
|
71
|
-
|
|
71
|
+
ReActAgentUserPrompt.fork((old) => ({
|
|
72
72
|
...old,
|
|
73
73
|
template: `User: {{input}}`
|
|
74
74
|
})),
|
|
75
|
-
|
|
75
|
+
ReActAgentUserPrompt.fork((old) => ({
|
|
76
76
|
...old,
|
|
77
77
|
template: ``
|
|
78
78
|
}))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["runner.spec.ts"],"names":["vi","mock","UnconstrainedMemory","TokenMemory","describe","beforeEach","useRealTimers","it","useFakeTimers","setSystemTime","Date","createMemory","memory","addMany","UserMessage","AssistantMessage","createInstance","prompt","instance","DefaultRunner","llm","expect","any","Function","tools","templates","RunContext","init","memory2","add","createdAt","instance2","messages","toEqual","each","ReActAgentUserPrompt","fork","old","functions","formatMeta","template","user","a","b","zip","filter","msg","role","Role","USER","render","input","text","meta","undefined","toStrictEqual"],"mappings":";;;;;;;;;AAyBAA,EAAGC,CAAAA,IAAAA,CAAK,2BAA2B,YAAA;AACjC,EAAA,MAAM,EAAEC,mBAAAA,EAAAA,oBAAAA,EAAwB,GAAA,MAAM,OAAO,2CAAA,CAAA;AAC7C,EAAMC,IAAAA,WAAAA,GAAN,MAAMA,WAAAA,SAAoBD,oBAAAA,CAAAA;IA3B5B;;;AA2BiD,GAAA;AAC/C,EAAO,OAAA;AAAEC,IAAAA;AAAY,GAAA;AACvB,CAAA,CAAA;AAEAH,EAAAA,CAAGC,KAAK,cAAA,CAAA;AAERG,QAAAA,CAAS,sBAAsB,MAAA;AAC7BC,EAAAA,UAAAA,CAAW,MAAA;AACTL,IAAAA,EAAAA,CAAGM,aAAa,EAAA;GAClB,CAAA;AAEAC,EAAAA,EAAAA,CAAG,yCAAyC,YAAA;AAC1CP,IAAAA,EAAAA,CAAGQ,aAAa,EAAA;AAChBR,IAAAA,EAAAA,CAAGS,aAAc,iBAAA,IAAIC,IAAK,CAAA,0BAAA,CAAA,CAAA;AAE1B,IAAA,MAAMC,+BAAe,MAAA,CAAA,YAAA;AACnB,MAAMC,MAAAA,OAAAA,GAAS,IAAIV,mBAAAA,EAAAA;AACnB,MAAA,MAAMU,QAAOC,OAAQ,CAAA;AACnB,QAAA,IAAIC,YAAY,oBAAA,CAAA;AAChB,QAAA,IAAIC,iBAAiB,UAAA;AACtB,OAAA,CAAA;AACD,MAAOH,OAAAA,OAAAA;KANY,EAAA,cAAA,CAAA;AASrB,IAAMI,MAAAA,cAAAA,mBAAwBJ,MAAAA,CAAAA,OAAAA,OAAAA,EAAo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CAAAA,IAAAA,KAASC,KAAKC,IAAI,CAAA;AAAG,MAAA,IAAInC,YAAYG,MAAAA;OAC7EC,QAASN,CAAAA,MAAAA,CAAOoB,QAASa,CAAAA,MAAAA,CAAO,CAACC,GAAAA,KAAQA,IAAIC,IAASC,KAAAA,IAAAA,CAAKC,IAAI,CAAA,CAC9D,EAAA;AACD5B,MAAAA,MAAAA,CAAOmB,SAASU,MAAO,CAAA;AAAEC,QAAAA,KAAAA,EAAOT,CAAEU,CAAAA,IAAAA;QAAMC,IAAMC,EAAAA;AAAU,OAAA,CAAA,CAAA,CAAIC,aAAcZ,CAAAA,CAAAA,CAAES,IAAI,CAAA;AAClF;GACF,CAAA;AACF,CAAA,CAAA","file":"runner.spec.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { AssistantMessage, Role, UserMessage } from \"@/backend/message.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { ReActAgentUserPrompt } from \"@/agents/react/prompts.js\";\nimport { zip } from \"remeda\";\nimport { RunContext } from \"@/context.js\";\nimport { ReActAgent } from \"@/agents/react/agent.js\";\n\nvi.mock(\"@/memory/tokenMemory.js\", async () => {\n const { UnconstrainedMemory } = await import(\"@/memory/unconstrainedMemory.js\");\n class TokenMemory extends UnconstrainedMemory {}\n return { TokenMemory };\n});\n\nvi.mock(\"@/context.js\");\n\ndescribe(\"ReAct Agent Runner\", () => {\n beforeEach(() => {\n vi.useRealTimers();\n });\n\n it(\"Handles different prompt input source\", async () => {\n vi.useFakeTimers();\n vi.setSystemTime(new Date(\"2024-09-10T19:51:46.954Z\"));\n\n const createMemory = async () => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([\n new UserMessage(\"What is your name?\"),\n new AssistantMessage(\"I am Bee\"),\n ]);\n return memory;\n };\n\n const createInstance = async (memory: BaseMemory, prompt: string | null) => {\n const instance = new DefaultRunner(\n {\n llm: expect.any(Function),\n memory,\n tools: [],\n templates: {},\n },\n {},\n new RunContext<ReActAgent, any>({} as any, {} as any),\n );\n await instance.init({ prompt });\n return instance;\n };\n\n const memory = await createMemory();\n const prompt = \"What can you do for me?\";\n const instance = await createInstance(memory, prompt);\n\n const memory2 = await createMemory();\n await memory2.add(new UserMessage(prompt, { createdAt: new Date() }));\n const instance2 = await createInstance(memory2, null);\n expect(instance.memory.messages).toEqual(instance2.memory.messages);\n });\n\n it.each([\n ReActAgentUserPrompt.fork((old) => ({\n ...old,\n functions: { ...old.functions, formatMeta: () => \"\" },\n })),\n ReActAgentUserPrompt.fork((old) => ({ ...old, template: `{{input}}` })),\n ReActAgentUserPrompt.fork((old) => ({ ...old, template: `User: {{input}}` })),\n ReActAgentUserPrompt.fork((old) => ({ ...old, template: `` })),\n ])(\"Correctly formats user input\", async (template: typeof ReActAgentUserPrompt) => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([\n new UserMessage(\"What is your name?\"),\n new AssistantMessage(\"Bee\"),\n new UserMessage(\"Who are you?\"),\n new AssistantMessage(\"I am a helpful assistant.\"),\n ]);\n\n const prompt = \"What can you do for me?\";\n const instance = new DefaultRunner(\n {\n llm: expect.any(Function),\n memory,\n tools: [],\n templates: {\n user: template,\n },\n },\n {},\n new RunContext<ReActAgent, any>({} as any, {} as any),\n );\n await instance.init({ prompt });\n\n for (const [a, b] of zip(\n [...memory.messages.filter((msg) => msg.role === Role.USER), new UserMessage(prompt)],\n instance.memory.messages.filter((msg) => msg.role === Role.USER),\n )) {\n expect(template.render({ input: a.text, meta: undefined })).toStrictEqual(b.text);\n }\n });\n});\n"]}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var prompts_cjs = require('../../prompts.cjs');
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const GraniteReActAgentAssistantPrompt = prompts_cjs.ReActAgentAssistantPrompt.fork((config) => {
|
|
6
6
|
config.template = `{{#thought}}Thought: {{.}}
|
|
7
7
|
{{/thought}}{{#toolName}}Tool Name: {{.}}
|
|
8
8
|
{{/toolName}}{{#toolInput}}Tool Input: {{.}}
|
|
9
9
|
{{/toolInput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`;
|
|
10
10
|
});
|
|
11
|
-
const
|
|
11
|
+
const GraniteReActAgentSystemPrompt = prompts_cjs.ReActAgentSystemPrompt.fork((config) => {
|
|
12
12
|
config.defaults.instructions = "";
|
|
13
13
|
config.functions.formatDate = function() {
|
|
14
14
|
const date = this.createdAt ? new Date(this.createdAt) : /* @__PURE__ */ new Date();
|
|
@@ -59,36 +59,36 @@ You do not need a tool to get the current Date and Time. Use the information ava
|
|
|
59
59
|
{{/instructions}}
|
|
60
60
|
`;
|
|
61
61
|
});
|
|
62
|
-
const
|
|
62
|
+
const GraniteReActAgentSchemaErrorPrompt = prompts_cjs.ReActAgentSchemaErrorPrompt.fork((config) => {
|
|
63
63
|
config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.
|
|
64
64
|
You communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input' or 'Thought' followed by 'Final Answer'.`;
|
|
65
65
|
});
|
|
66
|
-
const
|
|
66
|
+
const GraniteReActAgentUserPrompt = prompts_cjs.ReActAgentUserPrompt.fork((config) => {
|
|
67
67
|
config.template = `{{input}}`;
|
|
68
68
|
});
|
|
69
|
-
const
|
|
69
|
+
const GraniteReActAgentToolNotFoundPrompt = prompts_cjs.ReActAgentToolNotFoundPrompt.fork((config) => {
|
|
70
70
|
config.template = `Tool does not exist!
|
|
71
71
|
{{#tools.length}}
|
|
72
72
|
Use one of the following tools: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}
|
|
73
73
|
{{/tools.length}}`;
|
|
74
74
|
});
|
|
75
|
-
const
|
|
75
|
+
const GraniteReActAgentToolErrorPrompt = prompts_cjs.ReActAgentToolErrorPrompt.fork((config) => {
|
|
76
76
|
config.template = `The tool has failed; the error log is shown below. If the tool cannot accomplish what you want, use a different tool or explain why you can't use it.
|
|
77
77
|
|
|
78
78
|
{{reason}}`;
|
|
79
79
|
});
|
|
80
|
-
const
|
|
80
|
+
const GraniteReActAgentToolInputErrorPrompt = prompts_cjs.ReActAgentToolInputErrorPrompt.fork((config) => {
|
|
81
81
|
config.template = `{{reason}}
|
|
82
82
|
|
|
83
83
|
HINT: If you're convinced that the input was correct but the tool cannot process it then use a different tool or say I don't know.`;
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
exports.
|
|
87
|
-
exports.
|
|
88
|
-
exports.
|
|
89
|
-
exports.
|
|
90
|
-
exports.
|
|
91
|
-
exports.
|
|
92
|
-
exports.
|
|
86
|
+
exports.GraniteReActAgentAssistantPrompt = GraniteReActAgentAssistantPrompt;
|
|
87
|
+
exports.GraniteReActAgentSchemaErrorPrompt = GraniteReActAgentSchemaErrorPrompt;
|
|
88
|
+
exports.GraniteReActAgentSystemPrompt = GraniteReActAgentSystemPrompt;
|
|
89
|
+
exports.GraniteReActAgentToolErrorPrompt = GraniteReActAgentToolErrorPrompt;
|
|
90
|
+
exports.GraniteReActAgentToolInputErrorPrompt = GraniteReActAgentToolInputErrorPrompt;
|
|
91
|
+
exports.GraniteReActAgentToolNotFoundPrompt = GraniteReActAgentToolNotFoundPrompt;
|
|
92
|
+
exports.GraniteReActAgentUserPrompt = GraniteReActAgentUserPrompt;
|
|
93
93
|
//# sourceMappingURL=prompts.cjs.map
|
|
94
94
|
//# sourceMappingURL=prompts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["prompts.ts"],"names":["GraniteReActAgentAssistantPrompt","ReActAgentAssistantPrompt","fork","config","template","GraniteReActAgentSystemPrompt","ReActAgentSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","GraniteReActAgentSchemaErrorPrompt","ReActAgentSchemaErrorPrompt","GraniteReActAgentUserPrompt","ReActAgentUserPrompt","GraniteReActAgentToolNotFoundPrompt","ReActAgentToolNotFoundPrompt","GraniteReActAgentToolErrorPrompt","ReActAgentToolErrorPrompt","GraniteReActAgentToolInputErrorPrompt","ReActAgentToolInputErrorPrompt"],"mappings":";;;;AA0BO,MAAMA,gCAAmCC,GAAAA,qCAAAA,CAA0BC,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAC9EA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;AACpB,CAAA;AAEO,MAAMC,6BAAgCC,GAAAA,kCAAAA,CAAuBJ,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACxEA,EAAAA,MAAAA,CAAOI,SAASC,YAAe,GAAA,EAAA;AAC/BL,EAAOM,MAAAA,CAAAA,SAAAA,CAAUC,aAAa,WAAA;AAC5B,IAAMC,MAAAA,IAAAA,GAAO,KAAKC,SAAY,GAAA,IAAIC,KAAK,IAAKD,CAAAA,SAAS,CAAI,mBAAA,IAAIC,IAAAA,EAAAA;AAC7D,IAAO,OAAA,IAAIC,IAAKC,CAAAA,cAAAA,CAAe,OAAS,EAAA;MACtCC,SAAW,EAAA,MAAA;MACXC,SAAW,EAAA;KACb,CAAA,CAAGC,OAAOP,IAAAA,CAAAA;AACZ,GAAA;AACAR,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCpB,CAAA;AAEO,MAAMe,kCAAqCC,GAAAA,uCAAAA,CAA4BlB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAClFA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;AAEpB,CAAA;AAEO,MAAMiB,2BAA8BC,GAAAA,gCAAAA,CAAqBpB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACpEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA,SAAA,CAAA;AACpB,CAAA;AAEO,MAAMmB,mCAAsCC,GAAAA,wCAAAA,CAA6BtB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACpFA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;AAIpB,CAAA;AAEO,MAAMqB,gCAAmCC,GAAAA,qCAAAA,CAA0BxB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAC9EA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;AAGpB,CAAA;AAEO,MAAMuB,qCAAwCC,GAAAA,0CAAAA,CAA+B1B,IAClF,CAAA,CAACC,MAAAA,KAAAA;AACCA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;AAGpB,CAAA","file":"prompts.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ReActAgentAssistantPrompt,\n ReActAgentSchemaErrorPrompt,\n ReActAgentSystemPrompt,\n ReActAgentToolErrorPrompt,\n ReActAgentToolInputErrorPrompt,\n ReActAgentToolNotFoundPrompt,\n ReActAgentUserPrompt,\n} from \"@/agents/react/prompts.js\";\n\nexport const GraniteReActAgentAssistantPrompt = ReActAgentAssistantPrompt.fork((config) => {\n config.template = `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Tool Name: {{.}}\\n{{/toolName}}{{#toolInput}}Tool Input: {{.}}\\n{{/toolInput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`;\n});\n\nexport const GraniteReActAgentSystemPrompt = ReActAgentSystemPrompt.fork((config) => {\n config.defaults.instructions = \"\";\n config.functions.formatDate = function () {\n const date = this.createdAt ? new Date(this.createdAt) : new Date();\n return new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"full\",\n timeStyle: \"medium\",\n }).format(date);\n };\n config.template = `You are an AI assistant.\nWhen the user sends a message figure out a solution and provide a final answer.\n{{#tools.length}}\nYou have access to a set of tools that can be used to retrieve information and perform actions.\nPay close attention to the tool description to determine if a tool is useful in a particular context.\n{{/tools.length}}\n\n# Communication structure\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input', or 'Thought' followed by 'Final Answer'\n\nLine starting 'Thought: ' The assistant's response always starts with a thought, this is a single line where the assistant thinks about the user's message and describes in detail what it should do next.\n{{#tools.length}}\nIn a 'Thought: ', the assistant should determine if a Tool Call is necessary to get more information or perform an action, or if the available information is sufficient to provide the Final Answer.\nIf a tool needs to be called and is available, the assistant will produce a tool call:\nLine starting 'Tool Name: ' name of the tool that you want to use.\nLine starting 'Tool Input: ' JSON formatted tool arguments adhering to the selected tool parameters schema i.e. {\"arg1\":\"value1\", \"arg2\":\"value2\"}.\nAfter a 'Tool Input: ' the next message will contain a tool response. The next output should be a 'Thought: ' where the assistant thinks about the all the information it has available, and what it should do next (e.g. try the same tool with a different input, try a different tool, or proceed with answering the original user question).\n{{/tools.length}}\nOnce enough information is available to provide the Final Answer, the last line in the message needs to be:\nLine starting 'Final Answer: ' followed by a concise and clear answer to the original message.\n\n# Best practices\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n{{#tools.length}}\n- Do not attempt to use a tool that is not listed in available tools. This will cause an error.\n- Make sure that tool input is in the correct format and contains the correct arguments.\n{{/tools.length}}\n- When the message is unclear, respond with a line starting with 'Final Answer:' followed by a request for additional information needed to solve the problem.\n- When the user wants to chitchat instead, always respond politely.\n\n# Date and Time\nThe current date and time is: {{formatDate}}\n{{#tools.length}}\nYou do not need a tool to get the current Date and Time. Use the information available here.\n{{/tools.length}}\n\n{{#instructions}} \n# Additional instructions\n{{.}} \n{{/instructions}}\n`;\n});\n\nexport const GraniteReActAgentSchemaErrorPrompt = ReActAgentSchemaErrorPrompt.fork((config) => {\n config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input' or 'Thought' followed by 'Final Answer'.`;\n});\n\nexport const GraniteReActAgentUserPrompt = ReActAgentUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const GraniteReActAgentToolNotFoundPrompt = ReActAgentToolNotFoundPrompt.fork((config) => {\n config.template = `Tool does not exist!\n{{#tools.length}}\nUse one of the following tools: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}\n{{/tools.length}}`;\n});\n\nexport const GraniteReActAgentToolErrorPrompt = ReActAgentToolErrorPrompt.fork((config) => {\n config.template = `The tool has failed; the error log is shown below. If the tool cannot accomplish what you want, use a different tool or explain why you can't use it.\n\n{{reason}}`;\n});\n\nexport const GraniteReActAgentToolInputErrorPrompt = ReActAgentToolInputErrorPrompt.fork(\n (config) => {\n config.template = `{{reason}}\n\nHINT: If you're convinced that the input was correct but the tool cannot process it then use a different tool or say I don't know.`;\n },\n);\n"]}
|
|
@@ -21,7 +21,7 @@ import 'ajv';
|
|
|
21
21
|
* See the License for the specific language governing permissions and
|
|
22
22
|
* limitations under the License.
|
|
23
23
|
*/
|
|
24
|
-
declare const
|
|
24
|
+
declare const GraniteReActAgentAssistantPrompt: PromptTemplate<zod.ZodObject<{
|
|
25
25
|
thought: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
26
26
|
toolName: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
27
27
|
toolInput: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
@@ -40,7 +40,7 @@ declare const DeepThinkBeeAssistantPrompt: PromptTemplate<zod.ZodObject<{
|
|
|
40
40
|
toolOutput?: string[] | undefined;
|
|
41
41
|
finalAnswer?: string[] | undefined;
|
|
42
42
|
}>>;
|
|
43
|
-
declare const
|
|
43
|
+
declare const GraniteReActAgentSystemPrompt: PromptTemplate<zod.ZodObject<{
|
|
44
44
|
instructions: zod.ZodDefault<zod.ZodString>;
|
|
45
45
|
tools: zod.ZodArray<zod.ZodObject<{
|
|
46
46
|
name: zod.ZodString;
|
|
@@ -73,8 +73,8 @@ declare const DeepThinkBeeSystemPrompt: PromptTemplate<zod.ZodObject<{
|
|
|
73
73
|
createdAt?: string | null | undefined;
|
|
74
74
|
instructions?: string | undefined;
|
|
75
75
|
}>>;
|
|
76
|
-
declare const
|
|
77
|
-
declare const
|
|
76
|
+
declare const GraniteReActAgentSchemaErrorPrompt: PromptTemplate<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
|
|
77
|
+
declare const GraniteReActAgentUserPrompt: PromptTemplate<zod.ZodObject<{
|
|
78
78
|
input: zod.ZodString;
|
|
79
79
|
meta: zod.ZodOptional<zod.ZodObject<{
|
|
80
80
|
createdAt: zod.ZodOptional<zod.ZodString>;
|
|
@@ -102,7 +102,7 @@ declare const DeepThinkBeeUserPrompt: PromptTemplate<zod.ZodObject<{
|
|
|
102
102
|
createdAt: zod.ZodOptional<zod.ZodString>;
|
|
103
103
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
104
104
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
105
|
-
declare const
|
|
105
|
+
declare const GraniteReActAgentToolNotFoundPrompt: PromptTemplate<zod.ZodObject<{
|
|
106
106
|
tools: zod.ZodArray<zod.ZodObject<{
|
|
107
107
|
name: zod.ZodString;
|
|
108
108
|
}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
|
|
@@ -127,14 +127,14 @@ declare const DeepThinkBeeToolNotFoundPrompt: PromptTemplate<zod.ZodObject<{
|
|
|
127
127
|
name: zod.ZodString;
|
|
128
128
|
}, zod.ZodTypeAny, "passthrough">>, "many">;
|
|
129
129
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
130
|
-
declare const
|
|
130
|
+
declare const GraniteReActAgentToolErrorPrompt: PromptTemplate<zod.ZodObject<{
|
|
131
131
|
reason: zod.ZodString;
|
|
132
132
|
}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
|
|
133
133
|
reason: zod.ZodString;
|
|
134
134
|
}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
|
|
135
135
|
reason: zod.ZodString;
|
|
136
136
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
137
|
-
declare const
|
|
137
|
+
declare const GraniteReActAgentToolInputErrorPrompt: PromptTemplate<zod.ZodObject<{
|
|
138
138
|
reason: zod.ZodString;
|
|
139
139
|
}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
|
|
140
140
|
reason: zod.ZodString;
|
|
@@ -142,4 +142,4 @@ declare const DeepThinkBeeToolInputErrorPrompt: PromptTemplate<zod.ZodObject<{
|
|
|
142
142
|
reason: zod.ZodString;
|
|
143
143
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
144
144
|
|
|
145
|
-
export {
|
|
145
|
+
export { GraniteReActAgentAssistantPrompt, GraniteReActAgentSchemaErrorPrompt, GraniteReActAgentSystemPrompt, GraniteReActAgentToolErrorPrompt, GraniteReActAgentToolInputErrorPrompt, GraniteReActAgentToolNotFoundPrompt, GraniteReActAgentUserPrompt };
|
|
@@ -21,7 +21,7 @@ import 'ajv';
|
|
|
21
21
|
* See the License for the specific language governing permissions and
|
|
22
22
|
* limitations under the License.
|
|
23
23
|
*/
|
|
24
|
-
declare const
|
|
24
|
+
declare const GraniteReActAgentAssistantPrompt: PromptTemplate<zod.ZodObject<{
|
|
25
25
|
thought: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
26
26
|
toolName: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
27
27
|
toolInput: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
@@ -40,7 +40,7 @@ declare const DeepThinkBeeAssistantPrompt: PromptTemplate<zod.ZodObject<{
|
|
|
40
40
|
toolOutput?: string[] | undefined;
|
|
41
41
|
finalAnswer?: string[] | undefined;
|
|
42
42
|
}>>;
|
|
43
|
-
declare const
|
|
43
|
+
declare const GraniteReActAgentSystemPrompt: PromptTemplate<zod.ZodObject<{
|
|
44
44
|
instructions: zod.ZodDefault<zod.ZodString>;
|
|
45
45
|
tools: zod.ZodArray<zod.ZodObject<{
|
|
46
46
|
name: zod.ZodString;
|
|
@@ -73,8 +73,8 @@ declare const DeepThinkBeeSystemPrompt: PromptTemplate<zod.ZodObject<{
|
|
|
73
73
|
createdAt?: string | null | undefined;
|
|
74
74
|
instructions?: string | undefined;
|
|
75
75
|
}>>;
|
|
76
|
-
declare const
|
|
77
|
-
declare const
|
|
76
|
+
declare const GraniteReActAgentSchemaErrorPrompt: PromptTemplate<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
|
|
77
|
+
declare const GraniteReActAgentUserPrompt: PromptTemplate<zod.ZodObject<{
|
|
78
78
|
input: zod.ZodString;
|
|
79
79
|
meta: zod.ZodOptional<zod.ZodObject<{
|
|
80
80
|
createdAt: zod.ZodOptional<zod.ZodString>;
|
|
@@ -102,7 +102,7 @@ declare const DeepThinkBeeUserPrompt: PromptTemplate<zod.ZodObject<{
|
|
|
102
102
|
createdAt: zod.ZodOptional<zod.ZodString>;
|
|
103
103
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
104
104
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
105
|
-
declare const
|
|
105
|
+
declare const GraniteReActAgentToolNotFoundPrompt: PromptTemplate<zod.ZodObject<{
|
|
106
106
|
tools: zod.ZodArray<zod.ZodObject<{
|
|
107
107
|
name: zod.ZodString;
|
|
108
108
|
}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
|
|
@@ -127,14 +127,14 @@ declare const DeepThinkBeeToolNotFoundPrompt: PromptTemplate<zod.ZodObject<{
|
|
|
127
127
|
name: zod.ZodString;
|
|
128
128
|
}, zod.ZodTypeAny, "passthrough">>, "many">;
|
|
129
129
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
130
|
-
declare const
|
|
130
|
+
declare const GraniteReActAgentToolErrorPrompt: PromptTemplate<zod.ZodObject<{
|
|
131
131
|
reason: zod.ZodString;
|
|
132
132
|
}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
|
|
133
133
|
reason: zod.ZodString;
|
|
134
134
|
}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
|
|
135
135
|
reason: zod.ZodString;
|
|
136
136
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
137
|
-
declare const
|
|
137
|
+
declare const GraniteReActAgentToolInputErrorPrompt: PromptTemplate<zod.ZodObject<{
|
|
138
138
|
reason: zod.ZodString;
|
|
139
139
|
}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
|
|
140
140
|
reason: zod.ZodString;
|
|
@@ -142,4 +142,4 @@ declare const DeepThinkBeeToolInputErrorPrompt: PromptTemplate<zod.ZodObject<{
|
|
|
142
142
|
reason: zod.ZodString;
|
|
143
143
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
144
144
|
|
|
145
|
-
export {
|
|
145
|
+
export { GraniteReActAgentAssistantPrompt, GraniteReActAgentSchemaErrorPrompt, GraniteReActAgentSystemPrompt, GraniteReActAgentToolErrorPrompt, GraniteReActAgentToolInputErrorPrompt, GraniteReActAgentToolNotFoundPrompt, GraniteReActAgentUserPrompt };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReActAgentAssistantPrompt, ReActAgentSystemPrompt, ReActAgentSchemaErrorPrompt, ReActAgentUserPrompt, ReActAgentToolNotFoundPrompt, ReActAgentToolErrorPrompt, ReActAgentToolInputErrorPrompt } from '../../prompts.js';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const GraniteReActAgentAssistantPrompt = ReActAgentAssistantPrompt.fork((config) => {
|
|
4
4
|
config.template = `{{#thought}}Thought: {{.}}
|
|
5
5
|
{{/thought}}{{#toolName}}Tool Name: {{.}}
|
|
6
6
|
{{/toolName}}{{#toolInput}}Tool Input: {{.}}
|
|
7
7
|
{{/toolInput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`;
|
|
8
8
|
});
|
|
9
|
-
const
|
|
9
|
+
const GraniteReActAgentSystemPrompt = ReActAgentSystemPrompt.fork((config) => {
|
|
10
10
|
config.defaults.instructions = "";
|
|
11
11
|
config.functions.formatDate = function() {
|
|
12
12
|
const date = this.createdAt ? new Date(this.createdAt) : /* @__PURE__ */ new Date();
|
|
@@ -57,30 +57,30 @@ You do not need a tool to get the current Date and Time. Use the information ava
|
|
|
57
57
|
{{/instructions}}
|
|
58
58
|
`;
|
|
59
59
|
});
|
|
60
|
-
const
|
|
60
|
+
const GraniteReActAgentSchemaErrorPrompt = ReActAgentSchemaErrorPrompt.fork((config) => {
|
|
61
61
|
config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.
|
|
62
62
|
You communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input' or 'Thought' followed by 'Final Answer'.`;
|
|
63
63
|
});
|
|
64
|
-
const
|
|
64
|
+
const GraniteReActAgentUserPrompt = ReActAgentUserPrompt.fork((config) => {
|
|
65
65
|
config.template = `{{input}}`;
|
|
66
66
|
});
|
|
67
|
-
const
|
|
67
|
+
const GraniteReActAgentToolNotFoundPrompt = ReActAgentToolNotFoundPrompt.fork((config) => {
|
|
68
68
|
config.template = `Tool does not exist!
|
|
69
69
|
{{#tools.length}}
|
|
70
70
|
Use one of the following tools: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}
|
|
71
71
|
{{/tools.length}}`;
|
|
72
72
|
});
|
|
73
|
-
const
|
|
73
|
+
const GraniteReActAgentToolErrorPrompt = ReActAgentToolErrorPrompt.fork((config) => {
|
|
74
74
|
config.template = `The tool has failed; the error log is shown below. If the tool cannot accomplish what you want, use a different tool or explain why you can't use it.
|
|
75
75
|
|
|
76
76
|
{{reason}}`;
|
|
77
77
|
});
|
|
78
|
-
const
|
|
78
|
+
const GraniteReActAgentToolInputErrorPrompt = ReActAgentToolInputErrorPrompt.fork((config) => {
|
|
79
79
|
config.template = `{{reason}}
|
|
80
80
|
|
|
81
81
|
HINT: If you're convinced that the input was correct but the tool cannot process it then use a different tool or say I don't know.`;
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
export {
|
|
84
|
+
export { GraniteReActAgentAssistantPrompt, GraniteReActAgentSchemaErrorPrompt, GraniteReActAgentSystemPrompt, GraniteReActAgentToolErrorPrompt, GraniteReActAgentToolInputErrorPrompt, GraniteReActAgentToolNotFoundPrompt, GraniteReActAgentUserPrompt };
|
|
85
85
|
//# sourceMappingURL=prompts.js.map
|
|
86
86
|
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["prompts.ts"],"names":["GraniteReActAgentAssistantPrompt","ReActAgentAssistantPrompt","fork","config","template","GraniteReActAgentSystemPrompt","ReActAgentSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","GraniteReActAgentSchemaErrorPrompt","ReActAgentSchemaErrorPrompt","GraniteReActAgentUserPrompt","ReActAgentUserPrompt","GraniteReActAgentToolNotFoundPrompt","ReActAgentToolNotFoundPrompt","GraniteRe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AAA,CAAA;;;;AAIpB,CAAA;AAEO,MAAMqB,gCAAmCC,GAAAA,yBAAAA,CAA0BxB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAC9EA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;AAGpB,CAAA;AAEO,MAAMuB,qCAAwCC,GAAAA,8BAAAA,CAA+B1B,IAClF,CAAA,CAACC,MAAAA,KAAAA;AACCA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;AAGpB,CAAA","file":"prompts.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ReActAgentAssistantPrompt,\n ReActAgentSchemaErrorPrompt,\n ReActAgentSystemPrompt,\n ReActAgentToolErrorPrompt,\n ReActAgentToolInputErrorPrompt,\n ReActAgentToolNotFoundPrompt,\n ReActAgentUserPrompt,\n} from \"@/agents/react/prompts.js\";\n\nexport const GraniteReActAgentAssistantPrompt = ReActAgentAssistantPrompt.fork((config) => {\n config.template = `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Tool Name: {{.}}\\n{{/toolName}}{{#toolInput}}Tool Input: {{.}}\\n{{/toolInput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`;\n});\n\nexport const GraniteReActAgentSystemPrompt = ReActAgentSystemPrompt.fork((config) => {\n config.defaults.instructions = \"\";\n config.functions.formatDate = function () {\n const date = this.createdAt ? new Date(this.createdAt) : new Date();\n return new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"full\",\n timeStyle: \"medium\",\n }).format(date);\n };\n config.template = `You are an AI assistant.\nWhen the user sends a message figure out a solution and provide a final answer.\n{{#tools.length}}\nYou have access to a set of tools that can be used to retrieve information and perform actions.\nPay close attention to the tool description to determine if a tool is useful in a particular context.\n{{/tools.length}}\n\n# Communication structure\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input', or 'Thought' followed by 'Final Answer'\n\nLine starting 'Thought: ' The assistant's response always starts with a thought, this is a single line where the assistant thinks about the user's message and describes in detail what it should do next.\n{{#tools.length}}\nIn a 'Thought: ', the assistant should determine if a Tool Call is necessary to get more information or perform an action, or if the available information is sufficient to provide the Final Answer.\nIf a tool needs to be called and is available, the assistant will produce a tool call:\nLine starting 'Tool Name: ' name of the tool that you want to use.\nLine starting 'Tool Input: ' JSON formatted tool arguments adhering to the selected tool parameters schema i.e. {\"arg1\":\"value1\", \"arg2\":\"value2\"}.\nAfter a 'Tool Input: ' the next message will contain a tool response. The next output should be a 'Thought: ' where the assistant thinks about the all the information it has available, and what it should do next (e.g. try the same tool with a different input, try a different tool, or proceed with answering the original user question).\n{{/tools.length}}\nOnce enough information is available to provide the Final Answer, the last line in the message needs to be:\nLine starting 'Final Answer: ' followed by a concise and clear answer to the original message.\n\n# Best practices\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n{{#tools.length}}\n- Do not attempt to use a tool that is not listed in available tools. This will cause an error.\n- Make sure that tool input is in the correct format and contains the correct arguments.\n{{/tools.length}}\n- When the message is unclear, respond with a line starting with 'Final Answer:' followed by a request for additional information needed to solve the problem.\n- When the user wants to chitchat instead, always respond politely.\n\n# Date and Time\nThe current date and time is: {{formatDate}}\n{{#tools.length}}\nYou do not need a tool to get the current Date and Time. Use the information available here.\n{{/tools.length}}\n\n{{#instructions}} \n# Additional instructions\n{{.}} \n{{/instructions}}\n`;\n});\n\nexport const GraniteReActAgentSchemaErrorPrompt = ReActAgentSchemaErrorPrompt.fork((config) => {\n config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input' or 'Thought' followed by 'Final Answer'.`;\n});\n\nexport const GraniteReActAgentUserPrompt = ReActAgentUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const GraniteReActAgentToolNotFoundPrompt = ReActAgentToolNotFoundPrompt.fork((config) => {\n config.template = `Tool does not exist!\n{{#tools.length}}\nUse one of the following tools: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}\n{{/tools.length}}`;\n});\n\nexport const GraniteReActAgentToolErrorPrompt = ReActAgentToolErrorPrompt.fork((config) => {\n config.template = `The tool has failed; the error log is shown below. If the tool cannot accomplish what you want, use a different tool or explain why you can't use it.\n\n{{reason}}`;\n});\n\nexport const GraniteReActAgentToolInputErrorPrompt = ReActAgentToolInputErrorPrompt.fork(\n (config) => {\n config.template = `{{reason}}\n\nHINT: If you're convinced that the input was correct but the tool cannot process it then use a different tool or say I don't know.`;\n },\n);\n"]}
|
|
@@ -26,16 +26,16 @@ class GraniteRunner extends runner_cjs.DefaultRunner {
|
|
|
26
26
|
useNativeToolCalling = true;
|
|
27
27
|
get defaultTemplates() {
|
|
28
28
|
return {
|
|
29
|
-
system: prompts_cjs$1.
|
|
30
|
-
assistant: prompts_cjs$1.
|
|
31
|
-
user: prompts_cjs$1.
|
|
32
|
-
schemaError: prompts_cjs$1.
|
|
33
|
-
toolNotFoundError: prompts_cjs$1.
|
|
34
|
-
toolError: prompts_cjs$1.
|
|
35
|
-
toolInputError: prompts_cjs$1.
|
|
36
|
-
// Note: These are from
|
|
37
|
-
userEmpty: prompts_cjs.
|
|
38
|
-
toolNoResultError: prompts_cjs.
|
|
29
|
+
system: prompts_cjs$1.GraniteReActAgentSystemPrompt,
|
|
30
|
+
assistant: prompts_cjs$1.GraniteReActAgentAssistantPrompt,
|
|
31
|
+
user: prompts_cjs$1.GraniteReActAgentUserPrompt,
|
|
32
|
+
schemaError: prompts_cjs$1.GraniteReActAgentSchemaErrorPrompt,
|
|
33
|
+
toolNotFoundError: prompts_cjs$1.GraniteReActAgentToolNotFoundPrompt,
|
|
34
|
+
toolError: prompts_cjs$1.GraniteReActAgentToolErrorPrompt,
|
|
35
|
+
toolInputError: prompts_cjs$1.GraniteReActAgentToolInputErrorPrompt,
|
|
36
|
+
// Note: These are from ReAct
|
|
37
|
+
userEmpty: prompts_cjs.ReActAgentUserEmptyPrompt,
|
|
38
|
+
toolNoResultError: prompts_cjs.ReActAgentToolNoResultsPrompt
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
static {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["runner.ts"],"names":["GraniteRunner","DefaultRunner","useNativeToolCalling","defaultTemplates","system","GraniteReActAgentSystemPrompt","assistant","GraniteReActAgentAssistantPrompt","user","GraniteReActAgentUserPrompt","schemaError","GraniteReActAgentSchemaErrorPrompt","toolNotFoundError","GraniteReActAgentToolNotFoundPrompt","toolError","GraniteReActAgentToolErrorPrompt","toolInputError","GraniteReActAgentToolInputErrorPrompt","userEmpty","ReActAgentUserEmptyPrompt","toolNoResultError","ReActAgentToolNoResultsPrompt","register","constructor","input","options","run","emitter","on","update","meta","memory","data","key","add","ToolMessage","type","result","value","toolName","tool_name","isError","success","toolCallId","isBlocking","createParser","tools","parser","fork","nodes","thought","prefix","tool_input","isEnd","next","final_answer","enumerable"],"mappings":";;;;;;;;;;AAcC,SAAA,YAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GAAA,EAAA,IAAA,EAAA;;;;;;AAAA,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA;;;;;AAuBM,MAAMA,sBAAsBC,wBAAAA,CAAAA;EArCnC;;;EAsCYC,oBAAuB,GAAA,IAAA;AAEjC,EAAA,IACWC,gBAAmB,GAAA;AAC5B,IAAO,OAAA;MACLC,MAAQC,EAAAA,2CAAAA;MACRC,SAAWC,EAAAA,8CAAAA;MACXC,IAAMC,EAAAA,yCAAAA;MACNC,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AAS,EAAA;AAAE,YAAA,GAAGD,KAAMC,CAAAA,OAAAA;YAASC,MAAQ,EAAA;AAAW,WAAA;UAChDX,SAAW,EAAA;AAAE,YAAA,GAAGS,KAAMT,CAAAA,SAAAA;YAAWW,MAAQ,EAAA;AAAa,WAAA;UACtDC,UAAY,EAAA;AAAE,YAAA,GAAGH,KAAMG,CAAAA,UAAAA;YAAYD,MAAQ,EAAA,aAAA;YAAeE,KAAO,EAAA,IAAA;AAAMC,YAAAA,IAAAA,EAAM;AAAG,WAAA;UAChFC,YAAc,EAAA;AAAE,YAAA,GAAGN,KAAMM,CAAAA,YAAAA;YAAcJ,MAAQ,EAAA;AAAgB;AACjE;OACF,CAAA;AACF,KAAA;AACF;AACF;;;IAnEWK,UAAY,EAAA","file":"runner.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ToolMessage } from \"@/backend/message.js\";\nimport type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport type { ReActAgentParserInput, ReActAgentRunOptions } from \"@/agents/react/types.js\";\nimport { ReActAgent, ReActAgentInput } from \"@/agents/react/agent.js\";\nimport type { GetRunContext } from \"@/context.js\";\nimport {\n GraniteReActAgentAssistantPrompt,\n GraniteReActAgentSchemaErrorPrompt,\n GraniteReActAgentSystemPrompt,\n GraniteReActAgentToolErrorPrompt,\n GraniteReActAgentToolInputErrorPrompt,\n GraniteReActAgentToolNotFoundPrompt,\n GraniteReActAgentUserPrompt,\n} from \"@/agents/react/runners/granite/prompts.js\";\nimport {\n ReActAgentToolNoResultsPrompt,\n ReActAgentUserEmptyPrompt,\n} from \"@/agents/react/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\n\nexport class GraniteRunner extends DefaultRunner {\n protected useNativeToolCalling = true;\n\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: GraniteReActAgentSystemPrompt,\n assistant: GraniteReActAgentAssistantPrompt,\n user: GraniteReActAgentUserPrompt,\n schemaError: GraniteReActAgentSchemaErrorPrompt,\n toolNotFoundError: GraniteReActAgentToolNotFoundPrompt,\n toolError: GraniteReActAgentToolErrorPrompt,\n toolInputError: GraniteReActAgentToolInputErrorPrompt,\n // Note: These are from ReAct\n userEmpty: ReActAgentUserEmptyPrompt,\n toolNoResultError: ReActAgentToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n constructor(\n input: ReActAgentInput,\n options: ReActAgentRunOptions,\n run: GetRunContext<ReActAgent>,\n ) {\n super(input, options, run);\n\n run.emitter.on(\n \"update\",\n async ({ update, meta, memory, data }) => {\n if (update.key === \"tool_output\") {\n await memory.add(\n new ToolMessage(\n {\n type: \"tool-result\",\n result: update.value!,\n toolName: data.tool_name!,\n isError: !meta.success,\n toolCallId: \"DUMMY_ID\",\n },\n { success: meta.success },\n ),\n );\n }\n },\n {\n isBlocking: true,\n },\n );\n }\n\n protected createParser(tools: AnyTool[]) {\n const { parser } = super.createParser(tools);\n\n return {\n parser: parser.fork<ReActAgentParserInput>((nodes, options) => ({\n options,\n nodes: {\n ...nodes,\n thought: { ...nodes.thought, prefix: \"Thought:\" },\n tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n tool_input: { ...nodes.tool_input, prefix: \"Tool Input:\", isEnd: true, next: [] },\n final_answer: { ...nodes.final_answer, prefix: \"Final Answer:\" },\n },\n })),\n };\n }\n}\n"]}
|
|
@@ -3,8 +3,8 @@ import { PromptTemplate } from '../../../../template.cjs';
|
|
|
3
3
|
import * as zod from 'zod';
|
|
4
4
|
import { AnyTool } from '../../../../tools/base.cjs';
|
|
5
5
|
import { DefaultRunner } from '../default/runner.cjs';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { ReActAgentRunOptions, ReActAgentParserInput } from '../../types.cjs';
|
|
7
|
+
import { R as ReActAgentInput, a as ReActAgent } from '../../../../agent-Bpt7IFa_.cjs';
|
|
8
8
|
import { GetRunContext } from '../../../../context.cjs';
|
|
9
9
|
import '../../../../emitter-C9EN5B0j.cjs';
|
|
10
10
|
import '../../../../internals/types.cjs';
|
|
@@ -158,9 +158,9 @@ declare class GraniteRunner extends DefaultRunner {
|
|
|
158
158
|
userEmpty: PromptTemplate<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
|
|
159
159
|
toolNoResultError: PromptTemplate<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
|
|
160
160
|
};
|
|
161
|
-
constructor(input:
|
|
161
|
+
constructor(input: ReActAgentInput, options: ReActAgentRunOptions, run: GetRunContext<ReActAgent>);
|
|
162
162
|
protected createParser(tools: AnyTool[]): {
|
|
163
|
-
parser: LinePrefixParser<
|
|
163
|
+
parser: LinePrefixParser<ReActAgentParserInput>;
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -3,8 +3,8 @@ import { PromptTemplate } from '../../../../template.js';
|
|
|
3
3
|
import * as zod from 'zod';
|
|
4
4
|
import { AnyTool } from '../../../../tools/base.js';
|
|
5
5
|
import { DefaultRunner } from '../default/runner.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { ReActAgentRunOptions, ReActAgentParserInput } from '../../types.js';
|
|
7
|
+
import { R as ReActAgentInput, a as ReActAgent } from '../../../../agent-Bf2FaCKy.js';
|
|
8
8
|
import { GetRunContext } from '../../../../context.js';
|
|
9
9
|
import '../../../../emitter-BxVxGBbJ.js';
|
|
10
10
|
import '../../../../internals/types.js';
|
|
@@ -158,9 +158,9 @@ declare class GraniteRunner extends DefaultRunner {
|
|
|
158
158
|
userEmpty: PromptTemplate<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
|
|
159
159
|
toolNoResultError: PromptTemplate<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
|
|
160
160
|
};
|
|
161
|
-
constructor(input:
|
|
161
|
+
constructor(input: ReActAgentInput, options: ReActAgentRunOptions, run: GetRunContext<ReActAgent>);
|
|
162
162
|
protected createParser(tools: AnyTool[]): {
|
|
163
|
-
parser: LinePrefixParser<
|
|
163
|
+
parser: LinePrefixParser<ReActAgentParserInput>;
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ToolMessage } from '../../../../backend/message.js';
|
|
2
2
|
import { DefaultRunner } from '../default/runner.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { GraniteReActAgentToolInputErrorPrompt, GraniteReActAgentToolErrorPrompt, GraniteReActAgentToolNotFoundPrompt, GraniteReActAgentSchemaErrorPrompt, GraniteReActAgentUserPrompt, GraniteReActAgentAssistantPrompt, GraniteReActAgentSystemPrompt } from './prompts.js';
|
|
4
|
+
import { ReActAgentToolNoResultsPrompt, ReActAgentUserEmptyPrompt } from '../../prompts.js';
|
|
5
5
|
import { Cache } from '../../../../cache/decoratorCache.js';
|
|
6
6
|
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
@@ -24,16 +24,16 @@ class GraniteRunner extends DefaultRunner {
|
|
|
24
24
|
useNativeToolCalling = true;
|
|
25
25
|
get defaultTemplates() {
|
|
26
26
|
return {
|
|
27
|
-
system:
|
|
28
|
-
assistant:
|
|
29
|
-
user:
|
|
30
|
-
schemaError:
|
|
31
|
-
toolNotFoundError:
|
|
32
|
-
toolError:
|
|
33
|
-
toolInputError:
|
|
34
|
-
// Note: These are from
|
|
35
|
-
userEmpty:
|
|
36
|
-
toolNoResultError:
|
|
27
|
+
system: GraniteReActAgentSystemPrompt,
|
|
28
|
+
assistant: GraniteReActAgentAssistantPrompt,
|
|
29
|
+
user: GraniteReActAgentUserPrompt,
|
|
30
|
+
schemaError: GraniteReActAgentSchemaErrorPrompt,
|
|
31
|
+
toolNotFoundError: GraniteReActAgentToolNotFoundPrompt,
|
|
32
|
+
toolError: GraniteReActAgentToolErrorPrompt,
|
|
33
|
+
toolInputError: GraniteReActAgentToolInputErrorPrompt,
|
|
34
|
+
// Note: These are from ReAct
|
|
35
|
+
userEmpty: ReActAgentUserEmptyPrompt,
|
|
36
|
+
toolNoResultError: ReActAgentToolNoResultsPrompt
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
static {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["runner.ts"],"names":["GraniteRunner","DefaultRunner","useNativeToolCalling","defaultTemplates","system","GraniteReActAgentSystemPrompt","assistant","GraniteReActAgentAssistantPrompt","user","GraniteReActAgentUserPrompt","schemaError","GraniteReActAgentSchemaErrorPrompt","toolNotFoundError","GraniteReActAgentToolNotFoundPrompt","toolError","GraniteReActAgentToolErrorPrompt","toolInputError","GraniteReActAgentToolInputErrorPrompt","userEmpty","ReActAgentUserEmptyPrompt","toolNoResultError","ReActAgentToolNoResultsPrompt","register","constructor","input","options","run","emitter","on","update","meta","memory","data","key","add","ToolMessage","type","result","value","toolName","tool_name","isError","success","toolCallId","isBlocking","createParser","tools","parser","fork","nodes","thought","prefix","tool_input","isEnd","next","final_answer","enumerable"],"mappings":";;;;;;;;AAcC,SAAA,YAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GAAA,EAAA,IAAA,EAAA;;;;;;AAAA,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA;;;;;AAuBM,MAAMA,sBAAsBC,aAAAA,CAAAA;EArCnC;;;EAsCY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O,OAAA;AACLC,MAAAA,MAAAA,EAAQA,MAAOC,CAAAA,IAAAA,CAA4B,CAACC,KAAAA,EAAOxB,OAAa,MAAA;AAC9DA,QAAAA,OAAAA;QACAwB,KAAO,EAAA;UACL,GAAGA,KAAAA;UACHC,OAAS,EAAA;AAAE,YAAA,GAAGD,KAAMC,CAAAA,OAAAA;YAASC,MAAQ,EAAA;AAAW,WAAA;UAChDX,SAAW,EAAA;AAAE,YAAA,GAAGS,KAAMT,CAAAA,SAAAA;YAAWW,MAAQ,EAAA;AAAa,WAAA;UACtDC,UAAY,EAAA;AAAE,YAAA,GAAGH,KAAMG,CAAAA,UAAAA;YAAYD,MAAQ,EAAA,aAAA;YAAeE,KAAO,EAAA,IAAA;AAAMC,YAAAA,IAAAA,EAAM;AAAG,WAAA;UAChFC,YAAc,EAAA;AAAE,YAAA,GAAGN,KAAMM,CAAAA,YAAAA;YAAcJ,MAAQ,EAAA;AAAgB;AACjE;OACF,CAAA;AACF,KAAA;AACF;AACF;;;IAnEWK,UAAY,EAAA","file":"runner.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ToolMessage } from \"@/backend/message.js\";\nimport type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport type { ReActAgentParserInput, ReActAgentRunOptions } from \"@/agents/react/types.js\";\nimport { ReActAgent, ReActAgentInput } from \"@/agents/react/agent.js\";\nimport type { GetRunContext } from \"@/context.js\";\nimport {\n GraniteReActAgentAssistantPrompt,\n GraniteReActAgentSchemaErrorPrompt,\n GraniteReActAgentSystemPrompt,\n GraniteReActAgentToolErrorPrompt,\n GraniteReActAgentToolInputErrorPrompt,\n GraniteReActAgentToolNotFoundPrompt,\n GraniteReActAgentUserPrompt,\n} from \"@/agents/react/runners/granite/prompts.js\";\nimport {\n ReActAgentToolNoResultsPrompt,\n ReActAgentUserEmptyPrompt,\n} from \"@/agents/react/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\n\nexport class GraniteRunner extends DefaultRunner {\n protected useNativeToolCalling = true;\n\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: GraniteReActAgentSystemPrompt,\n assistant: GraniteReActAgentAssistantPrompt,\n user: GraniteReActAgentUserPrompt,\n schemaError: GraniteReActAgentSchemaErrorPrompt,\n toolNotFoundError: GraniteReActAgentToolNotFoundPrompt,\n toolError: GraniteReActAgentToolErrorPrompt,\n toolInputError: GraniteReActAgentToolInputErrorPrompt,\n // Note: These are from ReAct\n userEmpty: ReActAgentUserEmptyPrompt,\n toolNoResultError: ReActAgentToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n constructor(\n input: ReActAgentInput,\n options: ReActAgentRunOptions,\n run: GetRunContext<ReActAgent>,\n ) {\n super(input, options, run);\n\n run.emitter.on(\n \"update\",\n async ({ update, meta, memory, data }) => {\n if (update.key === \"tool_output\") {\n await memory.add(\n new ToolMessage(\n {\n type: \"tool-result\",\n result: update.value!,\n toolName: data.tool_name!,\n isError: !meta.success,\n toolCallId: \"DUMMY_ID\",\n },\n { success: meta.success },\n ),\n );\n }\n },\n {\n isBlocking: true,\n },\n );\n }\n\n protected createParser(tools: AnyTool[]) {\n const { parser } = super.createParser(tools);\n\n return {\n parser: parser.fork<ReActAgentParserInput>((nodes, options) => ({\n options,\n nodes: {\n ...nodes,\n thought: { ...nodes.thought, prefix: \"Thought:\" },\n tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n tool_input: { ...nodes.tool_input, prefix: \"Tool Input:\", isEnd: true, next: [] },\n final_answer: { ...nodes.final_answer, prefix: \"Final Answer:\" },\n },\n })),\n };\n }\n}\n"]}
|