@parallel-web/ai-sdk-tools 0.1.1-canary.023f473

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # @parallel-web/ai-sdk-tools
2
+
3
+ AI SDK tools for Parallel Web.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @parallel-web/ai-sdk-tools
9
+ # or
10
+ pnpm add @parallel-web/ai-sdk-tools
11
+ # or
12
+ yarn add @parallel-web/ai-sdk-tools
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ Add `PARALLEL_API_KEY` obtained from [Parallel Platform](https://platform.parallel.ai/settings?tab=api-keys) to your environment variables.
18
+
19
+ ### With Vercel AI SDK
20
+
21
+ The `searchTool` integrates seamlessly with Vercel's AI SDK for tool calling:
22
+
23
+ ```typescript
24
+ import { openai } from '@ai-sdk/openai';
25
+ import { streamText } from 'ai';
26
+ import { searchTool } from '@parallel-web/ai-sdk-tools';
27
+
28
+ const result = streamText({
29
+ model: openai('gpt-4o'),
30
+ messages: [
31
+ { role: 'user', content: 'What are the latest developments in AI?' }
32
+ ],
33
+ tools: {
34
+ 'web-search': searchTool,
35
+ },
36
+ toolChoice: 'auto',
37
+ });
38
+
39
+ // Stream the response
40
+ return result.toDataStreamResponse();
41
+ ```
42
+
43
+ ### Next.js Simple Route Handler Example
44
+
45
+ ```typescript
46
+ import { openai } from '@ai-sdk/openai';
47
+ import { streamText, convertToModelMessages } from 'ai';
48
+ import { searchTool } from '@parallel-web/ai-sdk-tools';
49
+
50
+ export async function POST(req: Request) {
51
+ const { messages } = await req.json();
52
+
53
+ const result = streamText({
54
+ model: openai('gpt-4o'),
55
+ messages: convertToModelMessages(messages),
56
+ tools: {
57
+ 'web-search': searchTool,
58
+ },
59
+ toolChoice: 'auto',
60
+ });
61
+
62
+ return result.toDataStreamResponse();
63
+ }
64
+ ```
65
+
66
+
67
+
68
+
package/dist/index.cjs ADDED
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ var parallelWeb = require('parallel-web');
4
+ var ai = require('ai');
5
+ var zod = require('zod');
6
+
7
+ // src/client.ts
8
+ var _parallelClient = null;
9
+ var parallelClient = new Proxy({}, {
10
+ get(_target, prop) {
11
+ if (!_parallelClient) {
12
+ _parallelClient = new parallelWeb.Parallel({
13
+ apiKey: process.env["PARALLEL_API_KEY"]
14
+ });
15
+ }
16
+ return _parallelClient[prop];
17
+ }
18
+ });
19
+ var search = async (searchArgs, { abortSignal }) => {
20
+ return await parallelClient.beta.search(
21
+ {
22
+ ...searchArgs
23
+ },
24
+ {
25
+ signal: abortSignal
26
+ }
27
+ );
28
+ };
29
+ var searchTool = ai.tool({
30
+ description: "Search Tool to quickly search in websites and published/public information on the internet like news, articles, blogs, posts, products, services, etc.",
31
+ parameters: zod.z.object({
32
+ objective: zod.z.string().describe(
33
+ "Natural-language description of what the web search is trying to find. May include guidance about preferred sources or freshness. At least one of objective or search_queries must be provided."
34
+ ),
35
+ search_queries: zod.z.array(zod.z.string()).optional().describe(
36
+ "Optional list of traditional keyword search queries to guide the search. May contain search operators. At least one of objective or search_queries must be provided."
37
+ ),
38
+ processor: zod.z.enum(["pro", "base"]).optional().describe(
39
+ "The processor to use for the search. `pro` is recommended for complex queries, or incomplete objectives. `base` is recommended for simple queries."
40
+ ),
41
+ max_results: zod.z.number().optional().describe(
42
+ "The maximum number of results to return. Default is 10. Optional value, do not pass if not needed."
43
+ ),
44
+ source_policy: zod.z.object({
45
+ include_domains: zod.z.array(zod.z.string()).optional().describe("The sources to include in the search. Optional value."),
46
+ exclude_domains: zod.z.array(zod.z.string()).optional().describe("The sources to exclude in the search. Optional value.")
47
+ }).optional().describe("The policy to use for the search. Optional value.")
48
+ }),
49
+ execute: async function({ ...args }, { abortSignal }) {
50
+ const results = await search(args, { abortSignal });
51
+ return {
52
+ searchParams: args,
53
+ answer: results
54
+ };
55
+ }
56
+ });
57
+
58
+ exports.parallelClient = parallelClient;
59
+ exports.searchTool = searchTool;
60
+ //# sourceMappingURL=index.cjs.map
61
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts","../src/tools/search.ts"],"names":["Parallel","tool","z"],"mappings":";;;;;;;AAMA,IAAI,eAAA,GAAmC,IAAA;AAEhC,IAAM,cAAA,GAAiB,IAAI,KAAA,CAAM,EAAC,EAAe;AAAA,EACtD,GAAA,CAAI,SAAS,IAAA,EAAM;AACjB,IAAA,IAAI,CAAC,eAAA,EAAiB;AACpB,MAAA,eAAA,GAAkB,IAAIA,oBAAA,CAAS;AAAA,QAC7B,MAAA,EAAQ,OAAA,CAAQ,GAAA,CAAI,kBAAkB;AAAA,OACvC,CAAA;AAAA,IACH;AACA,IAAA,OAAQ,gBAAwB,IAAI,CAAA;AAAA,EACtC;AACF,CAAC;ACRD,IAAM,MAAA,GAAS,OACb,UAAA,EACA,EAAE,aAAY,KACX;AACH,EAAA,OAAO,MAAM,eAAe,IAAA,CAAK,MAAA;AAAA,IAC/B;AAAA,MACE,GAAG;AAAA,KACL;AAAA,IACA;AAAA,MACE,MAAA,EAAQ;AAAA;AACV,GACF;AACF,CAAA;AAEO,IAAM,aAAaC,OAAA,CAAK;AAAA,EAC7B,WAAA,EACE,wJAAA;AAAA,EACF,UAAA,EAAYC,MAAE,MAAA,CAAO;AAAA,IACnB,SAAA,EAAWA,KAAA,CACR,MAAA,EAAO,CACP,QAAA;AAAA,MACC;AAAA,KACF;AAAA,IACF,cAAA,EAAgBA,MACb,KAAA,CAAMA,KAAA,CAAE,QAAQ,CAAA,CAChB,UAAS,CACT,QAAA;AAAA,MACC;AAAA,KACF;AAAA,IACF,SAAA,EAAWA,MACR,IAAA,CAAK,CAAC,OAAO,MAAM,CAAC,CAAA,CACpB,QAAA,EAAS,CACT,QAAA;AAAA,MACC;AAAA,KACF;AAAA,IACF,WAAA,EAAaA,KAAA,CACV,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,MACC;AAAA,KACF;AAAA,IACF,aAAA,EAAeA,MACZ,MAAA,CAAO;AAAA,MACN,eAAA,EAAiBA,KAAA,CACd,KAAA,CAAMA,KAAA,CAAE,MAAA,EAAQ,CAAA,CAChB,QAAA,EAAS,CACT,QAAA,CAAS,uDAAuD,CAAA;AAAA,MACnE,eAAA,EAAiBA,KAAA,CACd,KAAA,CAAMA,KAAA,CAAE,MAAA,EAAQ,CAAA,CAChB,QAAA,EAAS,CACT,QAAA,CAAS,uDAAuD;AAAA,KACpE,CAAA,CACA,QAAA,EAAS,CACT,SAAS,mDAAmD;AAAA,GAChE,CAAA;AAAA,EAED,OAAA,EAAS,eAAgB,EAAE,GAAG,MAAK,EAAG,EAAE,aAAY,EAAG;AACrD,IAAA,MAAM,UAAU,MAAM,MAAA,CAAO,IAAA,EAAM,EAAE,aAAa,CAAA;AAElD,IAAA,OAAO;AAAA,MACL,YAAA,EAAc,IAAA;AAAA,MACd,MAAA,EAAQ;AAAA,KACV;AAAA,EACF;AACF,CAAC","file":"index.cjs","sourcesContent":["/**\n * Shared Parallel Web client instance\n */\n\nimport { Parallel } from 'parallel-web';\n\nlet _parallelClient: Parallel | null = null;\n\nexport const parallelClient = new Proxy({} as Parallel, {\n get(_target, prop) {\n if (!_parallelClient) {\n _parallelClient = new Parallel({\n apiKey: process.env['PARALLEL_API_KEY'],\n });\n }\n return (_parallelClient as any)[prop];\n },\n});\n","/**\n * Search tool for Parallel Web\n */\n\nimport { tool } from 'ai';\nimport { z } from 'zod';\nimport { BetaSearchParams } from 'parallel-web/resources/beta/beta.mjs';\nimport { parallelClient } from '../client.js';\n\nconst search = async (\n searchArgs: BetaSearchParams,\n { abortSignal }: { abortSignal: AbortSignal | undefined }\n) => {\n return await parallelClient.beta.search(\n {\n ...searchArgs,\n },\n {\n signal: abortSignal,\n }\n );\n};\n\nexport const searchTool = tool({\n description:\n 'Search Tool to quickly search in websites and published/public information on the internet like news, articles, blogs, posts, products, services, etc.',\n parameters: z.object({\n objective: z\n .string()\n .describe(\n 'Natural-language description of what the web search is trying to find. May include guidance about preferred sources or freshness. At least one of objective or search_queries must be provided.'\n ),\n search_queries: z\n .array(z.string())\n .optional()\n .describe(\n 'Optional list of traditional keyword search queries to guide the search. May contain search operators. At least one of objective or search_queries must be provided.'\n ),\n processor: z\n .enum(['pro', 'base'])\n .optional()\n .describe(\n 'The processor to use for the search. `pro` is recommended for complex queries, or incomplete objectives. `base` is recommended for simple queries.'\n ),\n max_results: z\n .number()\n .optional()\n .describe(\n 'The maximum number of results to return. Default is 10. Optional value, do not pass if not needed.'\n ),\n source_policy: z\n .object({\n include_domains: z\n .array(z.string())\n .optional()\n .describe('The sources to include in the search. Optional value.'),\n exclude_domains: z\n .array(z.string())\n .optional()\n .describe('The sources to exclude in the search. Optional value.'),\n })\n .optional()\n .describe('The policy to use for the search. Optional value.'),\n }),\n\n execute: async function ({ ...args }, { abortSignal }) {\n const results = await search(args, { abortSignal });\n\n return {\n searchParams: args,\n answer: results,\n };\n },\n});\n"]}
@@ -0,0 +1,82 @@
1
+ import { Parallel } from 'parallel-web';
2
+ import * as ai from 'ai';
3
+ import * as parallel_web_resources_beta_beta_mjs from 'parallel-web/resources/beta/beta.mjs';
4
+ import { z } from 'zod';
5
+
6
+ /**
7
+ * Shared Parallel Web client instance
8
+ */
9
+
10
+ declare const parallelClient: Parallel;
11
+
12
+ declare const searchTool: ai.Tool<z.ZodObject<{
13
+ objective: z.ZodString;
14
+ search_queries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
15
+ processor: z.ZodOptional<z.ZodEnum<["pro", "base"]>>;
16
+ max_results: z.ZodOptional<z.ZodNumber>;
17
+ source_policy: z.ZodOptional<z.ZodObject<{
18
+ include_domains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
19
+ exclude_domains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ include_domains?: string[] | undefined;
22
+ exclude_domains?: string[] | undefined;
23
+ }, {
24
+ include_domains?: string[] | undefined;
25
+ exclude_domains?: string[] | undefined;
26
+ }>>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ objective: string;
29
+ search_queries?: string[] | undefined;
30
+ processor?: "pro" | "base" | undefined;
31
+ max_results?: number | undefined;
32
+ source_policy?: {
33
+ include_domains?: string[] | undefined;
34
+ exclude_domains?: string[] | undefined;
35
+ } | undefined;
36
+ }, {
37
+ objective: string;
38
+ search_queries?: string[] | undefined;
39
+ processor?: "pro" | "base" | undefined;
40
+ max_results?: number | undefined;
41
+ source_policy?: {
42
+ include_domains?: string[] | undefined;
43
+ exclude_domains?: string[] | undefined;
44
+ } | undefined;
45
+ }>, {
46
+ searchParams: {
47
+ objective: string;
48
+ search_queries?: string[] | undefined;
49
+ processor?: "pro" | "base" | undefined;
50
+ max_results?: number | undefined;
51
+ source_policy?: {
52
+ include_domains?: string[] | undefined;
53
+ exclude_domains?: string[] | undefined;
54
+ } | undefined;
55
+ };
56
+ answer: parallel_web_resources_beta_beta_mjs.SearchResult;
57
+ }> & {
58
+ execute: (args: {
59
+ objective: string;
60
+ search_queries?: string[] | undefined;
61
+ processor?: "pro" | "base" | undefined;
62
+ max_results?: number | undefined;
63
+ source_policy?: {
64
+ include_domains?: string[] | undefined;
65
+ exclude_domains?: string[] | undefined;
66
+ } | undefined;
67
+ }, options: ai.ToolExecutionOptions) => PromiseLike<{
68
+ searchParams: {
69
+ objective: string;
70
+ search_queries?: string[] | undefined;
71
+ processor?: "pro" | "base" | undefined;
72
+ max_results?: number | undefined;
73
+ source_policy?: {
74
+ include_domains?: string[] | undefined;
75
+ exclude_domains?: string[] | undefined;
76
+ } | undefined;
77
+ };
78
+ answer: parallel_web_resources_beta_beta_mjs.SearchResult;
79
+ }>;
80
+ };
81
+
82
+ export { parallelClient, searchTool };
@@ -0,0 +1,82 @@
1
+ import { Parallel } from 'parallel-web';
2
+ import * as ai from 'ai';
3
+ import * as parallel_web_resources_beta_beta_mjs from 'parallel-web/resources/beta/beta.mjs';
4
+ import { z } from 'zod';
5
+
6
+ /**
7
+ * Shared Parallel Web client instance
8
+ */
9
+
10
+ declare const parallelClient: Parallel;
11
+
12
+ declare const searchTool: ai.Tool<z.ZodObject<{
13
+ objective: z.ZodString;
14
+ search_queries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
15
+ processor: z.ZodOptional<z.ZodEnum<["pro", "base"]>>;
16
+ max_results: z.ZodOptional<z.ZodNumber>;
17
+ source_policy: z.ZodOptional<z.ZodObject<{
18
+ include_domains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
19
+ exclude_domains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ include_domains?: string[] | undefined;
22
+ exclude_domains?: string[] | undefined;
23
+ }, {
24
+ include_domains?: string[] | undefined;
25
+ exclude_domains?: string[] | undefined;
26
+ }>>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ objective: string;
29
+ search_queries?: string[] | undefined;
30
+ processor?: "pro" | "base" | undefined;
31
+ max_results?: number | undefined;
32
+ source_policy?: {
33
+ include_domains?: string[] | undefined;
34
+ exclude_domains?: string[] | undefined;
35
+ } | undefined;
36
+ }, {
37
+ objective: string;
38
+ search_queries?: string[] | undefined;
39
+ processor?: "pro" | "base" | undefined;
40
+ max_results?: number | undefined;
41
+ source_policy?: {
42
+ include_domains?: string[] | undefined;
43
+ exclude_domains?: string[] | undefined;
44
+ } | undefined;
45
+ }>, {
46
+ searchParams: {
47
+ objective: string;
48
+ search_queries?: string[] | undefined;
49
+ processor?: "pro" | "base" | undefined;
50
+ max_results?: number | undefined;
51
+ source_policy?: {
52
+ include_domains?: string[] | undefined;
53
+ exclude_domains?: string[] | undefined;
54
+ } | undefined;
55
+ };
56
+ answer: parallel_web_resources_beta_beta_mjs.SearchResult;
57
+ }> & {
58
+ execute: (args: {
59
+ objective: string;
60
+ search_queries?: string[] | undefined;
61
+ processor?: "pro" | "base" | undefined;
62
+ max_results?: number | undefined;
63
+ source_policy?: {
64
+ include_domains?: string[] | undefined;
65
+ exclude_domains?: string[] | undefined;
66
+ } | undefined;
67
+ }, options: ai.ToolExecutionOptions) => PromiseLike<{
68
+ searchParams: {
69
+ objective: string;
70
+ search_queries?: string[] | undefined;
71
+ processor?: "pro" | "base" | undefined;
72
+ max_results?: number | undefined;
73
+ source_policy?: {
74
+ include_domains?: string[] | undefined;
75
+ exclude_domains?: string[] | undefined;
76
+ } | undefined;
77
+ };
78
+ answer: parallel_web_resources_beta_beta_mjs.SearchResult;
79
+ }>;
80
+ };
81
+
82
+ export { parallelClient, searchTool };
package/dist/index.js ADDED
@@ -0,0 +1,58 @@
1
+ import { Parallel } from 'parallel-web';
2
+ import { tool } from 'ai';
3
+ import { z } from 'zod';
4
+
5
+ // src/client.ts
6
+ var _parallelClient = null;
7
+ var parallelClient = new Proxy({}, {
8
+ get(_target, prop) {
9
+ if (!_parallelClient) {
10
+ _parallelClient = new Parallel({
11
+ apiKey: process.env["PARALLEL_API_KEY"]
12
+ });
13
+ }
14
+ return _parallelClient[prop];
15
+ }
16
+ });
17
+ var search = async (searchArgs, { abortSignal }) => {
18
+ return await parallelClient.beta.search(
19
+ {
20
+ ...searchArgs
21
+ },
22
+ {
23
+ signal: abortSignal
24
+ }
25
+ );
26
+ };
27
+ var searchTool = tool({
28
+ description: "Search Tool to quickly search in websites and published/public information on the internet like news, articles, blogs, posts, products, services, etc.",
29
+ parameters: z.object({
30
+ objective: z.string().describe(
31
+ "Natural-language description of what the web search is trying to find. May include guidance about preferred sources or freshness. At least one of objective or search_queries must be provided."
32
+ ),
33
+ search_queries: z.array(z.string()).optional().describe(
34
+ "Optional list of traditional keyword search queries to guide the search. May contain search operators. At least one of objective or search_queries must be provided."
35
+ ),
36
+ processor: z.enum(["pro", "base"]).optional().describe(
37
+ "The processor to use for the search. `pro` is recommended for complex queries, or incomplete objectives. `base` is recommended for simple queries."
38
+ ),
39
+ max_results: z.number().optional().describe(
40
+ "The maximum number of results to return. Default is 10. Optional value, do not pass if not needed."
41
+ ),
42
+ source_policy: z.object({
43
+ include_domains: z.array(z.string()).optional().describe("The sources to include in the search. Optional value."),
44
+ exclude_domains: z.array(z.string()).optional().describe("The sources to exclude in the search. Optional value.")
45
+ }).optional().describe("The policy to use for the search. Optional value.")
46
+ }),
47
+ execute: async function({ ...args }, { abortSignal }) {
48
+ const results = await search(args, { abortSignal });
49
+ return {
50
+ searchParams: args,
51
+ answer: results
52
+ };
53
+ }
54
+ });
55
+
56
+ export { parallelClient, searchTool };
57
+ //# sourceMappingURL=index.js.map
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts","../src/tools/search.ts"],"names":[],"mappings":";;;;;AAMA,IAAI,eAAA,GAAmC,IAAA;AAEhC,IAAM,cAAA,GAAiB,IAAI,KAAA,CAAM,EAAC,EAAe;AAAA,EACtD,GAAA,CAAI,SAAS,IAAA,EAAM;AACjB,IAAA,IAAI,CAAC,eAAA,EAAiB;AACpB,MAAA,eAAA,GAAkB,IAAI,QAAA,CAAS;AAAA,QAC7B,MAAA,EAAQ,OAAA,CAAQ,GAAA,CAAI,kBAAkB;AAAA,OACvC,CAAA;AAAA,IACH;AACA,IAAA,OAAQ,gBAAwB,IAAI,CAAA;AAAA,EACtC;AACF,CAAC;ACRD,IAAM,MAAA,GAAS,OACb,UAAA,EACA,EAAE,aAAY,KACX;AACH,EAAA,OAAO,MAAM,eAAe,IAAA,CAAK,MAAA;AAAA,IAC/B;AAAA,MACE,GAAG;AAAA,KACL;AAAA,IACA;AAAA,MACE,MAAA,EAAQ;AAAA;AACV,GACF;AACF,CAAA;AAEO,IAAM,aAAa,IAAA,CAAK;AAAA,EAC7B,WAAA,EACE,wJAAA;AAAA,EACF,UAAA,EAAY,EAAE,MAAA,CAAO;AAAA,IACnB,SAAA,EAAW,CAAA,CACR,MAAA,EAAO,CACP,QAAA;AAAA,MACC;AAAA,KACF;AAAA,IACF,cAAA,EAAgB,EACb,KAAA,CAAM,CAAA,CAAE,QAAQ,CAAA,CAChB,UAAS,CACT,QAAA;AAAA,MACC;AAAA,KACF;AAAA,IACF,SAAA,EAAW,EACR,IAAA,CAAK,CAAC,OAAO,MAAM,CAAC,CAAA,CACpB,QAAA,EAAS,CACT,QAAA;AAAA,MACC;AAAA,KACF;AAAA,IACF,WAAA,EAAa,CAAA,CACV,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,MACC;AAAA,KACF;AAAA,IACF,aAAA,EAAe,EACZ,MAAA,CAAO;AAAA,MACN,eAAA,EAAiB,CAAA,CACd,KAAA,CAAM,CAAA,CAAE,MAAA,EAAQ,CAAA,CAChB,QAAA,EAAS,CACT,QAAA,CAAS,uDAAuD,CAAA;AAAA,MACnE,eAAA,EAAiB,CAAA,CACd,KAAA,CAAM,CAAA,CAAE,MAAA,EAAQ,CAAA,CAChB,QAAA,EAAS,CACT,QAAA,CAAS,uDAAuD;AAAA,KACpE,CAAA,CACA,QAAA,EAAS,CACT,SAAS,mDAAmD;AAAA,GAChE,CAAA;AAAA,EAED,OAAA,EAAS,eAAgB,EAAE,GAAG,MAAK,EAAG,EAAE,aAAY,EAAG;AACrD,IAAA,MAAM,UAAU,MAAM,MAAA,CAAO,IAAA,EAAM,EAAE,aAAa,CAAA;AAElD,IAAA,OAAO;AAAA,MACL,YAAA,EAAc,IAAA;AAAA,MACd,MAAA,EAAQ;AAAA,KACV;AAAA,EACF;AACF,CAAC","file":"index.js","sourcesContent":["/**\n * Shared Parallel Web client instance\n */\n\nimport { Parallel } from 'parallel-web';\n\nlet _parallelClient: Parallel | null = null;\n\nexport const parallelClient = new Proxy({} as Parallel, {\n get(_target, prop) {\n if (!_parallelClient) {\n _parallelClient = new Parallel({\n apiKey: process.env['PARALLEL_API_KEY'],\n });\n }\n return (_parallelClient as any)[prop];\n },\n});\n","/**\n * Search tool for Parallel Web\n */\n\nimport { tool } from 'ai';\nimport { z } from 'zod';\nimport { BetaSearchParams } from 'parallel-web/resources/beta/beta.mjs';\nimport { parallelClient } from '../client.js';\n\nconst search = async (\n searchArgs: BetaSearchParams,\n { abortSignal }: { abortSignal: AbortSignal | undefined }\n) => {\n return await parallelClient.beta.search(\n {\n ...searchArgs,\n },\n {\n signal: abortSignal,\n }\n );\n};\n\nexport const searchTool = tool({\n description:\n 'Search Tool to quickly search in websites and published/public information on the internet like news, articles, blogs, posts, products, services, etc.',\n parameters: z.object({\n objective: z\n .string()\n .describe(\n 'Natural-language description of what the web search is trying to find. May include guidance about preferred sources or freshness. At least one of objective or search_queries must be provided.'\n ),\n search_queries: z\n .array(z.string())\n .optional()\n .describe(\n 'Optional list of traditional keyword search queries to guide the search. May contain search operators. At least one of objective or search_queries must be provided.'\n ),\n processor: z\n .enum(['pro', 'base'])\n .optional()\n .describe(\n 'The processor to use for the search. `pro` is recommended for complex queries, or incomplete objectives. `base` is recommended for simple queries.'\n ),\n max_results: z\n .number()\n .optional()\n .describe(\n 'The maximum number of results to return. Default is 10. Optional value, do not pass if not needed.'\n ),\n source_policy: z\n .object({\n include_domains: z\n .array(z.string())\n .optional()\n .describe('The sources to include in the search. Optional value.'),\n exclude_domains: z\n .array(z.string())\n .optional()\n .describe('The sources to exclude in the search. Optional value.'),\n })\n .optional()\n .describe('The policy to use for the search. Optional value.'),\n }),\n\n execute: async function ({ ...args }, { abortSignal }) {\n const results = await search(args, { abortSignal });\n\n return {\n searchParams: args,\n answer: results,\n };\n },\n});\n"]}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@parallel-web/ai-sdk-tools",
3
+ "version": "0.1.1-canary.023f473",
4
+ "description": "AI SDK tools for Parallel Web",
5
+ "author": "Parallel Web",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsup",
24
+ "dev": "tsup --watch",
25
+ "test": "vitest run",
26
+ "typecheck": "tsc --noEmit",
27
+ "clean": "rm -rf dist"
28
+ },
29
+ "keywords": [
30
+ "ai",
31
+ "sdk",
32
+ "tools",
33
+ "parallel"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/parallel-web/npm-packages",
38
+ "directory": "packages/ai-sdk-tools"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "dependencies": {
44
+ "ai": "^4.0.0",
45
+ "parallel-web": "^0.1.0",
46
+ "zod": "^3.23.0"
47
+ },
48
+ "devDependencies": {
49
+ "@types/node": "^20.0.0"
50
+ }
51
+ }