modelfusion 0.49.0 → 0.51.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.
Files changed (86) hide show
  1. package/README.md +176 -158
  2. package/core/FunctionEvent.d.ts +9 -1
  3. package/core/FunctionOptions.d.ts +4 -0
  4. package/core/executeFunctionCall.cjs +85 -0
  5. package/core/executeFunctionCall.d.ts +10 -0
  6. package/core/executeFunctionCall.js +81 -0
  7. package/guard/GuardEvent.cjs +2 -0
  8. package/guard/GuardEvent.d.ts +7 -0
  9. package/guard/GuardEvent.js +1 -0
  10. package/guard/guard.cjs +60 -54
  11. package/guard/guard.d.ts +2 -1
  12. package/guard/guard.js +60 -54
  13. package/guard/index.cjs +1 -0
  14. package/guard/index.d.ts +1 -0
  15. package/guard/index.js +1 -0
  16. package/model-function/embed/EmbeddingEvent.d.ts +2 -2
  17. package/model-function/embed/embed.cjs +2 -2
  18. package/model-function/embed/embed.js +2 -2
  19. package/model-function/executeStandardCall.cjs +2 -0
  20. package/model-function/executeStandardCall.js +2 -0
  21. package/model-function/executeStreamCall.cjs +2 -0
  22. package/model-function/executeStreamCall.js +2 -0
  23. package/model-function/generate-image/ImageGenerationEvent.d.ts +2 -2
  24. package/model-function/generate-image/generateImage.cjs +1 -1
  25. package/model-function/generate-image/generateImage.js +1 -1
  26. package/model-function/generate-speech/SpeechGenerationEvent.d.ts +4 -4
  27. package/model-function/generate-speech/generateSpeech.cjs +1 -1
  28. package/model-function/generate-speech/generateSpeech.js +1 -1
  29. package/model-function/generate-speech/streamSpeech.cjs +1 -1
  30. package/model-function/generate-speech/streamSpeech.js +1 -1
  31. package/model-function/generate-structure/StructureGenerationEvent.d.ts +2 -2
  32. package/model-function/generate-structure/StructureStreamingEvent.d.ts +2 -2
  33. package/model-function/generate-structure/generateStructure.cjs +1 -1
  34. package/model-function/generate-structure/generateStructure.js +1 -1
  35. package/model-function/generate-structure/generateStructureOrText.cjs +1 -1
  36. package/model-function/generate-structure/generateStructureOrText.js +1 -1
  37. package/model-function/generate-structure/streamStructure.cjs +1 -1
  38. package/model-function/generate-structure/streamStructure.js +1 -1
  39. package/model-function/generate-text/TextGenerationEvent.d.ts +4 -4
  40. package/model-function/generate-text/generateText.cjs +1 -1
  41. package/model-function/generate-text/generateText.js +1 -1
  42. package/model-function/generate-text/streamText.cjs +1 -1
  43. package/model-function/generate-text/streamText.js +1 -1
  44. package/model-function/generate-transcription/TranscriptionEvent.d.ts +2 -2
  45. package/model-function/generate-transcription/generateTranscription.cjs +1 -1
  46. package/model-function/generate-transcription/generateTranscription.js +1 -1
  47. package/model-provider/elevenlabs/ElevenLabsError.cjs +0 -1
  48. package/model-provider/elevenlabs/ElevenLabsError.js +0 -1
  49. package/model-provider/elevenlabs/ElevenLabsSpeechModel.cjs +33 -5
  50. package/model-provider/elevenlabs/ElevenLabsSpeechModel.d.ts +6 -1
  51. package/model-provider/elevenlabs/ElevenLabsSpeechModel.js +33 -5
  52. package/model-provider/lmnt/LmntError.cjs +0 -1
  53. package/model-provider/lmnt/LmntError.js +0 -1
  54. package/model-provider/openai/OpenAICompletionModel.d.ts +4 -4
  55. package/model-provider/openai/OpenAICostCalculator.cjs +5 -5
  56. package/model-provider/openai/OpenAICostCalculator.js +5 -5
  57. package/model-provider/openai/OpenAITextEmbeddingModel.d.ts +3 -3
  58. package/model-provider/openai/chat/OpenAIChatModel.d.ts +7 -7
  59. package/package.json +1 -1
  60. package/retriever/retrieve.cjs +7 -75
  61. package/retriever/retrieve.js +7 -75
  62. package/tool/UseToolEvent.cjs +2 -0
  63. package/tool/UseToolEvent.d.ts +7 -0
  64. package/tool/UseToolEvent.js +1 -0
  65. package/tool/UseToolOrGenerateTextEvent.cjs +2 -0
  66. package/tool/UseToolOrGenerateTextEvent.d.ts +7 -0
  67. package/tool/UseToolOrGenerateTextEvent.js +1 -0
  68. package/tool/executeTool.cjs +2 -0
  69. package/tool/executeTool.js +2 -0
  70. package/tool/index.cjs +2 -0
  71. package/tool/index.d.ts +2 -0
  72. package/tool/index.js +2 -0
  73. package/tool/useTool.cjs +18 -10
  74. package/tool/useTool.js +18 -10
  75. package/tool/useToolOrGenerateText.cjs +34 -26
  76. package/tool/useToolOrGenerateText.js +34 -26
  77. package/vector-index/UpsertIntoVectorIndexEvent.cjs +2 -0
  78. package/vector-index/UpsertIntoVectorIndexEvent.d.ts +9 -0
  79. package/vector-index/UpsertIntoVectorIndexEvent.js +1 -0
  80. package/vector-index/VectorIndexRetriever.cjs +1 -4
  81. package/vector-index/VectorIndexRetriever.js +1 -4
  82. package/vector-index/index.cjs +1 -0
  83. package/vector-index/index.d.ts +1 -0
  84. package/vector-index/index.js +1 -0
  85. package/vector-index/upsertIntoVectorIndex.cjs +16 -7
  86. package/vector-index/upsertIntoVectorIndex.js +16 -7
package/guard/guard.cjs CHANGED
@@ -1,72 +1,78 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.guard = void 0;
4
+ const executeFunctionCall_js_1 = require("../core/executeFunctionCall.cjs");
4
5
  async function guard(execute, input, guards, options) {
5
- if (typeof guards === "function") {
6
- guards = [guards];
7
- }
6
+ const guardList = Array.isArray(guards) ? guards : [guards];
8
7
  const maxRetries = options?.maxRetries ?? 1;
9
- let attempts = 0;
10
- while (attempts <= maxRetries) {
11
- let result;
12
- try {
13
- result = {
14
- type: "value",
15
- input,
16
- output: await execute(input),
17
- };
18
- }
19
- catch (error) {
20
- result = {
21
- type: "error",
22
- input,
23
- error,
24
- };
25
- }
26
- let isValid = true;
27
- for (const guard of guards) {
28
- const guardResult = await guard(result);
29
- if (guardResult === undefined) {
30
- continue;
31
- }
32
- switch (guardResult.action) {
33
- case "passThrough": {
34
- break;
35
- }
36
- case "retry": {
37
- input = guardResult.input;
38
- isValid = false;
39
- break;
40
- }
41
- case "return": {
8
+ return (0, executeFunctionCall_js_1.executeFunctionCall)({
9
+ options,
10
+ input,
11
+ functionType: "guard",
12
+ execute: async (options) => {
13
+ let attempts = 0;
14
+ while (attempts <= maxRetries) {
15
+ let result;
16
+ try {
42
17
  result = {
43
18
  type: "value",
44
19
  input,
45
- output: guardResult.output,
20
+ output: await execute(input, options),
46
21
  };
47
- break;
48
22
  }
49
- case "throwError": {
23
+ catch (error) {
50
24
  result = {
51
25
  type: "error",
52
26
  input,
53
- error: guardResult.error,
27
+ error,
54
28
  };
55
- break;
56
29
  }
30
+ let isValid = true;
31
+ for (const guard of guardList) {
32
+ const guardResult = await guard(result);
33
+ if (guardResult === undefined) {
34
+ continue;
35
+ }
36
+ switch (guardResult.action) {
37
+ case "passThrough": {
38
+ break;
39
+ }
40
+ case "retry": {
41
+ input = guardResult.input;
42
+ isValid = false;
43
+ break;
44
+ }
45
+ case "return": {
46
+ result = {
47
+ type: "value",
48
+ input,
49
+ output: guardResult.output,
50
+ };
51
+ break;
52
+ }
53
+ case "throwError": {
54
+ result = {
55
+ type: "error",
56
+ input,
57
+ error: guardResult.error,
58
+ };
59
+ break;
60
+ }
61
+ }
62
+ }
63
+ if (isValid) {
64
+ if (result.type === "value") {
65
+ return result.output;
66
+ }
67
+ else {
68
+ throw result.error;
69
+ }
70
+ }
71
+ attempts++;
57
72
  }
58
- }
59
- if (isValid) {
60
- if (result.type === "value") {
61
- return result.output;
62
- }
63
- else {
64
- throw result.error;
65
- }
66
- }
67
- attempts++;
68
- }
69
- throw new Error(`Maximum retry attempts of ${maxRetries} reached ` +
70
- `without producing a valid output or handling an error after ${attempts} attempts.`);
73
+ throw new Error(`Maximum retry attempts of ${maxRetries} reached ` +
74
+ `without producing a valid output or handling an error after ${attempts} attempts.`);
75
+ },
76
+ });
71
77
  }
72
78
  exports.guard = guard;
package/guard/guard.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { FunctionOptions } from "../core/FunctionOptions.js";
1
2
  type OutputResult<INPUT, OUTPUT> = {
2
3
  type: "value";
3
4
  input: INPUT;
@@ -22,7 +23,7 @@ export type Guard<INPUT, OUTPUT> = ({ type, input, output, error, }: OutputResul
22
23
  } | {
23
24
  action: "passThrough";
24
25
  } | undefined>;
25
- export declare function guard<INPUT, OUTPUT>(execute: (input: INPUT) => PromiseLike<OUTPUT>, input: INPUT, guards: Guard<INPUT, OUTPUT> | Array<Guard<INPUT, OUTPUT>>, options?: {
26
+ export declare function guard<INPUT, OUTPUT>(execute: (input: INPUT, options?: FunctionOptions) => PromiseLike<OUTPUT>, input: INPUT, guards: Guard<INPUT, OUTPUT> | Array<Guard<INPUT, OUTPUT>>, options?: FunctionOptions & {
26
27
  maxRetries: number;
27
28
  }): Promise<OUTPUT | undefined>;
28
29
  export {};
package/guard/guard.js CHANGED
@@ -1,68 +1,74 @@
1
+ import { executeFunctionCall } from "../core/executeFunctionCall.js";
1
2
  export async function guard(execute, input, guards, options) {
2
- if (typeof guards === "function") {
3
- guards = [guards];
4
- }
3
+ const guardList = Array.isArray(guards) ? guards : [guards];
5
4
  const maxRetries = options?.maxRetries ?? 1;
6
- let attempts = 0;
7
- while (attempts <= maxRetries) {
8
- let result;
9
- try {
10
- result = {
11
- type: "value",
12
- input,
13
- output: await execute(input),
14
- };
15
- }
16
- catch (error) {
17
- result = {
18
- type: "error",
19
- input,
20
- error,
21
- };
22
- }
23
- let isValid = true;
24
- for (const guard of guards) {
25
- const guardResult = await guard(result);
26
- if (guardResult === undefined) {
27
- continue;
28
- }
29
- switch (guardResult.action) {
30
- case "passThrough": {
31
- break;
32
- }
33
- case "retry": {
34
- input = guardResult.input;
35
- isValid = false;
36
- break;
37
- }
38
- case "return": {
5
+ return executeFunctionCall({
6
+ options,
7
+ input,
8
+ functionType: "guard",
9
+ execute: async (options) => {
10
+ let attempts = 0;
11
+ while (attempts <= maxRetries) {
12
+ let result;
13
+ try {
39
14
  result = {
40
15
  type: "value",
41
16
  input,
42
- output: guardResult.output,
17
+ output: await execute(input, options),
43
18
  };
44
- break;
45
19
  }
46
- case "throwError": {
20
+ catch (error) {
47
21
  result = {
48
22
  type: "error",
49
23
  input,
50
- error: guardResult.error,
24
+ error,
51
25
  };
52
- break;
53
26
  }
27
+ let isValid = true;
28
+ for (const guard of guardList) {
29
+ const guardResult = await guard(result);
30
+ if (guardResult === undefined) {
31
+ continue;
32
+ }
33
+ switch (guardResult.action) {
34
+ case "passThrough": {
35
+ break;
36
+ }
37
+ case "retry": {
38
+ input = guardResult.input;
39
+ isValid = false;
40
+ break;
41
+ }
42
+ case "return": {
43
+ result = {
44
+ type: "value",
45
+ input,
46
+ output: guardResult.output,
47
+ };
48
+ break;
49
+ }
50
+ case "throwError": {
51
+ result = {
52
+ type: "error",
53
+ input,
54
+ error: guardResult.error,
55
+ };
56
+ break;
57
+ }
58
+ }
59
+ }
60
+ if (isValid) {
61
+ if (result.type === "value") {
62
+ return result.output;
63
+ }
64
+ else {
65
+ throw result.error;
66
+ }
67
+ }
68
+ attempts++;
54
69
  }
55
- }
56
- if (isValid) {
57
- if (result.type === "value") {
58
- return result.output;
59
- }
60
- else {
61
- throw result.error;
62
- }
63
- }
64
- attempts++;
65
- }
66
- throw new Error(`Maximum retry attempts of ${maxRetries} reached ` +
67
- `without producing a valid output or handling an error after ${attempts} attempts.`);
70
+ throw new Error(`Maximum retry attempts of ${maxRetries} reached ` +
71
+ `without producing a valid output or handling an error after ${attempts} attempts.`);
72
+ },
73
+ });
68
74
  }
package/guard/index.cjs CHANGED
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./GuardEvent.cjs"), exports);
17
18
  __exportStar(require("./fixStructure.cjs"), exports);
18
19
  __exportStar(require("./guard.cjs"), exports);
package/guard/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export * from "./GuardEvent.js";
1
2
  export * from "./fixStructure.js";
2
3
  export * from "./guard.js";
package/guard/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ export * from "./GuardEvent.js";
1
2
  export * from "./fixStructure.js";
2
3
  export * from "./guard.js";
@@ -1,7 +1,7 @@
1
1
  import { Vector } from "../../core/Vector.js";
2
2
  import { BaseModelCallFinishedEvent, BaseModelCallStartedEvent } from "../ModelCallEvent.js";
3
3
  export interface EmbeddingStartedEvent extends BaseModelCallStartedEvent {
4
- functionType: "embedding";
4
+ functionType: "embed";
5
5
  input: unknown | Array<unknown>;
6
6
  }
7
7
  export type EmbeddingFinishedEventResult = {
@@ -15,7 +15,7 @@ export type EmbeddingFinishedEventResult = {
15
15
  status: "abort";
16
16
  };
17
17
  export interface EmbeddingFinishedEvent extends BaseModelCallFinishedEvent {
18
- functionType: "embedding";
18
+ functionType: "embed";
19
19
  input: unknown | Array<unknown>;
20
20
  result: EmbeddingFinishedEventResult;
21
21
  }
@@ -17,7 +17,7 @@ const ModelFunctionPromise_js_1 = require("../ModelFunctionPromise.cjs");
17
17
  */
18
18
  function embedMany(model, values, options) {
19
19
  return new ModelFunctionPromise_js_1.ModelFunctionPromise((0, executeStandardCall_js_1.executeStandardCall)({
20
- functionType: "embedding",
20
+ functionType: "embed",
21
21
  input: values,
22
22
  model,
23
23
  options,
@@ -58,7 +58,7 @@ exports.embedMany = embedMany;
58
58
  */
59
59
  function embed(model, value, options) {
60
60
  return new ModelFunctionPromise_js_1.ModelFunctionPromise((0, executeStandardCall_js_1.executeStandardCall)({
61
- functionType: "embedding",
61
+ functionType: "embed",
62
62
  input: value,
63
63
  model,
64
64
  options,
@@ -14,7 +14,7 @@ import { ModelFunctionPromise } from "../ModelFunctionPromise.js";
14
14
  */
15
15
  export function embedMany(model, values, options) {
16
16
  return new ModelFunctionPromise(executeStandardCall({
17
- functionType: "embedding",
17
+ functionType: "embed",
18
18
  input: values,
19
19
  model,
20
20
  options,
@@ -54,7 +54,7 @@ export function embedMany(model, values, options) {
54
54
  */
55
55
  export function embed(model, value, options) {
56
56
  return new ModelFunctionPromise(executeStandardCall({
57
- functionType: "embedding",
57
+ functionType: "embed",
58
58
  input: value,
59
59
  model,
60
60
  options,
@@ -27,6 +27,7 @@ async function executeStandardCall({ model, options, input, functionType, genera
27
27
  const startMetadata = {
28
28
  functionType,
29
29
  callId: `call-${(0, nanoid_1.nanoid)()}`,
30
+ parentCallId: options?.parentCallId,
30
31
  runId: run?.runId,
31
32
  sessionId: run?.sessionId,
32
33
  userId: run?.userId,
@@ -46,6 +47,7 @@ async function executeStandardCall({ model, options, input, functionType, genera
46
47
  logging: options?.logging,
47
48
  observers: options?.observers,
48
49
  run,
50
+ parentCallId: startMetadata.callId,
49
51
  }));
50
52
  const finishMetadata = {
51
53
  eventType: "finished",
@@ -24,6 +24,7 @@ export async function executeStandardCall({ model, options, input, functionType,
24
24
  const startMetadata = {
25
25
  functionType,
26
26
  callId: `call-${createId()}`,
27
+ parentCallId: options?.parentCallId,
27
28
  runId: run?.runId,
28
29
  sessionId: run?.sessionId,
29
30
  userId: run?.userId,
@@ -43,6 +44,7 @@ export async function executeStandardCall({ model, options, input, functionType,
43
44
  logging: options?.logging,
44
45
  observers: options?.observers,
45
46
  run,
47
+ parentCallId: startMetadata.callId,
46
48
  }));
47
49
  const finishMetadata = {
48
50
  eventType: "finished",
@@ -27,6 +27,7 @@ async function executeStreamCall({ model, options, input, functionType, startStr
27
27
  const startMetadata = {
28
28
  functionType,
29
29
  callId: `call-${(0, nanoid_1.nanoid)()}`,
30
+ parentCallId: options?.parentCallId,
30
31
  runId: run?.runId,
31
32
  sessionId: run?.sessionId,
32
33
  userId: run?.userId,
@@ -47,6 +48,7 @@ async function executeStreamCall({ model, options, input, functionType, startStr
47
48
  logging: options?.logging,
48
49
  observers: options?.observers,
49
50
  run,
51
+ parentCallId: startMetadata.callId,
50
52
  });
51
53
  return (async function* () {
52
54
  for await (const event of deltaIterable) {
@@ -24,6 +24,7 @@ export async function executeStreamCall({ model, options, input, functionType, s
24
24
  const startMetadata = {
25
25
  functionType,
26
26
  callId: `call-${createId()}`,
27
+ parentCallId: options?.parentCallId,
27
28
  runId: run?.runId,
28
29
  sessionId: run?.sessionId,
29
30
  userId: run?.userId,
@@ -44,6 +45,7 @@ export async function executeStreamCall({ model, options, input, functionType, s
44
45
  logging: options?.logging,
45
46
  observers: options?.observers,
46
47
  run,
48
+ parentCallId: startMetadata.callId,
47
49
  });
48
50
  return (async function* () {
49
51
  for await (const event of deltaIterable) {
@@ -1,6 +1,6 @@
1
1
  import { BaseModelCallFinishedEvent, BaseModelCallStartedEvent } from "../ModelCallEvent.js";
2
2
  export interface ImageGenerationStartedEvent extends BaseModelCallStartedEvent {
3
- functionType: "image-generation";
3
+ functionType: "generate-image";
4
4
  }
5
5
  export type ImageGenerationFinishedEventResult = {
6
6
  status: "success";
@@ -13,6 +13,6 @@ export type ImageGenerationFinishedEventResult = {
13
13
  status: "abort";
14
14
  };
15
15
  export interface ImageGenerationFinishedEvent extends BaseModelCallFinishedEvent {
16
- functionType: "image-generation";
16
+ functionType: "generate-image";
17
17
  result: ImageGenerationFinishedEventResult;
18
18
  }
@@ -20,7 +20,7 @@ const ImageGenerationPromise_js_1 = require("./ImageGenerationPromise.cjs");
20
20
  */
21
21
  function generateImage(model, prompt, options) {
22
22
  return new ImageGenerationPromise_js_1.ImageGenerationPromise((0, executeStandardCall_js_1.executeStandardCall)({
23
- functionType: "image-generation",
23
+ functionType: "generate-image",
24
24
  input: prompt,
25
25
  model,
26
26
  options,
@@ -17,7 +17,7 @@ import { ImageGenerationPromise } from "./ImageGenerationPromise.js";
17
17
  */
18
18
  export function generateImage(model, prompt, options) {
19
19
  return new ImageGenerationPromise(executeStandardCall({
20
- functionType: "image-generation",
20
+ functionType: "generate-image",
21
21
  input: prompt,
22
22
  model,
23
23
  options,
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { BaseModelCallFinishedEvent, BaseModelCallStartedEvent } from "../ModelCallEvent.js";
3
3
  export interface SpeechGenerationStartedEvent extends BaseModelCallStartedEvent {
4
- functionType: "speech-generation";
4
+ functionType: "generate-speech";
5
5
  input: string;
6
6
  }
7
7
  export type SpeechGenerationFinishedEventResult = {
@@ -15,13 +15,13 @@ export type SpeechGenerationFinishedEventResult = {
15
15
  status: "abort";
16
16
  };
17
17
  export interface SpeechGenerationFinishedEvent extends BaseModelCallFinishedEvent {
18
- functionType: "speech-generation";
18
+ functionType: "generate-speech";
19
19
  input: string;
20
20
  result: SpeechGenerationFinishedEventResult;
21
21
  }
22
22
  export interface SpeechStreamingStartedEvent extends BaseModelCallStartedEvent {
23
- functionType: "speech-streaming";
23
+ functionType: "stream-speech";
24
24
  }
25
25
  export interface SpeechStreamingFinishedEvent extends BaseModelCallFinishedEvent {
26
- functionType: "speech-streaming";
26
+ functionType: "stream-speech";
27
27
  }
@@ -8,7 +8,7 @@ const executeStandardCall_js_1 = require("../executeStandardCall.cjs");
8
8
  */
9
9
  function generateSpeech(model, text, options) {
10
10
  return new ModelFunctionPromise_js_1.ModelFunctionPromise((0, executeStandardCall_js_1.executeStandardCall)({
11
- functionType: "speech-generation",
11
+ functionType: "generate-speech",
12
12
  input: text,
13
13
  model,
14
14
  options,
@@ -5,7 +5,7 @@ import { executeStandardCall } from "../executeStandardCall.js";
5
5
  */
6
6
  export function generateSpeech(model, text, options) {
7
7
  return new ModelFunctionPromise(executeStandardCall({
8
- functionType: "speech-generation",
8
+ functionType: "generate-speech",
9
9
  input: text,
10
10
  model,
11
11
  options,
@@ -20,7 +20,7 @@ function streamSpeech(model, text, options) {
20
20
  textStream = text;
21
21
  }
22
22
  return new AsyncIterableResultPromise_js_1.AsyncIterableResultPromise((0, executeStreamCall_js_1.executeStreamCall)({
23
- functionType: "speech-streaming",
23
+ functionType: "stream-speech",
24
24
  input: text,
25
25
  model,
26
26
  options,
@@ -17,7 +17,7 @@ export function streamSpeech(model, text, options) {
17
17
  textStream = text;
18
18
  }
19
19
  return new AsyncIterableResultPromise(executeStreamCall({
20
- functionType: "speech-streaming",
20
+ functionType: "stream-speech",
21
21
  input: text,
22
22
  model,
23
23
  options,
@@ -1,6 +1,6 @@
1
1
  import { BaseModelCallFinishedEvent, BaseModelCallStartedEvent } from "../ModelCallEvent.js";
2
2
  export interface StructureGenerationStartedEvent extends BaseModelCallStartedEvent {
3
- functionType: "structure-generation" | "structure-or-text-generation";
3
+ functionType: "generate-structure" | "generate-structure-or-text";
4
4
  }
5
5
  export type StructureGenerationFinishedEventResult = {
6
6
  status: "success";
@@ -18,6 +18,6 @@ export type StructureGenerationFinishedEventResult = {
18
18
  status: "abort";
19
19
  };
20
20
  export type StructureGenerationFinishedEvent = BaseModelCallFinishedEvent & {
21
- functionType: "structure-generation" | "structure-or-text-generation";
21
+ functionType: "generate-structure" | "generate-structure-or-text";
22
22
  result: StructureGenerationFinishedEventResult;
23
23
  };
@@ -1,7 +1,7 @@
1
1
  import { BaseModelCallFinishedEvent, BaseModelCallStartedEvent } from "../ModelCallEvent.js";
2
2
  export interface StructureStreamingStartedEvent extends BaseModelCallStartedEvent {
3
- functionType: "structure-streaming";
3
+ functionType: "stream-structure";
4
4
  }
5
5
  export interface StructureStreamingFinishedEvent extends BaseModelCallFinishedEvent {
6
- functionType: "structure-streaming";
6
+ functionType: "stream-structure";
7
7
  }
@@ -10,7 +10,7 @@ function generateStructure(model, structureDefinition, prompt, options) {
10
10
  ? prompt(structureDefinition)
11
11
  : prompt;
12
12
  return new ModelFunctionPromise_js_1.ModelFunctionPromise((0, executeStandardCall_js_1.executeStandardCall)({
13
- functionType: "structure-generation",
13
+ functionType: "generate-structure",
14
14
  input: expandedPrompt,
15
15
  model,
16
16
  options,
@@ -7,7 +7,7 @@ export function generateStructure(model, structureDefinition, prompt, options) {
7
7
  ? prompt(structureDefinition)
8
8
  : prompt;
9
9
  return new ModelFunctionPromise(executeStandardCall({
10
- functionType: "structure-generation",
10
+ functionType: "generate-structure",
11
11
  input: expandedPrompt,
12
12
  model,
13
13
  options,
@@ -11,7 +11,7 @@ function generateStructureOrText(model, structureDefinitions, prompt, options) {
11
11
  ? prompt(structureDefinitions)
12
12
  : prompt;
13
13
  return new ModelFunctionPromise_js_1.ModelFunctionPromise((0, executeStandardCall_js_1.executeStandardCall)({
14
- functionType: "structure-or-text-generation",
14
+ functionType: "generate-structure-or-text",
15
15
  input: expandedPrompt,
16
16
  model,
17
17
  options,
@@ -8,7 +8,7 @@ export function generateStructureOrText(model, structureDefinitions, prompt, opt
8
8
  ? prompt(structureDefinitions)
9
9
  : prompt;
10
10
  return new ModelFunctionPromise(executeStandardCall({
11
- functionType: "structure-or-text-generation",
11
+ functionType: "generate-structure-or-text",
12
12
  input: expandedPrompt,
13
13
  model,
14
14
  options,
@@ -8,7 +8,7 @@ function streamStructure(model, structureDefinition, prompt, options) {
8
8
  let lastStructure;
9
9
  let lastFullDelta;
10
10
  return new AsyncIterableResultPromise_js_1.AsyncIterableResultPromise((0, executeStreamCall_js_1.executeStreamCall)({
11
- functionType: "structure-streaming",
11
+ functionType: "stream-structure",
12
12
  input: prompt,
13
13
  model,
14
14
  options,
@@ -5,7 +5,7 @@ export function streamStructure(model, structureDefinition, prompt, options) {
5
5
  let lastStructure;
6
6
  let lastFullDelta;
7
7
  return new AsyncIterableResultPromise(executeStreamCall({
8
- functionType: "structure-streaming",
8
+ functionType: "stream-structure",
9
9
  input: prompt,
10
10
  model,
11
11
  options,
@@ -1,6 +1,6 @@
1
1
  import { BaseModelCallFinishedEvent, BaseModelCallStartedEvent } from "../ModelCallEvent.js";
2
2
  export interface TextGenerationStartedEvent extends BaseModelCallStartedEvent {
3
- functionType: "text-generation";
3
+ functionType: "generate-text";
4
4
  }
5
5
  export type TextGenerationFinishedEventResult = {
6
6
  status: "success";
@@ -18,12 +18,12 @@ export type TextGenerationFinishedEventResult = {
18
18
  status: "abort";
19
19
  };
20
20
  export interface TextGenerationFinishedEvent extends BaseModelCallFinishedEvent {
21
- functionType: "text-generation";
21
+ functionType: "generate-text";
22
22
  result: TextGenerationFinishedEventResult;
23
23
  }
24
24
  export interface TextStreamingStartedEvent extends BaseModelCallStartedEvent {
25
- functionType: "text-streaming";
25
+ functionType: "stream-text";
26
26
  }
27
27
  export interface TextStreamingFinishedEvent extends BaseModelCallFinishedEvent {
28
- functionType: "text-streaming";
28
+ functionType: "stream-text";
29
29
  }
@@ -18,7 +18,7 @@ const ModelFunctionPromise_js_1 = require("../ModelFunctionPromise.cjs");
18
18
  */
19
19
  function generateText(model, prompt, options) {
20
20
  return new ModelFunctionPromise_js_1.ModelFunctionPromise((0, executeStandardCall_js_1.executeStandardCall)({
21
- functionType: "text-generation",
21
+ functionType: "generate-text",
22
22
  input: prompt,
23
23
  model,
24
24
  options,
@@ -15,7 +15,7 @@ import { ModelFunctionPromise } from "../ModelFunctionPromise.js";
15
15
  */
16
16
  export function generateText(model, prompt, options) {
17
17
  return new ModelFunctionPromise(executeStandardCall({
18
- functionType: "text-generation",
18
+ functionType: "generate-text",
19
19
  input: prompt,
20
20
  model,
21
21
  options,