modelfusion 0.84.0 → 0.85.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
@@ -345,14 +345,12 @@ const result = await guard(
345
345
  fixStructure({
346
346
  modifyInputForRetry: async ({ input, error }) => [
347
347
  ...input,
348
- {
349
- role: "assistant",
350
- content: null,
351
- function_call: {
348
+ OpenAIChatMessage.assistant(null, {
349
+ functionCall: {
352
350
  name: "sentiment",
353
351
  arguments: JSON.stringify(error.valueText),
354
352
  },
355
- } satisfies OpenAIChatMessage,
353
+ }),
356
354
  OpenAIChatMessage.user(error.message),
357
355
  OpenAIChatMessage.user("Please fix the error and try again."),
358
356
  ],
@@ -736,9 +734,11 @@ invokeFlow({
736
734
  - [Troubleshooting](https://modelfusion.dev/guide/troubleshooting)
737
735
  - [Bundling](https://modelfusion.dev/guide/troubleshooting/bundling)
738
736
 
737
+ ### [Integrations](https://modelfusion.dev/integration/model-provider)
738
+
739
739
  ### [Examples & Tutorials](https://modelfusion.dev/tutorial)
740
740
 
741
- ### [Integrations](https://modelfusion.dev/integration/model-provider)
741
+ ### [Showcase](https://modelfusion.dev/showcase)
742
742
 
743
743
  ### [API Reference](https://modelfusion.dev/api/modules)
744
744
 
@@ -45,14 +45,12 @@ const StructureValidationError_js_1 = require("../model-function/generate-struct
45
45
  * fixStructure({
46
46
  * modifyInputForRetry: async ({ input, error }) => [
47
47
  * ...input,
48
- * {
49
- * role: "assistant",
50
- * content: null,
51
- function_call: {
48
+ * OpenAIChatMessage.assistant(null, {
49
+ * functionCall: {
52
50
  * name: "sentiment",
53
51
  * arguments: JSON.stringify(error.valueText),
54
52
  * },
55
- * } satisfies OpenAIChatMessage,
53
+ * }),
56
54
  * OpenAIChatMessage.user(error.message),
57
55
  * OpenAIChatMessage.user("Please fix the error and try again."),
58
56
  * ],
@@ -43,14 +43,12 @@ import { Guard } from "./guard.js";
43
43
  * fixStructure({
44
44
  * modifyInputForRetry: async ({ input, error }) => [
45
45
  * ...input,
46
- * {
47
- * role: "assistant",
48
- * content: null,
49
- function_call: {
46
+ * OpenAIChatMessage.assistant(null, {
47
+ * functionCall: {
50
48
  * name: "sentiment",
51
49
  * arguments: JSON.stringify(error.valueText),
52
50
  * },
53
- * } satisfies OpenAIChatMessage,
51
+ * }),
54
52
  * OpenAIChatMessage.user(error.message),
55
53
  * OpenAIChatMessage.user("Please fix the error and try again."),
56
54
  * ],
@@ -42,14 +42,12 @@ import { StructureValidationError } from "../model-function/generate-structure/S
42
42
  * fixStructure({
43
43
  * modifyInputForRetry: async ({ input, error }) => [
44
44
  * ...input,
45
- * {
46
- * role: "assistant",
47
- * content: null,
48
- function_call: {
45
+ * OpenAIChatMessage.assistant(null, {
46
+ * functionCall: {
49
47
  * name: "sentiment",
50
48
  * arguments: JSON.stringify(error.valueText),
51
49
  * },
52
- * } satisfies OpenAIChatMessage,
50
+ * }),
53
51
  * OpenAIChatMessage.user(error.message),
54
52
  * OpenAIChatMessage.user("Please fix the error and try again."),
55
53
  * ],
@@ -93,7 +93,7 @@ export declare abstract class AbstractOpenAIChatModel<SETTINGS extends AbstractO
93
93
  };
94
94
  index: number;
95
95
  logprobs?: any;
96
- finish_reason?: "length" | "stop" | "tool_calls" | "function_call" | "content_filter" | null | undefined;
96
+ finish_reason?: "length" | "stop" | "function_call" | "tool_calls" | "content_filter" | null | undefined;
97
97
  }[];
98
98
  created: number;
99
99
  system_fingerprint?: string | undefined;
@@ -135,7 +135,7 @@ export declare abstract class AbstractOpenAIChatModel<SETTINGS extends AbstractO
135
135
  };
136
136
  index: number;
137
137
  logprobs?: any;
138
- finish_reason?: "length" | "stop" | "tool_calls" | "function_call" | "content_filter" | null | undefined;
138
+ finish_reason?: "length" | "stop" | "function_call" | "tool_calls" | "content_filter" | null | undefined;
139
139
  }[];
140
140
  created: number;
141
141
  system_fingerprint?: string | undefined;
@@ -179,7 +179,7 @@ export declare abstract class AbstractOpenAIChatModel<SETTINGS extends AbstractO
179
179
  };
180
180
  index: number;
181
181
  logprobs?: any;
182
- finish_reason?: "length" | "stop" | "tool_calls" | "function_call" | "content_filter" | null | undefined;
182
+ finish_reason?: "length" | "stop" | "function_call" | "tool_calls" | "content_filter" | null | undefined;
183
183
  }[];
184
184
  created: number;
185
185
  system_fingerprint?: string | undefined;
@@ -299,7 +299,7 @@ declare const openAIChatResponseSchema: z.ZodObject<{
299
299
  };
300
300
  index: number;
301
301
  logprobs?: any;
302
- finish_reason?: "length" | "stop" | "tool_calls" | "function_call" | "content_filter" | null | undefined;
302
+ finish_reason?: "length" | "stop" | "function_call" | "tool_calls" | "content_filter" | null | undefined;
303
303
  }, {
304
304
  message: {
305
305
  role: "assistant";
@@ -319,7 +319,7 @@ declare const openAIChatResponseSchema: z.ZodObject<{
319
319
  };
320
320
  index: number;
321
321
  logprobs?: any;
322
- finish_reason?: "length" | "stop" | "tool_calls" | "function_call" | "content_filter" | null | undefined;
322
+ finish_reason?: "length" | "stop" | "function_call" | "tool_calls" | "content_filter" | null | undefined;
323
323
  }>, "many">;
324
324
  created: z.ZodNumber;
325
325
  model: z.ZodString;
@@ -366,7 +366,7 @@ declare const openAIChatResponseSchema: z.ZodObject<{
366
366
  };
367
367
  index: number;
368
368
  logprobs?: any;
369
- finish_reason?: "length" | "stop" | "tool_calls" | "function_call" | "content_filter" | null | undefined;
369
+ finish_reason?: "length" | "stop" | "function_call" | "tool_calls" | "content_filter" | null | undefined;
370
370
  }[];
371
371
  created: number;
372
372
  system_fingerprint?: string | undefined;
@@ -398,7 +398,7 @@ declare const openAIChatResponseSchema: z.ZodObject<{
398
398
  };
399
399
  index: number;
400
400
  logprobs?: any;
401
- finish_reason?: "length" | "stop" | "tool_calls" | "function_call" | "content_filter" | null | undefined;
401
+ finish_reason?: "length" | "stop" | "function_call" | "tool_calls" | "content_filter" | null | undefined;
402
402
  }[];
403
403
  created: number;
404
404
  system_fingerprint?: string | undefined;
@@ -442,7 +442,7 @@ export declare const OpenAIChatResponseFormat: {
442
442
  };
443
443
  index: number;
444
444
  logprobs?: any;
445
- finish_reason?: "length" | "stop" | "tool_calls" | "function_call" | "content_filter" | null | undefined;
445
+ finish_reason?: "length" | "stop" | "function_call" | "tool_calls" | "content_filter" | null | undefined;
446
446
  }[];
447
447
  created: number;
448
448
  system_fingerprint?: string | undefined;
@@ -71,7 +71,7 @@ OpenAIChatSettings> {
71
71
  };
72
72
  index: number;
73
73
  logprobs?: any;
74
- finish_reason?: "length" | "stop" | "tool_calls" | "function_call" | "content_filter" | null | undefined;
74
+ finish_reason?: "length" | "stop" | "function_call" | "tool_calls" | "content_filter" | null | undefined;
75
75
  }[];
76
76
  created: number;
77
77
  system_fingerprint?: string | undefined;
@@ -2,9 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpenAIChatMessage = void 0;
4
4
  exports.OpenAIChatMessage = {
5
+ /**
6
+ * Creates a system chat message.
7
+ */
5
8
  system(content) {
6
9
  return { role: "system", content };
7
10
  },
11
+ /**
12
+ * Creates a user chat message. The message can be a string or a multi-modal input.
13
+ */
8
14
  user(content, options) {
9
15
  return {
10
16
  role: "user",
@@ -27,12 +33,20 @@ exports.OpenAIChatMessage = {
27
33
  };
28
34
  },
29
35
  /**
30
- * Creates an assistant chat message. The assistant message can optionally contain tool calls.
36
+ * Creates an assistant chat message.
37
+ * The assistant message can optionally contain tool calls
38
+ * or a function call (function calls are deprecated).
31
39
  */
32
40
  assistant(content, options) {
33
41
  return {
34
42
  role: "assistant",
35
43
  content,
44
+ function_call: options?.functionCall == null
45
+ ? undefined
46
+ : {
47
+ name: options.functionCall.name,
48
+ arguments: options.functionCall.arguments,
49
+ },
36
50
  tool_calls: options?.toolCalls?.map((toolCall) => ({
37
51
  id: toolCall.id,
38
52
  type: "function",
@@ -43,6 +57,14 @@ exports.OpenAIChatMessage = {
43
57
  })) ?? undefined,
44
58
  };
45
59
  },
60
+ /**
61
+ * Creates a function result chat message for tool call results.
62
+ *
63
+ * @deprecated OpenAI functions are deprecated in favor of tools.
64
+ */
65
+ fn({ fnName, content, }) {
66
+ return { role: "function", name: fnName, content: JSON.stringify(content) };
67
+ },
46
68
  /**
47
69
  * Creates a tool result chat message with the result of a tool call.
48
70
  */
@@ -43,15 +43,36 @@ export type OpenAIChatMessage = {
43
43
  name: string;
44
44
  };
45
45
  export declare const OpenAIChatMessage: {
46
+ /**
47
+ * Creates a system chat message.
48
+ */
46
49
  system(content: string): OpenAIChatMessage;
50
+ /**
51
+ * Creates a user chat message. The message can be a string or a multi-modal input.
52
+ */
47
53
  user(content: string | MultiModalInput, options?: {
48
54
  name?: string;
49
55
  }): OpenAIChatMessage;
50
56
  /**
51
- * Creates an assistant chat message. The assistant message can optionally contain tool calls.
57
+ * Creates an assistant chat message.
58
+ * The assistant message can optionally contain tool calls
59
+ * or a function call (function calls are deprecated).
52
60
  */
53
61
  assistant(content: string | null, options?: {
54
- toolCalls: Array<ToolCall<string, unknown>> | null | undefined;
62
+ functionCall?: {
63
+ name: string;
64
+ arguments: string;
65
+ } | undefined;
66
+ toolCalls?: Array<ToolCall<string, unknown>> | null | undefined;
67
+ } | undefined): OpenAIChatMessage;
68
+ /**
69
+ * Creates a function result chat message for tool call results.
70
+ *
71
+ * @deprecated OpenAI functions are deprecated in favor of tools.
72
+ */
73
+ fn({ fnName, content, }: {
74
+ fnName: string;
75
+ content: unknown;
55
76
  }): OpenAIChatMessage;
56
77
  /**
57
78
  * Creates a tool result chat message with the result of a tool call.
@@ -1,7 +1,13 @@
1
1
  export const OpenAIChatMessage = {
2
+ /**
3
+ * Creates a system chat message.
4
+ */
2
5
  system(content) {
3
6
  return { role: "system", content };
4
7
  },
8
+ /**
9
+ * Creates a user chat message. The message can be a string or a multi-modal input.
10
+ */
5
11
  user(content, options) {
6
12
  return {
7
13
  role: "user",
@@ -24,12 +30,20 @@ export const OpenAIChatMessage = {
24
30
  };
25
31
  },
26
32
  /**
27
- * Creates an assistant chat message. The assistant message can optionally contain tool calls.
33
+ * Creates an assistant chat message.
34
+ * The assistant message can optionally contain tool calls
35
+ * or a function call (function calls are deprecated).
28
36
  */
29
37
  assistant(content, options) {
30
38
  return {
31
39
  role: "assistant",
32
40
  content,
41
+ function_call: options?.functionCall == null
42
+ ? undefined
43
+ : {
44
+ name: options.functionCall.name,
45
+ arguments: options.functionCall.arguments,
46
+ },
33
47
  tool_calls: options?.toolCalls?.map((toolCall) => ({
34
48
  id: toolCall.id,
35
49
  type: "function",
@@ -40,6 +54,14 @@ export const OpenAIChatMessage = {
40
54
  })) ?? undefined,
41
55
  };
42
56
  },
57
+ /**
58
+ * Creates a function result chat message for tool call results.
59
+ *
60
+ * @deprecated OpenAI functions are deprecated in favor of tools.
61
+ */
62
+ fn({ fnName, content, }) {
63
+ return { role: "function", name: fnName, content: JSON.stringify(content) };
64
+ },
43
65
  /**
44
66
  * Creates a tool result chat message with the result of a tool call.
45
67
  */
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.84.0",
4
+ "version": "0.85.0",
5
5
  "author": "Lars Grammel",
6
6
  "license": "MIT",
7
7
  "keywords": [