Skip to content

Commit bb483f3

Browse files
committed
fix param name from definition to description
1 parent c437599 commit bb483f3

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

packages/event-handler/src/bedrock-agent-function/BedrockAgentFunctionResolver.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import type {
44
BedrockAgentFunctionEvent,
55
BedrockAgentFunctionResponse,
66
Configuration,
7-
GenericLogger,
87
ResolverOptions,
98
ResponseOptions,
109
Tool,
1110
ToolFunction,
12-
} from '../types/index.js';
11+
} from '../types/bedrock-agent-function.js';
12+
import type { GenericLogger } from '../types/common.js';
1313
import { isPrimitive } from './utils.js';
1414

1515
export class BedrockAgentFunctionResolver {
@@ -43,7 +43,7 @@ export class BedrockAgentFunctionResolver {
4343
* return `Hello, ${name}!`;
4444
* }, {
4545
* name: 'greeting',
46-
* definition: 'Greets a person by name',
46+
* description: 'Greets a person by name',
4747
* });
4848
*
4949
* export const handler = async (event, context) =>
@@ -59,7 +59,7 @@ export class BedrockAgentFunctionResolver {
5959
* const app = new BedrockAgentFunctionResolver();
6060
*
6161
* class Lambda {
62-
* @app.tool({ name: 'greeting', definition: 'Greets a person by name' })
62+
* @app.tool({ name: 'greeting', description: 'Greets a person by name' })
6363
* async greeting(params) {
6464
* const { name } = params;
6565
* return `Hello, ${name}!`;
@@ -77,15 +77,16 @@ export class BedrockAgentFunctionResolver {
7777
* @param fn - The tool function
7878
* @param config - The configuration object for the tool
7979
*/
80-
public tool(fn: ToolFunction, config: Configuration): void;
80+
public tool(fn: ToolFunction, config: Configuration): undefined;
8181
public tool(config: Configuration): MethodDecorator;
8282
public tool(
8383
fnOrConfig: ToolFunction | Configuration,
8484
config?: Configuration
85-
): MethodDecorator | void {
85+
): MethodDecorator | undefined {
8686
// When used as a method (not a decorator)
8787
if (typeof fnOrConfig === 'function') {
88-
return this.#registerTool(fnOrConfig, config as Configuration);
88+
this.#registerTool(fnOrConfig, config as Configuration);
89+
return;
8990
}
9091

9192
// When used as a decorator

packages/event-handler/src/types/bedrock-agent-function.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { GenericLogger } from '../types/common.js';
33

44
type Configuration = {
55
name: string;
6-
definition: string;
6+
description: string;
77
};
88

99
type Parameter = {
@@ -12,9 +12,9 @@ type Parameter = {
1212
value: string;
1313
};
1414

15-
type ParameterPrimitives = string | number | boolean
15+
type ParameterPrimitives = string | number | boolean;
1616

17-
type ParameterValue = ParameterPrimitives | Array<ParameterValue>
17+
type ParameterValue = ParameterPrimitives | Array<ParameterValue>;
1818

1919
type Tool<TParams = Record<string, ParameterValue>> = {
2020
// biome-ignore lint/suspicious/noConfusingVoidType: we need to support async functions that don't have an explicit return value

packages/event-handler/tests/unit/bedrock-agent/BedrockAgentFunctionResolver.test.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
3434

3535
app.tool(async (_params) => {}, {
3636
name: 'noop',
37-
definition: 'Does nothing',
37+
description: 'Does nothing',
3838
});
3939

4040
// Assess
@@ -48,7 +48,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
4848

4949
app.tool(async (_params) => {}, {
5050
name: 'noop',
51-
definition: 'Does nothing',
51+
description: 'Does nothing',
5252
});
5353

5454
// Assess
@@ -68,7 +68,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
6868

6969
app.tool(async (_params) => {}, {
7070
name: 'noop',
71-
definition: 'Does nothing',
71+
description: 'Does nothing',
7272
});
7373

7474
// Act
@@ -88,7 +88,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
8888
for (const num of [1, 2, 3, 4, 5]) {
8989
app.tool(async (_params) => {}, {
9090
name: `noop${num}`,
91-
definition: 'Does nothing',
91+
description: 'Does nothing',
9292
});
9393
}
9494

@@ -98,7 +98,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
9898
},
9999
{
100100
name: 'mult',
101-
definition: 'Multiplies two numbers',
101+
description: 'Multiplies two numbers',
102102
}
103103
);
104104

@@ -151,7 +151,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
151151
},
152152
{
153153
name: 'math',
154-
definition: 'Adds two numbers',
154+
description: 'Adds two numbers',
155155
}
156156
);
157157

@@ -167,7 +167,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
167167
},
168168
{
169169
name: 'math',
170-
definition: 'Multiplies two numbers',
170+
description: 'Multiplies two numbers',
171171
}
172172
);
173173

@@ -183,12 +183,12 @@ describe('Class: BedrockAgentFunctionResolver', () => {
183183
const app = new BedrockAgentFunctionResolver();
184184

185185
class Lambda {
186-
@app.tool({ name: 'hello', definition: 'Says hello' })
186+
@app.tool({ name: 'hello', description: 'Says hello' })
187187
async helloWorld() {
188188
return 'Hello, world!';
189189
}
190190

191-
@app.tool({ name: 'add', definition: 'Adds two numbers' })
191+
@app.tool({ name: 'add', description: 'Adds two numbers' })
192192
async add(params: { a: string; b: string }) {
193193
const { a, b } = params;
194194
return Number.parseInt(a) + Number.parseInt(b);
@@ -229,23 +229,23 @@ describe('Class: BedrockAgentFunctionResolver', () => {
229229
toolFunction: async () => 'Hello, world',
230230
toolParams: {
231231
name: 'string',
232-
definition: 'Returns string',
232+
description: 'Returns string',
233233
},
234234
expected: 'Hello, world',
235235
},
236236
{
237237
toolFunction: async () => 42,
238238
toolParams: {
239239
name: 'number',
240-
definition: 'Returns number',
240+
description: 'Returns number',
241241
},
242242
expected: '42',
243243
},
244244
{
245245
toolFunction: async () => true,
246246
toolParams: {
247247
name: 'boolean',
248-
definition: 'Returns boolean',
248+
description: 'Returns boolean',
249249
},
250250
expected: 'true',
251251
},
@@ -261,7 +261,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
261261
}),
262262
toolParams: {
263263
name: 'object',
264-
definition: 'Returns an object',
264+
description: 'Returns an object',
265265
},
266266
expected:
267267
'{"name":"John Doe","age":30,"isActive":true,"address":{"street":"123 Main St","city":"Anytown"}}',
@@ -270,7 +270,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
270270
toolFunction: async () => [1, 'two', false, null],
271271
toolParams: {
272272
name: 'array',
273-
definition: 'Returns an array',
273+
description: 'Returns an array',
274274
},
275275
expected: '[1,"two",false,null]',
276276
},
@@ -298,14 +298,14 @@ describe('Class: BedrockAgentFunctionResolver', () => {
298298
toolFunction: async () => null,
299299
toolParams: {
300300
name: 'null',
301-
definition: 'Returns null',
301+
description: 'Returns null',
302302
},
303303
},
304304
{
305305
toolFunction: async () => void 0,
306306
toolParams: {
307307
name: 'undefined',
308-
definition: 'Returns undefined',
308+
description: 'Returns undefined',
309309
},
310310
},
311311
])(
@@ -337,7 +337,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
337337
},
338338
{
339339
name: 'error-tool',
340-
definition: 'Throws an error',
340+
description: 'Throws an error',
341341
}
342342
);
343343

@@ -365,7 +365,7 @@ describe('Class: BedrockAgentFunctionResolver', () => {
365365
},
366366
{
367367
name: 'greeting',
368-
definition: 'Greets a person by name',
368+
description: 'Greets a person by name',
369369
}
370370
);
371371

0 commit comments

Comments
 (0)