@zimtsui/brainswitch 0.0.40 → 0.0.42
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 +9 -20
- package/build/adaptor.d.ts +4 -2
- package/build/adaptor.js +27 -10
- package/build/adaptor.js.map +1 -1
- package/build/agentloop.d.ts +1 -1
- package/build/agentloop.js +2 -4
- package/build/agentloop.js.map +1 -1
- package/build/api-types/anthropic.d.ts +18 -22
- package/build/api-types/anthropic.js +81 -72
- package/build/api-types/anthropic.js.map +1 -1
- package/build/api-types/google.d.ts +13 -18
- package/build/api-types/google.js +32 -33
- package/build/api-types/google.js.map +1 -1
- package/build/api-types/openai-chat-completions.d.ts +17 -19
- package/build/api-types/openai-chat-completions.js +101 -85
- package/build/api-types/openai-chat-completions.js.map +1 -1
- package/build/api-types/openai-responses.d.ts +13 -13
- package/build/api-types/openai-responses.js +59 -51
- package/build/api-types/openai-responses.js.map +1 -1
- package/build/compatible-engine.d.ts +19 -24
- package/build/compatible-engine.js +54 -56
- package/build/compatible-engine.js.map +1 -1
- package/build/compatible-engines.d/aliyun.d.ts +38 -55
- package/build/compatible-engines.d/aliyun.js +91 -143
- package/build/compatible-engines.d/aliyun.js.map +1 -1
- package/build/compatible-engines.d/anthropic.d.ts +35 -60
- package/build/compatible-engines.d/anthropic.js +233 -282
- package/build/compatible-engines.d/anthropic.js.map +1 -1
- package/build/compatible-engines.d/google.d.ts +38 -59
- package/build/compatible-engines.d/google.js +172 -231
- package/build/compatible-engines.d/google.js.map +1 -1
- package/build/compatible-engines.d/openai-chatcompletions.d/monolith.d.ts +7 -14
- package/build/compatible-engines.d/openai-chatcompletions.d/monolith.js +64 -66
- package/build/compatible-engines.d/openai-chatcompletions.d/monolith.js.map +1 -1
- package/build/compatible-engines.d/openai-chatcompletions.d/stream.d.ts +10 -16
- package/build/compatible-engines.d/openai-chatcompletions.d/stream.js +169 -165
- package/build/compatible-engines.d/openai-chatcompletions.d/stream.js.map +1 -1
- package/build/compatible-engines.d/openai-chatcompletions.d.ts +12 -18
- package/build/compatible-engines.d/openai-chatcompletions.js +64 -64
- package/build/compatible-engines.d/openai-chatcompletions.js.map +1 -1
- package/build/compatible-engines.d/openai-responses.d.ts +46 -68
- package/build/compatible-engines.d/openai-responses.js +222 -274
- package/build/compatible-engines.d/openai-responses.js.map +1 -1
- package/build/engine.d.ts +10 -24
- package/build/engine.js +25 -38
- package/build/engine.js.map +1 -1
- package/build/exports.d.ts +1 -0
- package/build/exports.js +1 -0
- package/build/exports.js.map +1 -1
- package/build/frontmatter.js +2 -2
- package/build/frontmatter.js.map +1 -1
- package/build/function.js +9 -4
- package/build/function.js.map +1 -1
- package/build/inference-context.d.ts +1 -10
- package/build/inference-context.js +0 -2
- package/build/inference-context.js.map +1 -1
- package/build/native-engines.d/google/agentloop.d.ts +1 -1
- package/build/native-engines.d/google/agentloop.js +2 -4
- package/build/native-engines.d/google/agentloop.js.map +1 -1
- package/build/native-engines.d/google/engine.d.ts +56 -73
- package/build/native-engines.d/google/engine.js +265 -295
- package/build/native-engines.d/google/engine.js.map +1 -1
- package/build/native-engines.d/google/exports.d.ts +3 -2
- package/build/native-engines.d/google/exports.js +3 -2
- package/build/native-engines.d/google/exports.js.map +1 -1
- package/build/native-engines.d/google/session.js +6 -3
- package/build/native-engines.d/google/session.js.map +1 -1
- package/build/native-engines.d/openai-responses/agentloop.d.ts +1 -1
- package/build/native-engines.d/openai-responses/agentloop.js +2 -5
- package/build/native-engines.d/openai-responses/agentloop.js.map +1 -1
- package/build/native-engines.d/openai-responses/engine.d.ts +59 -78
- package/build/native-engines.d/openai-responses/engine.js +285 -321
- package/build/native-engines.d/openai-responses/engine.js.map +1 -1
- package/build/native-engines.d/openai-responses/exports.d.ts +4 -2
- package/build/native-engines.d/openai-responses/exports.js +4 -2
- package/build/native-engines.d/openai-responses/exports.js.map +1 -1
- package/build/native-engines.d/openai-responses/session.js +21 -8
- package/build/native-engines.d/openai-responses/session.js.map +1 -1
- package/build/session.js +12 -5
- package/build/session.js.map +1 -1
- package/build/telemetry.d.ts +6 -0
- package/build/telemetry.js +3 -0
- package/build/telemetry.js.map +1 -0
- package/build/throttle.d.ts +1 -1
- package/build/throttle.js +6 -6
- package/build/throttle.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -2,8 +2,15 @@ import { type Engine } from '../engine.ts';
|
|
|
2
2
|
import { Function } from '../function.ts';
|
|
3
3
|
import OpenAI from 'openai';
|
|
4
4
|
export declare namespace OpenAIChatCompletionsEngine {
|
|
5
|
-
interface
|
|
6
|
-
|
|
5
|
+
interface Options<in out fdm extends Function.Declaration.Map> extends Engine.Options<fdm> {
|
|
6
|
+
}
|
|
7
|
+
interface OwnProps {
|
|
8
|
+
parallelToolCall: boolean;
|
|
9
|
+
}
|
|
10
|
+
namespace OwnProps {
|
|
11
|
+
function init<fdm extends Function.Declaration.Map>(options: Options<fdm>): OwnProps;
|
|
12
|
+
}
|
|
13
|
+
interface Underhood<in out fdm extends Function.Declaration.Map> extends Engine.Underhood<fdm>, OwnProps {
|
|
7
14
|
convertFromFunctionCall(fc: Function.Call.Distributive<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionMessageToolCall;
|
|
8
15
|
convertToFunctionCall(apifc: OpenAI.ChatCompletionMessageFunctionToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
9
16
|
convertFromFunctionResponse(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionToolMessageParam;
|
|
@@ -13,21 +20,12 @@ export declare namespace OpenAIChatCompletionsEngine {
|
|
|
13
20
|
extractContent(completionContent: string): string;
|
|
14
21
|
handleFinishReason(completion: OpenAI.ChatCompletion, finishReason: OpenAI.ChatCompletion.Choice['finish_reason']): void;
|
|
15
22
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
convertToFunctionCall(apifc: OpenAI.ChatCompletionMessageFunctionToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
25
|
-
convertFromFunctionResponse(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionToolMessageParam;
|
|
26
|
-
convertFromFunctionDeclarationEntry(fdentry: Function.Declaration.Entry.From<fdm>): OpenAI.ChatCompletionTool;
|
|
27
|
-
convertFromToolChoice(mode: Function.ToolChoice<fdm>): OpenAI.ChatCompletionToolChoiceOption;
|
|
28
|
-
calcCost(usage: OpenAI.CompletionUsage): number;
|
|
29
|
-
extractContent(completionContent: string): string;
|
|
30
|
-
handleFinishReason(completion: OpenAI.ChatCompletion, finishReason: OpenAI.ChatCompletion.Choice['finish_reason']): void;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
23
|
+
function convertFromFunctionCall<fdm extends Function.Declaration.Map>(fc: Function.Call.Distributive<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionMessageToolCall;
|
|
24
|
+
function convertToFunctionCall<fdm extends Function.Declaration.Map>(this: Engine.Underhood<fdm>, apifc: OpenAI.ChatCompletionMessageFunctionToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
25
|
+
function convertFromFunctionResponse<fdm extends Function.Declaration.Map>(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionToolMessageParam;
|
|
26
|
+
function convertFromFunctionDeclarationEntry<fdm extends Function.Declaration.Map>(fdentry: Function.Declaration.Entry.From<fdm>): OpenAI.ChatCompletionTool;
|
|
27
|
+
function convertFromToolChoice<fdm extends Function.Declaration.Map>(toolChoice: Function.ToolChoice<fdm>): OpenAI.ChatCompletionToolChoiceOption;
|
|
28
|
+
function calcCost<fdm extends Function.Declaration.Map>(this: Engine.Underhood<fdm>, usage: OpenAI.CompletionUsage): number;
|
|
29
|
+
function extractContent(completionContent: string): string;
|
|
30
|
+
function handleFinishReason(completion: OpenAI.ChatCompletion, finishReason: OpenAI.ChatCompletion.Choice['finish_reason']): void;
|
|
33
31
|
}
|
|
@@ -1,97 +1,113 @@
|
|
|
1
1
|
import { ResponseInvalid } from "../engine.js";
|
|
2
2
|
import { Function } from "../function.js";
|
|
3
3
|
import OpenAI from 'openai';
|
|
4
|
-
import assert from 'node:assert';
|
|
5
4
|
import { Ajv } from 'ajv';
|
|
6
5
|
const ajv = new Ajv();
|
|
7
6
|
export var OpenAIChatCompletionsEngine;
|
|
8
7
|
(function (OpenAIChatCompletionsEngine) {
|
|
9
|
-
let
|
|
10
|
-
(function (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
assert(ajv.validate(fditem.paraschema, args), new ResponseInvalid('Invalid function arguments', { cause: apifc }));
|
|
41
|
-
return Function.Call.create({
|
|
42
|
-
id: apifc.id,
|
|
43
|
-
name: apifc.function.name,
|
|
44
|
-
args,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
convertFromFunctionResponse(fr) {
|
|
48
|
-
assert(fr.id);
|
|
49
|
-
return {
|
|
50
|
-
role: 'tool',
|
|
51
|
-
tool_call_id: fr.id,
|
|
52
|
-
content: fr.text,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
convertFromFunctionDeclarationEntry(fdentry) {
|
|
56
|
-
return {
|
|
57
|
-
type: 'function',
|
|
58
|
-
function: {
|
|
59
|
-
name: fdentry[0],
|
|
60
|
-
description: fdentry[1].description,
|
|
61
|
-
strict: true,
|
|
62
|
-
parameters: fdentry[1].paraschema,
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
convertFromToolChoice(mode) {
|
|
67
|
-
if (mode === Function.ToolChoice.NONE)
|
|
68
|
-
return 'none';
|
|
69
|
-
else if (mode === Function.ToolChoice.REQUIRED)
|
|
70
|
-
return 'required';
|
|
71
|
-
else if (mode === Function.ToolChoice.AUTO)
|
|
72
|
-
return 'auto';
|
|
73
|
-
else {
|
|
74
|
-
assert(mode.length === 1);
|
|
75
|
-
return { type: 'function', function: { name: mode[0] } };
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
calcCost(usage) {
|
|
79
|
-
const cacheHitTokenCount = usage.prompt_tokens_details?.cached_tokens ?? 0;
|
|
80
|
-
const cacheMissTokenCount = usage.prompt_tokens - cacheHitTokenCount;
|
|
81
|
-
return this.instance.inputPrice * cacheMissTokenCount / 1e6 +
|
|
82
|
-
this.instance.cachedPrice * cacheHitTokenCount / 1e6 +
|
|
83
|
-
this.instance.outputPrice * usage.completion_tokens / 1e6;
|
|
84
|
-
}
|
|
85
|
-
extractContent(completionContent) {
|
|
86
|
-
return completionContent;
|
|
8
|
+
let OwnProps;
|
|
9
|
+
(function (OwnProps) {
|
|
10
|
+
function init(options) {
|
|
11
|
+
return {
|
|
12
|
+
parallelToolCall: options.parallelToolCall ?? false,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
OwnProps.init = init;
|
|
16
|
+
})(OwnProps = OpenAIChatCompletionsEngine.OwnProps || (OpenAIChatCompletionsEngine.OwnProps = {}));
|
|
17
|
+
function convertFromFunctionCall(fc) {
|
|
18
|
+
if (fc.id) { }
|
|
19
|
+
else
|
|
20
|
+
throw new Error();
|
|
21
|
+
return {
|
|
22
|
+
id: fc.id,
|
|
23
|
+
type: 'function',
|
|
24
|
+
function: {
|
|
25
|
+
name: fc.name,
|
|
26
|
+
arguments: JSON.stringify(fc.args),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
OpenAIChatCompletionsEngine.convertFromFunctionCall = convertFromFunctionCall;
|
|
31
|
+
function convertToFunctionCall(apifc) {
|
|
32
|
+
const fditem = this.fdm[apifc.function.name];
|
|
33
|
+
if (fditem) { }
|
|
34
|
+
else
|
|
35
|
+
throw new ResponseInvalid('Unknown function call', { cause: apifc });
|
|
36
|
+
const args = (() => {
|
|
37
|
+
try {
|
|
38
|
+
return JSON.parse(apifc.function.arguments);
|
|
87
39
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
throw new ResponseInvalid('Token limit exceeded.', { cause: completion });
|
|
91
|
-
assert(['stop', 'tool_calls'].includes(finishReason), new ResponseInvalid('Abnormal finish reason', { cause: finishReason }));
|
|
40
|
+
catch (e) {
|
|
41
|
+
return new ResponseInvalid('Invalid JSON of function call', { cause: apifc });
|
|
92
42
|
}
|
|
43
|
+
})();
|
|
44
|
+
if (ajv.validate(fditem.paraschema, args)) { }
|
|
45
|
+
else
|
|
46
|
+
throw new ResponseInvalid('Invalid function arguments', { cause: apifc });
|
|
47
|
+
return Function.Call.create({
|
|
48
|
+
id: apifc.id,
|
|
49
|
+
name: apifc.function.name,
|
|
50
|
+
args,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
OpenAIChatCompletionsEngine.convertToFunctionCall = convertToFunctionCall;
|
|
54
|
+
function convertFromFunctionResponse(fr) {
|
|
55
|
+
if (fr.id) { }
|
|
56
|
+
else
|
|
57
|
+
throw new Error();
|
|
58
|
+
return {
|
|
59
|
+
role: 'tool',
|
|
60
|
+
tool_call_id: fr.id,
|
|
61
|
+
content: fr.text,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
OpenAIChatCompletionsEngine.convertFromFunctionResponse = convertFromFunctionResponse;
|
|
65
|
+
function convertFromFunctionDeclarationEntry(fdentry) {
|
|
66
|
+
return {
|
|
67
|
+
type: 'function',
|
|
68
|
+
function: {
|
|
69
|
+
name: fdentry[0],
|
|
70
|
+
description: fdentry[1].description,
|
|
71
|
+
strict: true,
|
|
72
|
+
parameters: fdentry[1].paraschema,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
OpenAIChatCompletionsEngine.convertFromFunctionDeclarationEntry = convertFromFunctionDeclarationEntry;
|
|
77
|
+
function convertFromToolChoice(toolChoice) {
|
|
78
|
+
if (toolChoice === Function.ToolChoice.NONE)
|
|
79
|
+
return 'none';
|
|
80
|
+
else if (toolChoice === Function.ToolChoice.REQUIRED)
|
|
81
|
+
return 'required';
|
|
82
|
+
else if (toolChoice === Function.ToolChoice.AUTO)
|
|
83
|
+
return 'auto';
|
|
84
|
+
else {
|
|
85
|
+
if (toolChoice.length === 1) { }
|
|
86
|
+
else
|
|
87
|
+
throw new Error();
|
|
88
|
+
return { type: 'function', function: { name: toolChoice[0] } };
|
|
93
89
|
}
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
}
|
|
91
|
+
OpenAIChatCompletionsEngine.convertFromToolChoice = convertFromToolChoice;
|
|
92
|
+
function calcCost(usage) {
|
|
93
|
+
const cacheHitTokenCount = usage.prompt_tokens_details?.cached_tokens ?? 0;
|
|
94
|
+
const cacheMissTokenCount = usage.prompt_tokens - cacheHitTokenCount;
|
|
95
|
+
return this.inputPrice * cacheMissTokenCount / 1e6 +
|
|
96
|
+
this.cachePrice * cacheHitTokenCount / 1e6 +
|
|
97
|
+
this.outputPrice * usage.completion_tokens / 1e6;
|
|
98
|
+
}
|
|
99
|
+
OpenAIChatCompletionsEngine.calcCost = calcCost;
|
|
100
|
+
function extractContent(completionContent) {
|
|
101
|
+
return completionContent;
|
|
102
|
+
}
|
|
103
|
+
OpenAIChatCompletionsEngine.extractContent = extractContent;
|
|
104
|
+
function handleFinishReason(completion, finishReason) {
|
|
105
|
+
if (finishReason === 'length')
|
|
106
|
+
throw new ResponseInvalid('Token limit exceeded.', { cause: completion });
|
|
107
|
+
if (['stop', 'tool_calls'].includes(finishReason)) { }
|
|
108
|
+
else
|
|
109
|
+
throw new ResponseInvalid('Abnormal finish reason', { cause: finishReason });
|
|
110
|
+
}
|
|
111
|
+
OpenAIChatCompletionsEngine.handleFinishReason = handleFinishReason;
|
|
96
112
|
})(OpenAIChatCompletionsEngine || (OpenAIChatCompletionsEngine = {}));
|
|
97
113
|
//# sourceMappingURL=openai-chat-completions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-chat-completions.js","sourceRoot":"","sources":["../../src/api-types/openai-chat-completions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"openai-chat-completions.js","sourceRoot":"","sources":["../../src/api-types/openai-chat-completions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1B,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;AAGtB,MAAM,KAAW,2BAA2B,CA2H3C;AA3HD,WAAiB,2BAA2B;IAMxC,IAAiB,QAAQ,CAMxB;IAND,WAAiB,QAAQ;QACrB,SAAgB,IAAI,CAAuC,OAAqB;YAC5E,OAAO;gBACH,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,KAAK;aACtD,CAAC;QACN,CAAC;QAJe,aAAI,OAInB,CAAA;IACL,CAAC,EANgB,QAAQ,GAAR,oCAAQ,KAAR,oCAAQ,QAMxB;IAgBD,SAAgB,uBAAuB,CACnC,EAA8D;QAE9D,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA,C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,kBAAkB,GAAG,KAAK,CAAC,qBAAqB,EAAE,aAAa,IAAI,CAAC,CAAC;QAC3E,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,GAAG,kBAAkB,CAAC;QACrE,OAAO,IAAI,CAAC,UAAU,GAAG,mBAAmB,GAAG,GAAG;YAC1C,IAAI,CAAC,UAAU,GAAG,kBAAkB,GAAG,GAAG;YAC1C,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,iBAAiB,GAAG,GAAG,CAAC;IAC7D,CAAC;IATe,oCAAQ,WASvB,CAAA;IAED,SAAgB,cAAc,CAAC,iBAAyB;QACpD,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAFe,0CAAc,iBAE7B,CAAA;IAED,SAAgB,kBAAkB,CAAC,UAAiC,EAAE,YAA2D;QAC7H,IAAI,YAAY,KAAK,QAAQ;YACzB,MAAM,IAAI,eAAe,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA,CAAC;;YAChD,MAAM,IAAI,eAAe,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IACtF,CAAC;IALe,8CAAkB,qBAKjC,CAAA;AACL,CAAC,EA3HgB,2BAA2B,KAA3B,2BAA2B,QA2H3C"}
|
|
@@ -2,22 +2,22 @@ import OpenAI from 'openai';
|
|
|
2
2
|
import { Function } from '../function.ts';
|
|
3
3
|
import { type Engine } from '../engine.ts';
|
|
4
4
|
export declare namespace OpenAIResponsesEngine {
|
|
5
|
-
interface
|
|
5
|
+
interface Options<in out fdm extends Function.Declaration.Map> extends Engine.Options<fdm> {
|
|
6
|
+
}
|
|
7
|
+
interface OwnProps {
|
|
8
|
+
parallelToolCall: boolean;
|
|
9
|
+
}
|
|
10
|
+
namespace OwnProps {
|
|
11
|
+
function init<fdm extends Function.Declaration.Map>(options: Options<fdm>): OwnProps;
|
|
12
|
+
}
|
|
13
|
+
interface Underhood<in out fdm extends Function.Declaration.Map> extends Engine.Underhood<fdm>, OwnProps {
|
|
6
14
|
convertFromFunctionResponse(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInputItem.FunctionCallOutput;
|
|
7
15
|
calcCost(usage: OpenAI.Responses.ResponseUsage): number;
|
|
8
16
|
convertFromFunctionDeclarationEntry(fdentry: Function.Declaration.Entry.From<fdm>): OpenAI.Responses.FunctionTool;
|
|
9
17
|
convertToFunctionCall(apifc: OpenAI.Responses.ResponseFunctionToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
10
18
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
protected instance: OpenAIResponsesEngine.Instance<fdm>;
|
|
16
|
-
constructor(instance: OpenAIResponsesEngine.Instance<fdm>);
|
|
17
|
-
convertFromFunctionResponse(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInputItem.FunctionCallOutput;
|
|
18
|
-
calcCost(usage: OpenAI.Responses.ResponseUsage): number;
|
|
19
|
-
convertFromFunctionDeclarationEntry(fdentry: Function.Declaration.Entry.From<fdm>): OpenAI.Responses.FunctionTool;
|
|
20
|
-
convertToFunctionCall(apifc: OpenAI.Responses.ResponseFunctionToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
19
|
+
function convertFromFunctionResponse<fdm extends Function.Declaration.Map>(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInputItem.FunctionCallOutput;
|
|
20
|
+
function calcCost<fdm extends Function.Declaration.Map>(this: Engine.Underhood<fdm>, usage: OpenAI.Responses.ResponseUsage): number;
|
|
21
|
+
function convertFromFunctionDeclarationEntry<fdm extends Function.Declaration.Map>(fdentry: Function.Declaration.Entry.From<fdm>): OpenAI.Responses.FunctionTool;
|
|
22
|
+
function convertToFunctionCall<fdm extends Function.Declaration.Map>(this: Engine.Underhood<fdm>, apifc: OpenAI.Responses.ResponseFunctionToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
23
23
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
1
|
import OpenAI from 'openai';
|
|
3
2
|
import { Function } from "../function.js";
|
|
4
3
|
import { ResponseInvalid } from "../engine.js";
|
|
@@ -7,57 +6,66 @@ import {} from "../engine.js";
|
|
|
7
6
|
const ajv = new Ajv();
|
|
8
7
|
export var OpenAIResponsesEngine;
|
|
9
8
|
(function (OpenAIResponsesEngine) {
|
|
10
|
-
let
|
|
11
|
-
(function (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
9
|
+
let OwnProps;
|
|
10
|
+
(function (OwnProps) {
|
|
11
|
+
function init(options) {
|
|
12
|
+
return {
|
|
13
|
+
parallelToolCall: options.parallelToolCall ?? false,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
OwnProps.init = init;
|
|
17
|
+
})(OwnProps = OpenAIResponsesEngine.OwnProps || (OpenAIResponsesEngine.OwnProps = {}));
|
|
18
|
+
function convertFromFunctionResponse(fr) {
|
|
19
|
+
if (fr.id) { }
|
|
20
|
+
else
|
|
21
|
+
throw new Error();
|
|
22
|
+
return {
|
|
23
|
+
type: 'function_call_output',
|
|
24
|
+
call_id: fr.id,
|
|
25
|
+
output: fr.text,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
OpenAIResponsesEngine.convertFromFunctionResponse = convertFromFunctionResponse;
|
|
29
|
+
function calcCost(usage) {
|
|
30
|
+
const cacheHitTokenCount = usage.input_tokens_details.cached_tokens;
|
|
31
|
+
const cacheMissTokenCount = usage.input_tokens - cacheHitTokenCount;
|
|
32
|
+
return this.inputPrice * cacheMissTokenCount / 1e6 +
|
|
33
|
+
this.cachePrice * cacheHitTokenCount / 1e6 +
|
|
34
|
+
this.outputPrice * usage.output_tokens / 1e6;
|
|
35
|
+
}
|
|
36
|
+
OpenAIResponsesEngine.calcCost = calcCost;
|
|
37
|
+
function convertFromFunctionDeclarationEntry(fdentry) {
|
|
38
|
+
return {
|
|
39
|
+
name: fdentry[0],
|
|
40
|
+
description: fdentry[1].description,
|
|
41
|
+
parameters: fdentry[1].paraschema,
|
|
42
|
+
strict: true,
|
|
43
|
+
type: 'function',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
OpenAIResponsesEngine.convertFromFunctionDeclarationEntry = convertFromFunctionDeclarationEntry;
|
|
47
|
+
function convertToFunctionCall(apifc) {
|
|
48
|
+
const fditem = this.fdm[apifc.name];
|
|
49
|
+
if (fditem) { }
|
|
50
|
+
else
|
|
51
|
+
throw new ResponseInvalid('Unknown function call', { cause: apifc });
|
|
52
|
+
const args = (() => {
|
|
53
|
+
try {
|
|
54
|
+
return JSON.parse(apifc.arguments);
|
|
40
55
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
assert(fditem, new ResponseInvalid('Unknown function call', { cause: apifc }));
|
|
44
|
-
const args = (() => {
|
|
45
|
-
try {
|
|
46
|
-
return JSON.parse(apifc.arguments);
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
return new ResponseInvalid('Invalid JSON of function call', { cause: apifc });
|
|
50
|
-
}
|
|
51
|
-
})();
|
|
52
|
-
assert(ajv.validate(fditem.paraschema, args), new ResponseInvalid('Function call not conforming to schema', { cause: apifc }));
|
|
53
|
-
return Function.Call.create({
|
|
54
|
-
id: apifc.call_id,
|
|
55
|
-
name: apifc.name,
|
|
56
|
-
args,
|
|
57
|
-
});
|
|
56
|
+
catch (e) {
|
|
57
|
+
return new ResponseInvalid('Invalid JSON of function call', { cause: apifc });
|
|
58
58
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
})();
|
|
60
|
+
if (ajv.validate(fditem.paraschema, args)) { }
|
|
61
|
+
else
|
|
62
|
+
throw new ResponseInvalid('Function call not conforming to schema', { cause: apifc });
|
|
63
|
+
return Function.Call.create({
|
|
64
|
+
id: apifc.call_id,
|
|
65
|
+
name: apifc.name,
|
|
66
|
+
args,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
OpenAIResponsesEngine.convertToFunctionCall = convertToFunctionCall;
|
|
62
70
|
})(OpenAIResponsesEngine || (OpenAIResponsesEngine = {}));
|
|
63
71
|
//# sourceMappingURL=openai-responses.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-responses.js","sourceRoot":"","sources":["../../src/api-types/openai-responses.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"openai-responses.js","sourceRoot":"","sources":["../../src/api-types/openai-responses.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAe,MAAM,cAAc,CAAC;AAE3C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;AAItB,MAAM,KAAW,qBAAqB,CA+ErC;AA/ED,WAAiB,qBAAqB;IAMlC,IAAiB,QAAQ,CAMxB;IAND,WAAiB,QAAQ;QACrB,SAAgB,IAAI,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KAAK,CAAC,IAAI,CAAoD,CAAC;QACvF,IAAI,MAAM,EAAE,CAAC,CAAA,CAAC;;YAAM,MAAM,IAAI,eAAe,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACzF,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE;YACf,IAAI,CAAC;gBACD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACvC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,OAAO,IAAI,eAAe,CAAC,+BAA+B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YAClF,CAAC;QACL,CAAC,CAAC,EAAE,CAAC;QACL,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA,CAAC;;YACxC,MAAM,IAAI,eAAe,CAAC,wCAAwC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3F,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;YACxB,EAAE,EAAE,KAAK,CAAC,OAAO;YACjB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI;SACyD,CAAC,CAAC;IACvE,CAAC;IApBe,2CAAqB,wBAoBpC,CAAA;AACL,CAAC,EA/EgB,qBAAqB,KAArB,qBAAqB,QA+ErC"}
|
|
@@ -4,16 +4,16 @@ import { type InferenceContext } from './inference-context.ts';
|
|
|
4
4
|
import { type Engine } from './engine.ts';
|
|
5
5
|
export interface CompatibleEngine<in out fdm extends Function.Declaration.Map> extends Engine {
|
|
6
6
|
/**
|
|
7
|
-
* @throws {@link
|
|
7
|
+
* @throws {@link USER_ABORTION} 用户中止
|
|
8
8
|
* @throws {@link InferenceTimeout} 推理超时
|
|
9
9
|
* @throws {@link ResponseInvalid} 模型抽风
|
|
10
10
|
* @throws {TypeError} 网络故障
|
|
11
11
|
*/
|
|
12
|
-
stateless(
|
|
12
|
+
stateless(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
13
13
|
/**
|
|
14
14
|
* @param session mutable
|
|
15
15
|
*/
|
|
16
|
-
stateful(
|
|
16
|
+
stateful(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
17
17
|
appendUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
18
18
|
/**
|
|
19
19
|
* @param session mutable
|
|
@@ -21,36 +21,31 @@ export interface CompatibleEngine<in out fdm extends Function.Declaration.Map> e
|
|
|
21
21
|
pushUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
22
22
|
}
|
|
23
23
|
export declare namespace CompatibleEngine {
|
|
24
|
-
interface Options<in out fdm extends Function.Declaration.Map> extends Engine.Options<fdm>,
|
|
24
|
+
interface Options<in out fdm extends Function.Declaration.Map> extends Engine.Options<fdm>, Options.Tools<fdm> {
|
|
25
25
|
}
|
|
26
26
|
namespace Options {
|
|
27
27
|
interface Tools<in out fdm extends Function.Declaration.Map> extends Engine.Options.Tools<fdm> {
|
|
28
28
|
toolChoice?: Function.ToolChoice<fdm>;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
interface
|
|
31
|
+
interface OwnProps<in out fdm extends Function.Declaration.Map> {
|
|
32
32
|
toolChoice: Function.ToolChoice<fdm>;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
}
|
|
34
|
+
namespace OwnProps {
|
|
35
|
+
function init<fdm extends Function.Declaration.Map>(options: CompatibleEngine.Options<fdm>): OwnProps<fdm>;
|
|
36
|
+
}
|
|
37
|
+
interface Underhood<in out fdm extends Function.Declaration.Map> extends Engine.Underhood<fdm>, CompatibleEngine<fdm>, OwnProps<fdm> {
|
|
38
|
+
parallelToolCall: boolean;
|
|
39
|
+
fetch(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
40
|
+
stateless(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
41
|
+
stateful(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
35
42
|
appendUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
36
43
|
pushUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
37
44
|
validateToolCallsByToolChoice(toolCalls: Function.Call.Distributive<Function.Declaration.From<fdm>>[]): void;
|
|
38
45
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class Instance<in out fdm extends Function.Declaration.Map> implements CompatibleEngine.Base<fdm> {
|
|
45
|
-
protected instance: CompatibleEngine.Instance<fdm>;
|
|
46
|
-
toolChoice: Function.ToolChoice<fdm>;
|
|
47
|
-
constructor(instance: CompatibleEngine.Instance<fdm>, options: CompatibleEngine.Options<fdm>);
|
|
48
|
-
stateless(ctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
49
|
-
stateful(ctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
50
|
-
appendUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
51
|
-
pushUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
52
|
-
validateToolCallsByToolChoice(toolCalls: Function.Call.Distributive<Function.Declaration.From<fdm>>[]): void;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function validateToolCallsByToolChoice<fdm extends Function.Declaration.Map>(toolCalls: Function.Call.Distributive<Function.Declaration.From<fdm>>[], toolChoice: Function.ToolChoice<fdm>): void;
|
|
46
|
+
function stateless<fdm extends Function.Declaration.Map>(this: CompatibleEngine.Underhood<fdm>, wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
47
|
+
function stateful<fdm extends Function.Declaration.Map>(this: CompatibleEngine.Underhood<fdm>, wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
48
|
+
function appendUserMessage<fdm extends Function.Declaration.Map>(this: CompatibleEngine.Underhood<fdm>, session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
49
|
+
function pushUserMessage<fdm extends Function.Declaration.Map>(this: CompatibleEngine.Underhood<fdm>, session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
50
|
+
function validateToolCallsByToolChoice<fdm extends Function.Declaration.Map>(this: CompatibleEngine.Underhood<fdm>, toolCalls: Function.Call.Distributive<Function.Declaration.From<fdm>>[]): void;
|
|
56
51
|
}
|