Skip to content

Commit 278656f

Browse files
[tools] Update tools to use structuredContent with schema
1 parent 7950c92 commit 278656f

4 files changed

Lines changed: 20 additions & 18 deletions

File tree

src/tools/bounding-box-tool/BoundingBoxTool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ export class BoundingBoxTool extends BaseTool<
7171
content: [
7272
{
7373
type: 'text',
74-
text: JSON.stringify({ data: bbox }, null, 2)
74+
text: JSON.stringify({ data: { bbox } }, null, 2)
7575
}
7676
],
7777
structuredContent: {
78-
data: bbox
78+
data: { bbox }
7979
},
8080
isError: false
8181
};

src/tools/bounding-box-tool/CountryBoundingBoxTool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ export class CountryBoundingBoxTool extends BaseTool<
6161
content: [
6262
{
6363
type: 'text',
64-
text: JSON.stringify({ data: bbox }, null, 2)
64+
text: JSON.stringify({ data: { bbox } }, null, 2)
6565
}
6666
],
6767
structuredContent: {
68-
data: bbox
68+
data: { bbox }
6969
},
7070
isError: false
7171
};

test/tools/bounding-box-tool/BoundingBoxTool.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('BoundingBoxTool', () => {
2626
expect(result.content[0]).toHaveProperty('type', 'text');
2727
const textContent = result.content[0] as TextContent;
2828
expect(JSON.parse(textContent.text)).toEqual({
29-
data: [-73.9857, 40.7484, -73.9857, 40.7484]
29+
data: { bbox: [-73.9857, 40.7484, -73.9857, 40.7484] }
3030
});
3131
});
3232

@@ -42,7 +42,7 @@ describe('BoundingBoxTool', () => {
4242
expect(result.content[0]).toHaveProperty('type', 'text');
4343
const textContent = result.content[0] as TextContent;
4444
expect(JSON.parse(textContent.text)).toEqual({
45-
data: [-73.9857, 40.7484, -73.9857, 40.7484]
45+
data: { bbox: [-73.9857, 40.7484, -73.9857, 40.7484] }
4646
});
4747
});
4848

@@ -62,7 +62,7 @@ describe('BoundingBoxTool', () => {
6262
expect(result.content[0]).toHaveProperty('type', 'text');
6363
const textContent = result.content[0] as TextContent;
6464
expect(JSON.parse(textContent.text)).toEqual({
65-
data: [-73.9919, 40.7484, -73.9857, 40.7614]
65+
data: { bbox: [-73.9919, 40.7484, -73.9857, 40.7614] }
6666
});
6767
});
6868

@@ -86,7 +86,7 @@ describe('BoundingBoxTool', () => {
8686
expect(result.content[0]).toHaveProperty('type', 'text');
8787
const textContent = result.content[0] as TextContent;
8888
expect(JSON.parse(textContent.text)).toEqual({
89-
data: [-73.9919, 40.7484, -73.9857, 40.7614]
89+
data: { bbox: [-73.9919, 40.7484, -73.9857, 40.7614] }
9090
});
9191
});
9292

@@ -119,7 +119,7 @@ describe('BoundingBoxTool', () => {
119119
expect(result.content[0]).toHaveProperty('type', 'text');
120120
const textContent = result.content[0] as TextContent;
121121
expect(JSON.parse(textContent.text)).toEqual({
122-
data: [-74.006, 40.7128, -73.9857, 40.7484]
122+
data: { bbox: [-74.006, 40.7128, -73.9857, 40.7484] }
123123
});
124124
});
125125

@@ -139,7 +139,7 @@ describe('BoundingBoxTool', () => {
139139
expect(result.content[0]).toHaveProperty('type', 'text');
140140
const textContent = result.content[0] as TextContent;
141141
expect(JSON.parse(textContent.text)).toEqual({
142-
data: [-74.006, 40.7128, -73.9352, 40.7484]
142+
data: { bbox: [-74.006, 40.7128, -73.9352, 40.7484] }
143143
});
144144
});
145145

@@ -173,7 +173,9 @@ describe('BoundingBoxTool', () => {
173173
expect(result.isError).toBe(false);
174174
expect(result.content[0]).toHaveProperty('type', 'text');
175175
const textContent = result.content[0] as TextContent;
176-
expect(JSON.parse(textContent.text)).toEqual({ data: [0, 0, 3, 3] });
176+
expect(JSON.parse(textContent.text)).toEqual({
177+
data: { bbox: [0, 0, 3, 3] }
178+
});
177179
});
178180

179181
it('should calculate bounding box for a GeometryCollection', async () => {
@@ -200,7 +202,7 @@ describe('BoundingBoxTool', () => {
200202
expect(result.content[0]).toHaveProperty('type', 'text');
201203
const textContent = result.content[0] as TextContent;
202204
expect(JSON.parse(textContent.text)).toEqual({
203-
data: [-74.006, 40.7128, -73.9352, 40.7484]
205+
data: { bbox: [-74.006, 40.7128, -73.9352, 40.7484] }
204206
});
205207
});
206208

test/tools/bounding-box-tool/CountryBoundingBoxTool.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('CountryBoundingBoxTool', () => {
2222
const textContent = result.content[0] as TextContent;
2323
const bbox = JSON.parse(textContent.text);
2424
expect(bbox).toEqual({
25-
data: [73.599819, 21.144707, 134.762115, 53.424591]
25+
data: { bbox: [73.599819, 21.144707, 134.762115, 53.424591] }
2626
});
2727
});
2828

@@ -34,7 +34,7 @@ describe('CountryBoundingBoxTool', () => {
3434
const textContent = result.content[0] as TextContent;
3535
const bbox = JSON.parse(textContent.text);
3636
expect(bbox).toEqual({
37-
data: [-168.069693, 25.133463, -67.292669, 71.284212]
37+
data: { bbox: [-168.069693, 25.133463, -67.292669, 71.284212] }
3838
});
3939
});
4040

@@ -46,7 +46,7 @@ describe('CountryBoundingBoxTool', () => {
4646
const textContent = result.content[0] as TextContent;
4747
const bbox = JSON.parse(textContent.text);
4848
expect(bbox).toEqual({
49-
data: [51.590737, 22.705773, 56.376954, 26.050548]
49+
data: { bbox: [51.590737, 22.705773, 56.376954, 26.050548] }
5050
});
5151
});
5252

@@ -58,7 +58,7 @@ describe('CountryBoundingBoxTool', () => {
5858
const textContent = result.content[0] as TextContent;
5959
const bbox = JSON.parse(textContent.text);
6060
expect(bbox).toEqual({
61-
data: [73.599819, 21.144707, 134.762115, 53.424591]
61+
data: { bbox: [73.599819, 21.144707, 134.762115, 53.424591] }
6262
});
6363
});
6464

@@ -70,7 +70,7 @@ describe('CountryBoundingBoxTool', () => {
7070
const textContent = result.content[0] as TextContent;
7171
const bbox = JSON.parse(textContent.text);
7272
expect(bbox).toEqual({
73-
data: [-168.069693, 25.133463, -67.292669, 71.284212]
73+
data: { bbox: [-168.069693, 25.133463, -67.292669, 71.284212] }
7474
});
7575
});
7676

@@ -175,7 +175,7 @@ describe('CountryBoundingBoxTool', () => {
175175
if (!result.isError) {
176176
expect(result.content[0]).toHaveProperty('type', 'text');
177177
const textContent = result.content[0] as TextContent;
178-
const bbox = JSON.parse(textContent.text).data;
178+
const bbox = JSON.parse(textContent.text).data.bbox;
179179
expect(Array.isArray(bbox)).toBe(true);
180180
expect(bbox).toHaveLength(4);
181181
}

0 commit comments

Comments
 (0)