@xsai/generate-object 0.0.28 → 0.0.30

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/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ interface GenerateObjectOptions<T extends Schema> extends GenerateTextOptions {
6
6
  schemaDescription?: string;
7
7
  schemaName?: string;
8
8
  }
9
- interface GenerateObjectResult<T extends Schema> extends Omit<GenerateTextResult, 'text' | 'toolCalls' | 'toolResults'> {
9
+ interface GenerateObjectResult<T extends Schema> extends Omit<GenerateTextResult, 'text'> {
10
10
  object: Infer<T>;
11
11
  }
12
12
  /** @experimental WIP */
package/dist/index.js CHANGED
@@ -1,31 +1,30 @@
1
1
  import { toJSONSchema, validate } from '@typeschema/main';
2
2
  import { generateText } from '@xsai/generate-text';
3
- import { clean } from '@xsai/shared';
4
3
 
5
- const generateObject = async (options) => await generateText({
4
+ const generateObject = async (options) => generateText({
6
5
  ...options,
7
6
  response_format: {
8
7
  json_schema: {
9
8
  description: options.schemaDescription,
10
9
  name: options.schemaName ?? "json_schema",
11
- schema: await toJSONSchema(options.schema).then((json) => clean({
12
- ...json,
13
- $schema: void 0
14
- })),
10
+ schema: await toJSONSchema(options.schema),
15
11
  strict: true
16
12
  },
17
13
  type: "json_schema"
18
14
  },
19
- schema: void 0,
20
- schemaDescription: void 0,
21
- schemaName: void 0
22
- }).then(async ({ finishReason, steps, text, usage }) => {
15
+ schema: undefined,
16
+ schemaDescription: undefined,
17
+ schemaName: undefined
18
+ }).then(async ({ finishReason, messages, steps, text, toolCalls, toolResults, usage }) => {
23
19
  const result = await validate(options.schema, JSON.parse(text));
24
20
  if (result.success) {
25
21
  return {
26
22
  finishReason,
23
+ messages,
27
24
  object: result.data,
28
25
  steps,
26
+ toolCalls,
27
+ toolResults,
29
28
  usage
30
29
  };
31
30
  } else {
package/package.json CHANGED
@@ -1,38 +1,37 @@
1
1
  {
2
2
  "name": "@xsai/generate-object",
3
- "version": "0.0.28",
4
3
  "type": "module",
4
+ "version": "0.0.30",
5
+ "description": "extra-small AI SDK for Browser, Node.js, Deno, Bun or Edge Runtime.",
5
6
  "author": "Moeru AI",
6
7
  "license": "MIT",
7
8
  "homepage": "https://xsai.js.org",
8
- "description": "extra-small AI SDK for Browser, Node.js, Deno, Bun or Edge Runtime.",
9
- "keywords": [
10
- "xsai",
11
- "openai",
12
- "ai"
13
- ],
14
9
  "repository": {
15
10
  "type": "git",
16
11
  "url": "git+https://github.com/moeru-ai/xsai.git",
17
12
  "directory": "packages/generate-object"
18
13
  },
19
14
  "bugs": "https://github.com/moeru-ai/xsai/issues",
15
+ "keywords": [
16
+ "xsai",
17
+ "openai",
18
+ "ai"
19
+ ],
20
20
  "sideEffects": false,
21
- "main": "./dist/index.js",
22
- "types": "./dist/index.d.ts",
23
21
  "exports": {
24
22
  ".": {
25
23
  "types": "./dist/index.d.ts",
26
24
  "default": "./dist/index.js"
27
25
  }
28
26
  },
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
29
  "files": [
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
33
  "@typeschema/main": "^0.14.1",
34
- "@xsai/generate-text": "",
35
- "@xsai/shared": ""
34
+ "@xsai/generate-text": ""
36
35
  },
37
36
  "devDependencies": {
38
37
  "@gcornut/valibot-json-schema": "^0.42.0",