diff --git a/examples/openai-agents-ts/package-lock.json b/examples/openai-agents-ts/package-lock.json index c802c2cd..f2a42a52 100644 --- a/examples/openai-agents-ts/package-lock.json +++ b/examples/openai-agents-ts/package-lock.json @@ -9,14 +9,14 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@arcadeai/arcadejs": "1.7.0", + "@arcadeai/arcadejs": "1.8.1", "@openai/agents": "^0.0.8" } }, "node_modules/@arcadeai/arcadejs": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@arcadeai/arcadejs/-/arcadejs-1.7.0.tgz", - "integrity": "sha512-Yw6/cUiywm/Ws/OCZvRGLJhmujDXYPmt6NW4DljkrBc/gceSJi/Yhjaum68cqsWXMqyeCM2Mg4PWkxOg8QJ8nA==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@arcadeai/arcadejs/-/arcadejs-1.8.1.tgz", + "integrity": "sha512-ZTj2UvdfFmFn1as4gdDiZD8nbnEFZcZUzH9XtTmjRbgf/1V8s1wEtlzlI3vct+dA+KZ+NhS79AEw5lx/Ki0xSw==", "license": "Apache-2.0", "dependencies": { "@types/node": "^18.11.18", diff --git a/examples/openai-agents-ts/package.json b/examples/openai-agents-ts/package.json index 38bdc786..6636a50b 100644 --- a/examples/openai-agents-ts/package.json +++ b/examples/openai-agents-ts/package.json @@ -11,7 +11,7 @@ "dev:waitForCompletion": "npx tsx --env-file=.env src/waitForCompletion.ts" }, "dependencies": { - "@arcadeai/arcadejs": "1.7.0", + "@arcadeai/arcadejs": "1.8.1", "@openai/agents": "^0.0.8" } } diff --git a/examples/openai-agents-ts/src/index.ts b/examples/openai-agents-ts/src/index.ts index de894bd3..40c4b17d 100644 --- a/examples/openai-agents-ts/src/index.ts +++ b/examples/openai-agents-ts/src/index.ts @@ -7,25 +7,14 @@ const client = new Arcade(); // 2) Fetch Google toolkit from Arcade and prepare tools for OpenAI Agents const googleToolkit = await client.tools.list({ toolkit: "google", limit: 30 }); -const arcadeTools = toZod({ +const tools = toZod({ tools: googleToolkit.items, client, userId: "", // Replace this with your application's user ID (e.g. email address, UUID, etc.) executeFactory: executeOrAuthorizeZodTool, -}) +}).map(tool); -// 3) Convert the tools to a format that OpenAI Agents can use -const tools = arcadeTools.map(({ name, description, execute, parameters }) => - tool({ - name, - description: description ?? "", - parameters: parameters as any, - execute, - strict: true, - }), -); - -// 4) Create a new agent with the Google toolkit +// 3) Create a new agent with the Google toolkit const googleAgent = new Agent({ name: "Google agent", instructions: "You are a helpful assistant that can assist with Google API calls.", @@ -33,8 +22,8 @@ const googleAgent = new Agent({ tools }); -// 5) Run the agent +// 4) Run the agent const result = await run(googleAgent, "What are my latest emails?"); -// 6) Print the result +// 5) Print the result console.log(result.finalOutput); diff --git a/examples/openai-agents-ts/src/waitForCompletion.ts b/examples/openai-agents-ts/src/waitForCompletion.ts index 5ef41dcd..b937464a 100644 --- a/examples/openai-agents-ts/src/waitForCompletion.ts +++ b/examples/openai-agents-ts/src/waitForCompletion.ts @@ -8,24 +8,13 @@ async function main() { // 2) Fetch Google toolkit from Arcade and prepare tools for OpenAI Agents const googleToolkit = await client.tools.list({ toolkit: "google", limit: 30 }); - const arcadeTools = toZod({ + const tools = toZod({ tools: googleToolkit.items, client, userId: "", // Replace this with your application's user ID (e.g. email address, UUID, etc.) - }) + }).map(tool); - // 3) Convert the tools to a format that OpenAI Agents can use - const tools = arcadeTools.map(({ name, description, execute, parameters }) => - tool({ - name, - description: description ?? "", - parameters: parameters as any, - execute, - errorFunction: (_, error) => { throw error } - }), - ); - - // 4) Create a new agent with the Google toolkit + // 3) Create a new agent with the Google toolkit const googleAgent = new Agent({ name: "Google agent", instructions: "You are a helpful assistant that can assist with Google API calls.", @@ -33,7 +22,7 @@ async function main() { tools }); - // 5) Run the agent, if authorization is required, wait for it to complete and retry + // 4) Run the agent, if authorization is required, wait for it to complete and retry while (true) { try { const result = await run(googleAgent, "What are my latest emails?");