modelfusion 0.10.0 → 0.11.0

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 CHANGED
@@ -451,6 +451,12 @@ Record audio with push-to-talk and transcribe it using Whisper, implemented as a
451
451
 
452
452
  TypeScript implementation of the BabyAGI classic and BabyBeeAGI.
453
453
 
454
+ ### [Wikipedia Agent](https://github.com/lgrammel/modelfusion/tree/main/examples/wikipedia-agent)
455
+
456
+ > _terminal app_, _ReAct agent_, _GPT-4_, _OpenAI functions_, _tools_
457
+
458
+ Get answers to questions from Wikipedia, e.g. "Who was born first, Einstein or Picasso?"
459
+
454
460
  ### [Middle school math agent](https://github.com/lgrammel/modelfusion/tree/main/examples/middle-school-math-agent)
455
461
 
456
462
  > _terminal app_, _agent_, _tools_, _GPT-4_
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modelfusion",
3
3
  "description": "Build AI applications, chatbots, and agents with JavaScript and TypeScript.",
4
- "version": "0.10.0",
4
+ "version": "0.11.0",
5
5
  "author": "Lars Grammel",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -67,7 +67,7 @@
67
67
  "eslint": "^8.45.0",
68
68
  "eslint-config-prettier": "9.0.0",
69
69
  "husky": "^8.0.3",
70
- "lint-staged": "13.2.3",
70
+ "lint-staged": "14.0.0",
71
71
  "prettier": "3.0.1",
72
72
  "rimraf": "5.0.1",
73
73
  "typescript": "5.1.6",
@@ -13,31 +13,39 @@ const OUTPUT_SCHEMA = zod_1.z.object({
13
13
  snippet: zod_1.z.string(),
14
14
  })),
15
15
  });
16
- /**
17
- * @see https://serpapi.com/search-api
18
- */
19
16
  class WebSearchTool extends Tool_js_1.Tool {
20
- constructor(options) {
17
+ constructor({ name, description, queryDescription = "Search query", execute, }) {
21
18
  super({
22
- name: options.name,
23
- description: options.description,
24
- inputSchema: INPUT_SCHEMA,
19
+ name,
20
+ description,
21
+ inputSchema: WebSearchTool.createInputSchema(queryDescription),
25
22
  outputSchema: OUTPUT_SCHEMA,
26
- execute: options.execute,
23
+ execute,
27
24
  });
25
+ Object.defineProperty(this, "outputSchema", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: void 0
30
+ });
31
+ this.outputSchema = OUTPUT_SCHEMA;
28
32
  }
29
33
  }
30
34
  exports.WebSearchTool = WebSearchTool;
31
35
  // expose the schemas to library consumers:
32
- Object.defineProperty(WebSearchTool, "INPUT_SCHEMA", {
36
+ Object.defineProperty(WebSearchTool, "createInputSchema", {
33
37
  enumerable: true,
34
38
  configurable: true,
35
39
  writable: true,
36
- value: INPUT_SCHEMA
40
+ value: (description) =>
41
+ // same structure, but with description:
42
+ zod_1.z.object({
43
+ query: zod_1.z.string().describe(description),
44
+ })
37
45
  });
38
- Object.defineProperty(WebSearchTool, "OUTPUT_SCHEMA", {
46
+ Object.defineProperty(WebSearchTool, "createOutputSchema", {
39
47
  enumerable: true,
40
48
  configurable: true,
41
49
  writable: true,
42
- value: OUTPUT_SCHEMA
50
+ value: () => OUTPUT_SCHEMA
43
51
  });
@@ -34,18 +34,15 @@ declare const OUTPUT_SCHEMA: z.ZodObject<{
34
34
  snippet: string;
35
35
  }[];
36
36
  }>;
37
- /**
38
- * @see https://serpapi.com/search-api
39
- */
40
37
  export declare class WebSearchTool<NAME extends string> extends Tool<NAME, z.infer<typeof INPUT_SCHEMA>, z.infer<typeof OUTPUT_SCHEMA>> {
41
- static readonly INPUT_SCHEMA: z.ZodObject<{
38
+ static readonly createInputSchema: (description: string) => z.ZodObject<{
42
39
  query: z.ZodString;
43
40
  }, "strip", z.ZodTypeAny, {
44
41
  query: string;
45
42
  }, {
46
43
  query: string;
47
44
  }>;
48
- static readonly OUTPUT_SCHEMA: z.ZodObject<{
45
+ static readonly createOutputSchema: () => z.ZodObject<{
49
46
  results: z.ZodArray<z.ZodObject<{
50
47
  title: z.ZodString;
51
48
  link: z.ZodString;
@@ -72,9 +69,11 @@ export declare class WebSearchTool<NAME extends string> extends Tool<NAME, z.inf
72
69
  snippet: string;
73
70
  }[];
74
71
  }>;
75
- constructor(options: {
72
+ readonly outputSchema: typeof OUTPUT_SCHEMA;
73
+ constructor({ name, description, queryDescription, execute, }: {
76
74
  name: NAME;
77
75
  description: string;
76
+ queryDescription?: string;
78
77
  execute(input: z.infer<typeof INPUT_SCHEMA>): Promise<z.infer<typeof OUTPUT_SCHEMA>>;
79
78
  });
80
79
  }
@@ -10,30 +10,38 @@ const OUTPUT_SCHEMA = z.object({
10
10
  snippet: z.string(),
11
11
  })),
12
12
  });
13
- /**
14
- * @see https://serpapi.com/search-api
15
- */
16
13
  export class WebSearchTool extends Tool {
17
- constructor(options) {
14
+ constructor({ name, description, queryDescription = "Search query", execute, }) {
18
15
  super({
19
- name: options.name,
20
- description: options.description,
21
- inputSchema: INPUT_SCHEMA,
16
+ name,
17
+ description,
18
+ inputSchema: WebSearchTool.createInputSchema(queryDescription),
22
19
  outputSchema: OUTPUT_SCHEMA,
23
- execute: options.execute,
20
+ execute,
24
21
  });
22
+ Object.defineProperty(this, "outputSchema", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: void 0
27
+ });
28
+ this.outputSchema = OUTPUT_SCHEMA;
25
29
  }
26
30
  }
27
31
  // expose the schemas to library consumers:
28
- Object.defineProperty(WebSearchTool, "INPUT_SCHEMA", {
32
+ Object.defineProperty(WebSearchTool, "createInputSchema", {
29
33
  enumerable: true,
30
34
  configurable: true,
31
35
  writable: true,
32
- value: INPUT_SCHEMA
36
+ value: (description) =>
37
+ // same structure, but with description:
38
+ z.object({
39
+ query: z.string().describe(description),
40
+ })
33
41
  });
34
- Object.defineProperty(WebSearchTool, "OUTPUT_SCHEMA", {
42
+ Object.defineProperty(WebSearchTool, "createOutputSchema", {
35
43
  enumerable: true,
36
44
  configurable: true,
37
45
  writable: true,
38
- value: OUTPUT_SCHEMA
46
+ value: () => OUTPUT_SCHEMA
39
47
  });