@loopstack/accessing-tool-results-example-workflow 0.20.6 → 0.21.0
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/README.md +1 -1
- package/dist/tool-results-example.module.js +2 -2
- package/dist/tool-results-example.module.js.map +1 -1
- package/dist/workflow-tool-results.ui.yaml +1 -0
- package/dist/workflow-tool-results.workflow.d.ts +6 -11
- package/dist/workflow-tool-results.workflow.d.ts.map +1 -1
- package/dist/workflow-tool-results.workflow.js +34 -10
- package/dist/workflow-tool-results.workflow.js.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/workflow-tool-results.workflow.spec.ts +21 -40
- package/src/tool-results-example.module.ts +2 -2
- package/src/workflow-tool-results.ui.yaml +1 -0
- package/src/workflow-tool-results.workflow.ts +36 -17
- package/dist/workflow-tool-results.workflow.yaml +0 -40
- package/src/workflow-tool-results.workflow.yaml +0 -40
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ The workflow declares tools, typed runtime, and a helper function:
|
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
31
|
@Workflow({
|
|
32
|
-
|
|
32
|
+
uiConfig: __dirname + '/workflow-tool-results.ui.yaml',
|
|
33
33
|
})
|
|
34
34
|
export class WorkflowToolResultsWorkflow {
|
|
35
35
|
@InjectTool() private createValue: CreateValue;
|
|
@@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ToolResultsExampleModule = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
|
-
const
|
|
11
|
+
const core_1 = require("@loopstack/core");
|
|
12
12
|
const create_chat_message_tool_1 = require("@loopstack/create-chat-message-tool");
|
|
13
13
|
const create_value_tool_1 = require("@loopstack/create-value-tool");
|
|
14
14
|
const workflow_tool_results_workflow_1 = require("./workflow-tool-results.workflow");
|
|
@@ -17,7 +17,7 @@ let ToolResultsExampleModule = class ToolResultsExampleModule {
|
|
|
17
17
|
exports.ToolResultsExampleModule = ToolResultsExampleModule;
|
|
18
18
|
exports.ToolResultsExampleModule = ToolResultsExampleModule = __decorate([
|
|
19
19
|
(0, common_1.Module)({
|
|
20
|
-
imports: [
|
|
20
|
+
imports: [core_1.LoopCoreModule, create_value_tool_1.CreateValueToolModule, create_chat_message_tool_1.CreateChatMessageToolModule],
|
|
21
21
|
providers: [workflow_tool_results_workflow_1.WorkflowToolResultsWorkflow],
|
|
22
22
|
exports: [workflow_tool_results_workflow_1.WorkflowToolResultsWorkflow],
|
|
23
23
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-results-example.module.js","sourceRoot":"","sources":["../src/tool-results-example.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"tool-results-example.module.js","sourceRoot":"","sources":["../src/tool-results-example.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,0CAAiD;AACjD,kFAAkF;AAClF,oEAAqE;AACrE,qFAA+E;AAOxE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;CAAG,CAAA;AAA3B,4DAAwB;mCAAxB,wBAAwB;IALpC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,qBAAc,EAAE,yCAAqB,EAAE,sDAA2B,CAAC;QAC7E,SAAS,EAAE,CAAC,4DAA2B,CAAC;QACxC,OAAO,EAAE,CAAC,4DAA2B,CAAC;KACvC,CAAC;GACW,wBAAwB,CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
title: 'Workflow Tool Result'
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { BaseWorkflow } from '@loopstack/common';
|
|
2
|
+
export declare class WorkflowToolResultsWorkflow extends BaseWorkflow {
|
|
2
3
|
private createValue;
|
|
3
4
|
private createChatMessage;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
data: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
theMessage(): string;
|
|
5
|
+
storedMessage?: string;
|
|
6
|
+
createSomeData(): Promise<void>;
|
|
7
|
+
accessData(): Promise<void>;
|
|
8
|
+
private theMessage;
|
|
14
9
|
}
|
|
15
10
|
//# sourceMappingURL=workflow-tool-results.workflow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-tool-results.workflow.d.ts","sourceRoot":"","sources":["../src/workflow-tool-results.workflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workflow-tool-results.workflow.d.ts","sourceRoot":"","sources":["../src/workflow-tool-results.workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwC,MAAM,mBAAmB,CAAC;AAIvF,qBAGa,2BAA4B,SAAQ,YAAY;IAC7C,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,iBAAiB,CAAoB;IAE3D,aAAa,CAAC,EAAE,MAAM,CAAC;IAGjB,cAAc;IAgBd,UAAU;IAYhB,OAAO,CAAC,UAAU;CAGnB"}
|
|
@@ -13,12 +13,34 @@ exports.WorkflowToolResultsWorkflow = void 0;
|
|
|
13
13
|
const common_1 = require("@loopstack/common");
|
|
14
14
|
const create_chat_message_tool_1 = require("@loopstack/create-chat-message-tool");
|
|
15
15
|
const create_value_tool_1 = require("@loopstack/create-value-tool");
|
|
16
|
-
let WorkflowToolResultsWorkflow = class WorkflowToolResultsWorkflow {
|
|
16
|
+
let WorkflowToolResultsWorkflow = class WorkflowToolResultsWorkflow extends common_1.BaseWorkflow {
|
|
17
17
|
createValue;
|
|
18
18
|
createChatMessage;
|
|
19
|
-
|
|
19
|
+
storedMessage;
|
|
20
|
+
async createSomeData() {
|
|
21
|
+
const result = await this.createValue.call({ input: 'Hello World.' });
|
|
22
|
+
this.storedMessage = result.data;
|
|
23
|
+
await this.createChatMessage.call({
|
|
24
|
+
role: 'assistant',
|
|
25
|
+
content: `Data from specific call id: ${this.storedMessage}`,
|
|
26
|
+
});
|
|
27
|
+
await this.createChatMessage.call({
|
|
28
|
+
role: 'assistant',
|
|
29
|
+
content: `Data from first tool call: ${this.storedMessage}`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async accessData() {
|
|
33
|
+
await this.createChatMessage.call({
|
|
34
|
+
role: 'assistant',
|
|
35
|
+
content: `Data from previous transition: ${this.storedMessage}`,
|
|
36
|
+
});
|
|
37
|
+
await this.createChatMessage.call({
|
|
38
|
+
role: 'assistant',
|
|
39
|
+
content: `Data access using custom helper: ${this.theMessage()}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
20
42
|
theMessage() {
|
|
21
|
-
return this.
|
|
43
|
+
return this.storedMessage;
|
|
22
44
|
}
|
|
23
45
|
};
|
|
24
46
|
exports.WorkflowToolResultsWorkflow = WorkflowToolResultsWorkflow;
|
|
@@ -31,18 +53,20 @@ __decorate([
|
|
|
31
53
|
__metadata("design:type", create_chat_message_tool_1.CreateChatMessage)
|
|
32
54
|
], WorkflowToolResultsWorkflow.prototype, "createChatMessage", void 0);
|
|
33
55
|
__decorate([
|
|
34
|
-
(0, common_1.
|
|
35
|
-
__metadata("design:type",
|
|
36
|
-
|
|
56
|
+
(0, common_1.Initial)({ to: 'data_created' }),
|
|
57
|
+
__metadata("design:type", Function),
|
|
58
|
+
__metadata("design:paramtypes", []),
|
|
59
|
+
__metadata("design:returntype", Promise)
|
|
60
|
+
], WorkflowToolResultsWorkflow.prototype, "createSomeData", null);
|
|
37
61
|
__decorate([
|
|
38
|
-
(0, common_1.
|
|
62
|
+
(0, common_1.Final)({ from: 'data_created' }),
|
|
39
63
|
__metadata("design:type", Function),
|
|
40
64
|
__metadata("design:paramtypes", []),
|
|
41
|
-
__metadata("design:returntype",
|
|
42
|
-
], WorkflowToolResultsWorkflow.prototype, "
|
|
65
|
+
__metadata("design:returntype", Promise)
|
|
66
|
+
], WorkflowToolResultsWorkflow.prototype, "accessData", null);
|
|
43
67
|
exports.WorkflowToolResultsWorkflow = WorkflowToolResultsWorkflow = __decorate([
|
|
44
68
|
(0, common_1.Workflow)({
|
|
45
|
-
|
|
69
|
+
uiConfig: __dirname + '/workflow-tool-results.ui.yaml',
|
|
46
70
|
})
|
|
47
71
|
], WorkflowToolResultsWorkflow);
|
|
48
72
|
//# sourceMappingURL=workflow-tool-results.workflow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-tool-results.workflow.js","sourceRoot":"","sources":["../src/workflow-tool-results.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"workflow-tool-results.workflow.js","sourceRoot":"","sources":["../src/workflow-tool-results.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAuF;AACvF,kFAAwE;AACxE,oEAA2D;AAKpD,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,qBAAY;IACrC,WAAW,CAAc;IACzB,iBAAiB,CAAoB;IAE3D,aAAa,CAAU;IAGjB,AAAN,KAAK,CAAC,cAAc;QAClB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;QACtE,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,IAAc,CAAC;QAE3C,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;YAChC,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,+BAA+B,IAAI,CAAC,aAAa,EAAE;SAC7D,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;YAChC,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,8BAA8B,IAAI,CAAC,aAAa,EAAE;SAC5D,CAAC,CAAC;IACL,CAAC;IAGK,AAAN,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;YAChC,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,kCAAkC,IAAI,CAAC,aAAa,EAAE;SAChE,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;YAChC,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,oCAAoC,IAAI,CAAC,UAAU,EAAE,EAAE;SACjE,CAAC,CAAC;IACL,CAAC;IAEO,UAAU;QAChB,OAAO,IAAI,CAAC,aAAc,CAAC;IAC7B,CAAC;CACF,CAAA;AAtCY,kEAA2B;AAChB;IAArB,IAAA,mBAAU,GAAE;8BAAsB,+BAAW;gEAAC;AACzB;IAArB,IAAA,mBAAU,GAAE;8BAA4B,4CAAiB;sEAAC;AAKrD;IADL,IAAA,gBAAO,EAAC,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC;;;;iEAc/B;AAGK;IADL,IAAA,cAAK,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;;;;6DAW/B;sCAjCU,2BAA2B;IAHvC,IAAA,iBAAQ,EAAC;QACR,QAAQ,EAAE,SAAS,GAAG,gCAAgC;KACvD,CAAC;GACW,2BAA2B,CAsCvC"}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"tool",
|
|
11
11
|
"workflow"
|
|
12
12
|
],
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.21.0",
|
|
14
14
|
"license": "Apache-2.0",
|
|
15
15
|
"author": {
|
|
16
16
|
"name": "Jakob Klippel",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"watch": "nest build --watch"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@loopstack/common": "^0.
|
|
35
|
-
"@loopstack/core
|
|
36
|
-
"@loopstack/create-chat-message-tool": "^0.
|
|
37
|
-
"@loopstack/create-value-tool": "^0.
|
|
34
|
+
"@loopstack/common": "^0.25.0",
|
|
35
|
+
"@loopstack/core": "^0.25.0",
|
|
36
|
+
"@loopstack/create-chat-message-tool": "^0.21.0",
|
|
37
|
+
"@loopstack/create-value-tool": "^0.21.0",
|
|
38
38
|
"@nestjs/common": "^11.1.14",
|
|
39
39
|
"zod": "^4.3.6"
|
|
40
40
|
},
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { TestingModule } from '@nestjs/testing';
|
|
2
|
-
import {
|
|
3
|
-
import { WorkflowProcessorService } from '@loopstack/core';
|
|
4
|
-
import { CoreUiModule } from '@loopstack/core-ui-module';
|
|
2
|
+
import { LoopCoreModule, WorkflowProcessorService } from '@loopstack/core';
|
|
5
3
|
import { CreateChatMessage, CreateChatMessageToolModule } from '@loopstack/create-chat-message-tool';
|
|
6
4
|
import { CreateValue, CreateValueToolModule } from '@loopstack/create-value-tool';
|
|
7
|
-
import { ToolMock, createWorkflowTest } from '@loopstack/testing';
|
|
5
|
+
import { ToolMock, createStatelessContext, createWorkflowTest } from '@loopstack/testing';
|
|
8
6
|
import { WorkflowToolResultsWorkflow } from '../workflow-tool-results.workflow';
|
|
9
7
|
|
|
10
8
|
describe('WorkflowToolResultsWorkflow', () => {
|
|
@@ -18,7 +16,7 @@ describe('WorkflowToolResultsWorkflow', () => {
|
|
|
18
16
|
beforeEach(async () => {
|
|
19
17
|
module = await createWorkflowTest()
|
|
20
18
|
.forWorkflow(WorkflowToolResultsWorkflow)
|
|
21
|
-
.withImports(
|
|
19
|
+
.withImports(LoopCoreModule, CreateValueToolModule, CreateChatMessageToolModule)
|
|
22
20
|
.withToolOverride(CreateValue)
|
|
23
21
|
.withToolOverride(CreateChatMessage)
|
|
24
22
|
.compile();
|
|
@@ -38,81 +36,64 @@ describe('WorkflowToolResultsWorkflow', () => {
|
|
|
38
36
|
expect(workflow).toBeDefined();
|
|
39
37
|
});
|
|
40
38
|
|
|
41
|
-
it('should have extractMessage helper', () => {
|
|
42
|
-
expect(getBlockHelpers(workflow)).toContain('theMessage');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
39
|
describe('tool result access', () => {
|
|
46
40
|
it('should access tool results by call id and index in same transition', async () => {
|
|
47
|
-
const context =
|
|
48
|
-
mockCreateValue.
|
|
49
|
-
mockCreateChatMessage.
|
|
41
|
+
const context = createStatelessContext();
|
|
42
|
+
mockCreateValue.call.mockResolvedValue({ data: 'Hello World.' });
|
|
43
|
+
mockCreateChatMessage.call.mockResolvedValue({ data: undefined });
|
|
50
44
|
|
|
51
45
|
await processor.process(workflow, {}, context);
|
|
52
46
|
|
|
53
47
|
// Verify CreateValue was called
|
|
54
|
-
expect(mockCreateValue.
|
|
55
|
-
{ input: 'Hello World.' },
|
|
56
|
-
expect.anything(),
|
|
57
|
-
expect.anything(),
|
|
58
|
-
expect.anything(),
|
|
59
|
-
);
|
|
48
|
+
expect(mockCreateValue.call).toHaveBeenCalledWith({ input: 'Hello World.' }, undefined);
|
|
60
49
|
|
|
61
50
|
// Verify CreateChatMessage received resolved template values
|
|
62
|
-
expect(mockCreateChatMessage.
|
|
51
|
+
expect(mockCreateChatMessage.call).toHaveBeenCalledWith(
|
|
63
52
|
{
|
|
64
53
|
role: 'assistant',
|
|
65
54
|
content: 'Data from specific call id: Hello World.',
|
|
66
55
|
},
|
|
67
|
-
|
|
68
|
-
expect.anything(),
|
|
69
|
-
expect.anything(),
|
|
56
|
+
undefined,
|
|
70
57
|
);
|
|
71
58
|
|
|
72
|
-
expect(mockCreateChatMessage.
|
|
59
|
+
expect(mockCreateChatMessage.call).toHaveBeenCalledWith(
|
|
73
60
|
{
|
|
74
61
|
role: 'assistant',
|
|
75
62
|
content: 'Data from first tool call: Hello World.',
|
|
76
63
|
},
|
|
77
|
-
|
|
78
|
-
expect.anything(),
|
|
79
|
-
expect.anything(),
|
|
64
|
+
undefined,
|
|
80
65
|
);
|
|
81
66
|
});
|
|
82
67
|
|
|
83
68
|
it('should access tool results from previous transition', async () => {
|
|
84
|
-
const context =
|
|
85
|
-
mockCreateValue.
|
|
86
|
-
mockCreateChatMessage.
|
|
69
|
+
const context = createStatelessContext();
|
|
70
|
+
mockCreateValue.call.mockResolvedValue({ data: 'Hello World.' });
|
|
71
|
+
mockCreateChatMessage.call.mockResolvedValue({ data: undefined });
|
|
87
72
|
|
|
88
73
|
await processor.process(workflow, {}, context);
|
|
89
74
|
|
|
90
|
-
expect(mockCreateChatMessage.
|
|
75
|
+
expect(mockCreateChatMessage.call).toHaveBeenCalledWith(
|
|
91
76
|
{
|
|
92
77
|
role: 'assistant',
|
|
93
78
|
content: 'Data from previous transition: Hello World.',
|
|
94
79
|
},
|
|
95
|
-
|
|
96
|
-
expect.anything(),
|
|
97
|
-
expect.anything(),
|
|
80
|
+
undefined,
|
|
98
81
|
);
|
|
99
82
|
});
|
|
100
83
|
|
|
101
84
|
it('should access tool results using custom helper', async () => {
|
|
102
|
-
const context =
|
|
103
|
-
mockCreateValue.
|
|
104
|
-
mockCreateChatMessage.
|
|
85
|
+
const context = createStatelessContext();
|
|
86
|
+
mockCreateValue.call.mockResolvedValue({ data: 'Hello World.' });
|
|
87
|
+
mockCreateChatMessage.call.mockResolvedValue({ data: undefined });
|
|
105
88
|
|
|
106
89
|
await processor.process(workflow, {}, context);
|
|
107
90
|
|
|
108
|
-
expect(mockCreateChatMessage.
|
|
91
|
+
expect(mockCreateChatMessage.call).toHaveBeenCalledWith(
|
|
109
92
|
{
|
|
110
93
|
role: 'assistant',
|
|
111
94
|
content: 'Data access using custom helper: Hello World.',
|
|
112
95
|
},
|
|
113
|
-
|
|
114
|
-
expect.anything(),
|
|
115
|
-
expect.anything(),
|
|
96
|
+
undefined,
|
|
116
97
|
);
|
|
117
98
|
});
|
|
118
99
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Module } from '@nestjs/common';
|
|
2
|
-
import {
|
|
2
|
+
import { LoopCoreModule } from '@loopstack/core';
|
|
3
3
|
import { CreateChatMessageToolModule } from '@loopstack/create-chat-message-tool';
|
|
4
4
|
import { CreateValueToolModule } from '@loopstack/create-value-tool';
|
|
5
5
|
import { WorkflowToolResultsWorkflow } from './workflow-tool-results.workflow';
|
|
6
6
|
|
|
7
7
|
@Module({
|
|
8
|
-
imports: [
|
|
8
|
+
imports: [LoopCoreModule, CreateValueToolModule, CreateChatMessageToolModule],
|
|
9
9
|
providers: [WorkflowToolResultsWorkflow],
|
|
10
10
|
exports: [WorkflowToolResultsWorkflow],
|
|
11
11
|
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
title: 'Workflow Tool Result'
|
|
@@ -1,27 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseWorkflow, Final, Initial, InjectTool, Workflow } from '@loopstack/common';
|
|
2
2
|
import { CreateChatMessage } from '@loopstack/create-chat-message-tool';
|
|
3
3
|
import { CreateValue } from '@loopstack/create-value-tool';
|
|
4
4
|
|
|
5
5
|
@Workflow({
|
|
6
|
-
|
|
6
|
+
uiConfig: __dirname + '/workflow-tool-results.ui.yaml',
|
|
7
7
|
})
|
|
8
|
-
export class WorkflowToolResultsWorkflow {
|
|
8
|
+
export class WorkflowToolResultsWorkflow extends BaseWorkflow {
|
|
9
9
|
@InjectTool() private createValue: CreateValue;
|
|
10
10
|
@InjectTool() private createChatMessage: CreateChatMessage;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
storedMessage?: string;
|
|
13
|
+
|
|
14
|
+
@Initial({ to: 'data_created' })
|
|
15
|
+
async createSomeData() {
|
|
16
|
+
const result = await this.createValue.call({ input: 'Hello World.' });
|
|
17
|
+
this.storedMessage = result.data as string;
|
|
18
|
+
|
|
19
|
+
await this.createChatMessage.call({
|
|
20
|
+
role: 'assistant',
|
|
21
|
+
content: `Data from specific call id: ${this.storedMessage}`,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
await this.createChatMessage.call({
|
|
25
|
+
role: 'assistant',
|
|
26
|
+
content: `Data from first tool call: ${this.storedMessage}`,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Final({ from: 'data_created' })
|
|
31
|
+
async accessData() {
|
|
32
|
+
await this.createChatMessage.call({
|
|
33
|
+
role: 'assistant',
|
|
34
|
+
content: `Data from previous transition: ${this.storedMessage}`,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await this.createChatMessage.call({
|
|
38
|
+
role: 'assistant',
|
|
39
|
+
content: `Data access using custom helper: ${this.theMessage()}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private theMessage(): string {
|
|
44
|
+
return this.storedMessage!;
|
|
26
45
|
}
|
|
27
46
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
title: 'Workflow Tool Result'
|
|
2
|
-
|
|
3
|
-
transitions:
|
|
4
|
-
- id: create_some_data
|
|
5
|
-
from: start
|
|
6
|
-
to: data_created
|
|
7
|
-
call:
|
|
8
|
-
# Create test data and return it in the tool result
|
|
9
|
-
- id: say_hello
|
|
10
|
-
tool: createValue
|
|
11
|
-
args:
|
|
12
|
-
input: 'Hello World.'
|
|
13
|
-
|
|
14
|
-
# Access the data using the call id as identifier
|
|
15
|
-
- tool: createChatMessage
|
|
16
|
-
args:
|
|
17
|
-
role: 'assistant'
|
|
18
|
-
content: 'Data from specific call id: {{ runtime.tools.create_some_data.say_hello.data }}'
|
|
19
|
-
|
|
20
|
-
# Access the data using the call index
|
|
21
|
-
- tool: createChatMessage
|
|
22
|
-
args:
|
|
23
|
-
role: 'assistant'
|
|
24
|
-
content: 'Data from first tool call: {{ runtime.tools.create_some_data.0.data }}'
|
|
25
|
-
|
|
26
|
-
- id: access_data
|
|
27
|
-
from: data_created
|
|
28
|
-
to: end
|
|
29
|
-
call:
|
|
30
|
-
# Access the data from a previous transition using transition and call id
|
|
31
|
-
- tool: createChatMessage
|
|
32
|
-
args:
|
|
33
|
-
role: 'assistant'
|
|
34
|
-
content: 'Data from previous transition: {{ runtime.tools.create_some_data.say_hello.data }}'
|
|
35
|
-
|
|
36
|
-
# Access the data using a custom helper function of the workflow
|
|
37
|
-
- tool: createChatMessage
|
|
38
|
-
args:
|
|
39
|
-
role: 'assistant'
|
|
40
|
-
content: 'Data access using custom helper: {{ theMessage }}'
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
title: 'Workflow Tool Result'
|
|
2
|
-
|
|
3
|
-
transitions:
|
|
4
|
-
- id: create_some_data
|
|
5
|
-
from: start
|
|
6
|
-
to: data_created
|
|
7
|
-
call:
|
|
8
|
-
# Create test data and return it in the tool result
|
|
9
|
-
- id: say_hello
|
|
10
|
-
tool: createValue
|
|
11
|
-
args:
|
|
12
|
-
input: 'Hello World.'
|
|
13
|
-
|
|
14
|
-
# Access the data using the call id as identifier
|
|
15
|
-
- tool: createChatMessage
|
|
16
|
-
args:
|
|
17
|
-
role: 'assistant'
|
|
18
|
-
content: 'Data from specific call id: {{ runtime.tools.create_some_data.say_hello.data }}'
|
|
19
|
-
|
|
20
|
-
# Access the data using the call index
|
|
21
|
-
- tool: createChatMessage
|
|
22
|
-
args:
|
|
23
|
-
role: 'assistant'
|
|
24
|
-
content: 'Data from first tool call: {{ runtime.tools.create_some_data.0.data }}'
|
|
25
|
-
|
|
26
|
-
- id: access_data
|
|
27
|
-
from: data_created
|
|
28
|
-
to: end
|
|
29
|
-
call:
|
|
30
|
-
# Access the data from a previous transition using transition and call id
|
|
31
|
-
- tool: createChatMessage
|
|
32
|
-
args:
|
|
33
|
-
role: 'assistant'
|
|
34
|
-
content: 'Data from previous transition: {{ runtime.tools.create_some_data.say_hello.data }}'
|
|
35
|
-
|
|
36
|
-
# Access the data using a custom helper function of the workflow
|
|
37
|
-
- tool: createChatMessage
|
|
38
|
-
args:
|
|
39
|
-
role: 'assistant'
|
|
40
|
-
content: 'Data access using custom helper: {{ theMessage }}'
|