Skip to content

Commit

Permalink
chore: move constants to top of file
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhopperlowe committed Sep 11, 2024
1 parent c09d742 commit daca18a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions actions/gptscript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@
import { ToolDef, Tool, Block, Text, Program } from '@gptscript-ai/gptscript';
import { gpt } from '@/config/env';

export const rootTool = async (toolContent: Block[]): Promise<Tool> => {
for (const block of toolContent) {
if (block.type !== 'text') return block;
}
return {} as Tool;
};

export const parseContent = async (toolContent: string): Promise<Tool[]> => {
const parsedTool = await gpt().parseContent(toolContent);
return parsedTool.filter(
(block) => block.type !== 'text' && !block.name?.startsWith('metadata')
) as Tool[];
};

const SystemToolWhitelist = [
'sys.abort',
'sys.append',
Expand All @@ -41,6 +27,20 @@ const SystemToolWhitelist = [
'sys.write',
];

export const rootTool = async (toolContent: Block[]): Promise<Tool> => {
for (const block of toolContent) {
if (block.type !== 'text') return block;
}
return {} as Tool;
};

export const parseContent = async (toolContent: string): Promise<Tool[]> => {
const parsedTool = await gpt().parseContent(toolContent);
return parsedTool.filter(
(block) => block.type !== 'text' && !block.name?.startsWith('metadata')
) as Tool[];
};

/**
* Verifies that a tool exists by parsing it.
* @param toolRef The tool reference to verify.
Expand Down

0 comments on commit daca18a

Please sign in to comment.