modelfusion 0.81.0 → 0.82.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
@@ -193,7 +193,7 @@ Generate typed objects using a language model and a schema.
193
193
  Generate a structure that matches a schema.
194
194
 
195
195
  ```ts
196
- import { ZodSchema, generateStructure, openai } from "modelfusion";
196
+ import { zodSchema, generateStructure, openai } from "modelfusion";
197
197
 
198
198
  const sentiment = await generateStructure(
199
199
  openai
@@ -205,7 +205,7 @@ const sentiment = await generateStructure(
205
205
  .asFunctionCallStructureGenerationModel({ fnName: "sentiment" })
206
206
  .withInstructionPrompt(),
207
207
 
208
- new ZodSchema(
208
+ zodSchema(
209
209
  z.object({
210
210
  sentiment: z
211
211
  .enum(["positive", "neutral", "negative"])
@@ -231,7 +231,7 @@ Providers: [OpenAI](https://modelfusion.dev/integration/model-provider/openai)
231
231
  Stream a structure that matches a schema. Partial structures before the final part are untyped JSON.
232
232
 
233
233
  ```ts
234
- import { ZodSchema, openai, streamStructure } from "modelfusion";
234
+ import { zodSchema, openai, streamStructure } from "modelfusion";
235
235
 
236
236
  const structureStream = await streamStructure(
237
237
  openai
@@ -242,7 +242,7 @@ const structureStream = await streamStructure(
242
242
  })
243
243
  .withTextPrompt(),
244
244
 
245
- new ZodSchema(
245
+ zodSchema(
246
246
  z.object({
247
247
  characters: z.array(
248
248
  z.object({
@@ -330,7 +330,7 @@ const result = await guard(
330
330
  .asFunctionCallStructureGenerationModel({
331
331
  fnName: "myFunction",
332
332
  }),
333
- new ZodSchema({
333
+ zodSchema({
334
334
  // ...
335
335
  }),
336
336
  input,
@@ -372,7 +372,7 @@ const calculator = new Tool({
372
372
  name: "calculator",
373
373
  description: "Execute a calculation",
374
374
 
375
- parameters: new ZodSchema(
375
+ parameters: zodSchema(
376
376
  z.object({
377
377
  a: z.number().describe("The first number."),
378
378
  b: z.number().describe("The second number."),
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZodSchema = void 0;
3
+ exports.ZodSchema = exports.zodSchema = void 0;
4
4
  const zod_to_json_schema_1 = require("zod-to-json-schema");
5
+ function zodSchema(zodSchema) {
6
+ return new ZodSchema(zodSchema);
7
+ }
8
+ exports.zodSchema = zodSchema;
5
9
  class ZodSchema {
6
10
  constructor(zodSchema) {
7
11
  Object.defineProperty(this, "zodSchema", {
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { JsonSchemaProducer } from "./JsonSchemaProducer.js";
3
3
  import { Schema } from "./Schema.js";
4
+ export declare function zodSchema<STRUCTURE>(zodSchema: z.Schema<STRUCTURE>): ZodSchema<STRUCTURE>;
4
5
  export declare class ZodSchema<STRUCTURE> implements Schema<STRUCTURE>, JsonSchemaProducer {
5
6
  readonly zodSchema: z.Schema<STRUCTURE>;
6
7
  constructor(zodSchema: z.Schema<STRUCTURE>);
@@ -1,4 +1,7 @@
1
1
  import { zodToJsonSchema } from "zod-to-json-schema";
2
+ export function zodSchema(zodSchema) {
3
+ return new ZodSchema(zodSchema);
4
+ }
2
5
  export class ZodSchema {
3
6
  constructor(zodSchema) {
4
7
  Object.defineProperty(this, "zodSchema", {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modelfusion",
3
3
  "description": "The TypeScript library for building multi-modal AI applications.",
4
- "version": "0.81.0",
4
+ "version": "0.82.0",
5
5
  "author": "Lars Grammel",
6
6
  "license": "MIT",
7
7
  "keywords": [