Skip to content

Commit 1ba3b1f

Browse files
authored
Merge pull request #382 from thedadams/tool-type-changes
chore: check for "not text" instead of "tool"
2 parents 03344d3 + 7a1cc7c commit 1ba3b1f

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

actions/gptscript.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import { createAction } from '@/actions/helpers';
66

77
export const rootTool = async (toolContent: Block[]): Promise<Tool> => {
88
for (const block of toolContent) {
9-
if (block.type === 'tool') return block;
9+
if (block.type !== 'text') return block;
1010
}
1111
return {} as Tool;
1212
};
1313

1414
export const parseContent = async (toolContent: string): Promise<Tool[]> => {
1515
const parsedTool = await gpt().parseContent(toolContent);
1616
return parsedTool.filter(
17-
(block) => block.type === 'tool' && !block.name?.startsWith('metadata')
17+
(block) => block.type !== 'text' && !block.name?.startsWith('metadata')
1818
) as Tool[];
1919
};
2020

@@ -25,7 +25,7 @@ export const parseBlock = createAction(async (ref: string) => {
2525
export const parse = async (file: string): Promise<Tool[]> => {
2626
const parsedTool = await gpt().parse(file);
2727
return parsedTool.filter(
28-
(block) => block.type === 'tool' && !block.name?.startsWith('metadata')
28+
(block) => block.type !== 'text' && !block.name?.startsWith('metadata')
2929
) as Tool[];
3030
};
3131

components/scripts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default function Scripts({ showFavorites }: ScriptsProps) {
7979
displayName: 'Copy of ' + script.agentName ?? script.displayName,
8080
visibility: 'private',
8181
};
82-
if (script.script.length > 0 && script.script[0].type === 'tool') {
82+
if (script.script.length > 0 && script.script[0].type !== 'text') {
8383
(script.script[0] as Tool).name = toCreate.displayName;
8484
}
8585
toCreate.content = await stringify(script.script);

components/scripts/script-save.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const SaveScriptDropdown = () => {
9898

9999
if (
100100
!scriptContent.find(
101-
(t) => t.type === 'tool' && t.name === KNOWLEDGE_NAME
101+
(t) => t.type !== 'text' && t.name === KNOWLEDGE_NAME
102102
)
103103
) {
104104
newKnowledgeToolBlock = await assistantKnowledgeTool(scriptID, 10);

contexts/edit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ const EditContextProvider: React.FC<EditContextProps> = ({
327327
withoutRoot.splice(i, 1);
328328
break;
329329
}
330-
return withoutRoot.filter((block) => block.type === 'tool') as Tool[];
330+
return withoutRoot.filter((block) => block.type !== 'text') as Tool[];
331331
},
332332
[root]
333333
);

server/app.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ const mount = async (
176176

177177
// also load the tools defined the states so that when running a thread that has tools added in state, we don't lose them
178178
for (let block of script) {
179-
if (block.type === 'tool') {
179+
if (block.type !== 'text') {
180180
block.tools = [
181181
...new Set([...(block.tools || []), ...(state.tools || [])]),
182182
];
@@ -267,7 +267,7 @@ const mount = async (
267267

268268
// find the root tool and then add the new tool
269269
for (let block of script) {
270-
if (block.type === 'tool') {
270+
if (block.type !== 'text') {
271271
block.tools = [...new Set([...(block.tools || []), tool])];
272272
break;
273273
}
@@ -296,7 +296,7 @@ const mount = async (
296296

297297
// find the root tool and then remove the tool
298298
for (let block of script) {
299-
if (block.type === 'tool') {
299+
if (block.type !== 'text') {
300300
if (block.tools) {
301301
block.tools = [...new Set(block.tools.filter((t) => t !== tool))];
302302
}
@@ -325,7 +325,7 @@ const mount = async (
325325

326326
state.tools = [];
327327
for (let block of script) {
328-
if (block.type === 'tool') {
328+
if (block.type !== 'text') {
329329
block.name = newName || block.name;
330330
block.tools = [
331331
...new Set([
@@ -335,7 +335,7 @@ const mount = async (
335335
if (extraTools) {
336336
script = [...script, ...extraTools];
337337
block.tools.push(
338-
...extraTools.filter((t) => t.type === 'tool').map((t) => t.name)
338+
...extraTools.filter((t) => t.type !== 'text').map((t) => t.name)
339339
);
340340
}
341341
break;

0 commit comments

Comments
 (0)