@zimtsui/brainswitch 0.0.54 → 0.0.56
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/DEVELOPMENT.md +13 -14
- package/README.md +7 -14
- package/build/adaptor.d.ts +5 -5
- package/build/adaptor.js +16 -16
- package/build/adaptor.js.map +1 -1
- package/build/agentloop.d.ts +5 -5
- package/build/agentloop.js +4 -4
- package/build/agentloop.js.map +1 -1
- package/build/api-types/anthropic/billing.d.ts +12 -0
- package/build/api-types/anthropic/billing.js +15 -0
- package/build/api-types/anthropic/billing.js.map +1 -0
- package/build/api-types/anthropic/tool-codec.d.ts +17 -0
- package/build/api-types/anthropic/tool-codec.js +73 -0
- package/build/api-types/anthropic/tool-codec.js.map +1 -0
- package/build/api-types/google/billing.d.ts +12 -0
- package/build/api-types/google/billing.js +24 -0
- package/build/api-types/google/billing.js.map +1 -0
- package/build/api-types/google/restful-request.d.ts +8 -0
- package/build/api-types/google/restful-request.js +2 -0
- package/build/api-types/google/restful-request.js.map +1 -0
- package/build/api-types/google/tool-codec.d.ts +16 -0
- package/build/api-types/{google.js → google/tool-codec.js} +27 -26
- package/build/api-types/google/tool-codec.js.map +1 -0
- package/build/api-types/openai-chatcompletion/billing.d.ts +13 -0
- package/build/api-types/openai-chatcompletion/billing.js +16 -0
- package/build/api-types/openai-chatcompletion/billing.js.map +1 -0
- package/build/api-types/openai-chatcompletion/tool-codec.d.ts +18 -0
- package/build/api-types/openai-chatcompletion/tool-codec.js +86 -0
- package/build/api-types/openai-chatcompletion/tool-codec.js.map +1 -0
- package/build/api-types/openai-responses/billing.d.ts +12 -0
- package/build/api-types/openai-responses/billing.js +15 -0
- package/build/api-types/openai-responses/billing.js.map +1 -0
- package/build/api-types/openai-responses/tool-codec.d.ts +16 -0
- package/build/api-types/openai-responses/tool-codec.js +72 -0
- package/build/api-types/openai-responses/tool-codec.js.map +1 -0
- package/build/compatible/engine.d/aliyun.d.ts +23 -0
- package/build/compatible/engine.d/aliyun.js +44 -0
- package/build/compatible/engine.d/aliyun.js.map +1 -0
- package/build/compatible/engine.d/anthropic.d.ts +23 -0
- package/build/compatible/engine.d/anthropic.js +41 -0
- package/build/compatible/engine.d/anthropic.js.map +1 -0
- package/build/compatible/engine.d/google.d.ts +23 -0
- package/build/compatible/engine.d/google.js +45 -0
- package/build/compatible/engine.d/google.js.map +1 -0
- package/build/compatible/engine.d/openai-responses.d.ts +23 -0
- package/build/compatible/engine.d/openai-responses.js +41 -0
- package/build/compatible/engine.d/openai-responses.js.map +1 -0
- package/build/compatible/engine.d.ts +18 -0
- package/build/compatible/engine.js +21 -0
- package/build/compatible/engine.js.map +1 -0
- package/build/compatible/session.d.ts +78 -0
- package/build/compatible/session.js +138 -0
- package/build/compatible/session.js.map +1 -0
- package/build/compatible/tool-call-validator.d.ts +11 -0
- package/build/compatible/tool-call-validator.js +12 -0
- package/build/compatible/tool-call-validator.js.map +1 -0
- package/build/compatible.d/aliyun/transport.d.ts +11 -0
- package/build/compatible.d/aliyun/transport.js +9 -0
- package/build/compatible.d/aliyun/transport.js.map +1 -0
- package/build/compatible.d/anthropic/message-codec.d.ts +31 -0
- package/build/compatible.d/anthropic/message-codec.js +88 -0
- package/build/compatible.d/anthropic/message-codec.js.map +1 -0
- package/build/compatible.d/anthropic/transport.d.ts +31 -0
- package/build/compatible.d/anthropic/transport.js +137 -0
- package/build/compatible.d/anthropic/transport.js.map +1 -0
- package/build/compatible.d/google/message-codec.d.ts +31 -0
- package/build/compatible.d/google/message-codec.js +98 -0
- package/build/compatible.d/google/message-codec.js.map +1 -0
- package/build/compatible.d/google/transport.d.ts +28 -0
- package/build/compatible.d/google/transport.js +74 -0
- package/build/compatible.d/google/transport.js.map +1 -0
- package/build/compatible.d/openai-chatcompletions/message-codec.d.ts +19 -0
- package/build/compatible.d/openai-chatcompletions/message-codec.js +66 -0
- package/build/compatible.d/openai-chatcompletions/message-codec.js.map +1 -0
- package/build/compatible.d/openai-chatcompletions/transport.d.ts +9 -0
- package/build/compatible.d/openai-chatcompletions/transport.js +25 -0
- package/build/compatible.d/openai-chatcompletions/transport.js.map +1 -0
- package/build/compatible.d/openai-chatcompletions.d/monolith.d.ts +36 -0
- package/build/compatible.d/openai-chatcompletions.d/monolith.js +74 -0
- package/build/compatible.d/openai-chatcompletions.d/monolith.js.map +1 -0
- package/build/compatible.d/openai-chatcompletions.d/stream.d.ts +35 -0
- package/build/{compatible-engines.d → compatible.d}/openai-chatcompletions.d/stream.js +52 -42
- package/build/compatible.d/openai-chatcompletions.d/stream.js.map +1 -0
- package/build/compatible.d/openai-responses/message-codec.d.ts +32 -0
- package/build/compatible.d/openai-responses/message-codec.js +105 -0
- package/build/compatible.d/openai-responses/message-codec.js.map +1 -0
- package/build/compatible.d/openai-responses/transport.d.ts +33 -0
- package/build/compatible.d/openai-responses/transport.js +88 -0
- package/build/compatible.d/openai-responses/transport.js.map +1 -0
- package/build/config.js +1 -1
- package/build/config.js.map +1 -1
- package/build/engine.d.ts +48 -26
- package/build/engine.js +78 -29
- package/build/engine.js.map +1 -1
- package/build/exports.d.ts +14 -13
- package/build/exports.js +14 -13
- package/build/exports.js.map +1 -1
- package/build/function.d.ts +25 -13
- package/build/function.js +2 -1
- package/build/function.js.map +1 -1
- package/build/inference-context.d.ts +1 -1
- package/build/native-engines.d/google/agentloop.d.ts +6 -6
- package/build/native-engines.d/google/agentloop.js +5 -5
- package/build/native-engines.d/google/agentloop.js.map +1 -1
- package/build/native-engines.d/google/engine.d.ts +28 -103
- package/build/native-engines.d/google/engine.js +63 -304
- package/build/native-engines.d/google/engine.js.map +1 -1
- package/build/native-engines.d/google/exports.d.ts +5 -5
- package/build/native-engines.d/google/exports.js +5 -5
- package/build/native-engines.d/google/exports.js.map +1 -1
- package/build/native-engines.d/google/message-codec.d.ts +21 -0
- package/build/native-engines.d/google/message-codec.js +69 -0
- package/build/native-engines.d/google/message-codec.js.map +1 -0
- package/build/native-engines.d/google/session.d.ts +16 -15
- package/build/native-engines.d/google/session.js +2 -2
- package/build/native-engines.d/google/session.js.map +1 -1
- package/build/native-engines.d/google/transport.d.ts +31 -0
- package/build/native-engines.d/google/transport.js +81 -0
- package/build/native-engines.d/google/transport.js.map +1 -0
- package/build/native-engines.d/openai-responses/agentloop.d.ts +7 -7
- package/build/native-engines.d/openai-responses/agentloop.js +6 -6
- package/build/native-engines.d/openai-responses/agentloop.js.map +1 -1
- package/build/native-engines.d/openai-responses/engine.d.ts +26 -106
- package/build/native-engines.d/openai-responses/engine.js +53 -334
- package/build/native-engines.d/openai-responses/engine.js.map +1 -1
- package/build/native-engines.d/openai-responses/exports.d.ts +6 -7
- package/build/native-engines.d/openai-responses/exports.js +6 -7
- package/build/native-engines.d/openai-responses/exports.js.map +1 -1
- package/build/native-engines.d/openai-responses/message-codec.d.ts +21 -0
- package/build/native-engines.d/openai-responses/message-codec.js +69 -0
- package/build/native-engines.d/openai-responses/message-codec.js.map +1 -0
- package/build/native-engines.d/openai-responses/session.d.ts +27 -26
- package/build/native-engines.d/openai-responses/session.js +3 -3
- package/build/native-engines.d/openai-responses/session.js.map +1 -1
- package/build/native-engines.d/openai-responses/tool-call-validator.d.ts +12 -0
- package/build/native-engines.d/openai-responses/tool-call-validator.js +33 -0
- package/build/native-engines.d/openai-responses/tool-call-validator.js.map +1 -0
- package/build/native-engines.d/openai-responses/tool.d.ts +3 -3
- package/build/native-engines.d/openai-responses/tool.js +1 -1
- package/build/native-engines.d/openai-responses/tool.js.map +1 -1
- package/build/native-engines.d/openai-responses/transport.d.ts +36 -0
- package/build/native-engines.d/openai-responses/transport.js +104 -0
- package/build/native-engines.d/openai-responses/transport.js.map +1 -0
- package/build/session.d.ts +5 -75
- package/build/session.js +0 -136
- package/build/session.js.map +1 -1
- package/build/throttle.d.ts +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/test/build/test-codecs.js +230 -0
- package/test/build/test-codecs.js.map +1 -0
- package/test/build/test-compatible-engine.d.ts +1 -0
- package/test/build/test-compatible-engine.js +27 -0
- package/test/build/test-compatible-engine.js.map +1 -0
- package/test/build/test-compatible-engines.d.ts +1 -0
- package/test/build/test-compatible-engines.js +112 -0
- package/test/build/test-compatible-engines.js.map +1 -0
- package/test/build/test-engine.d.ts +1 -0
- package/test/build/test-engine.js +97 -0
- package/test/build/test-engine.js.map +1 -0
- package/test/build/test-helpers.d.ts +46 -0
- package/test/build/test-helpers.js +45 -0
- package/test/build/test-helpers.js.map +1 -0
- package/test/build/test-native-engines.d.ts +1 -0
- package/test/build/test-native-engines.js +64 -0
- package/test/build/test-native-engines.js.map +1 -0
- package/test/build/test.d.ts +5 -0
- package/test/build/test.js +6 -0
- package/test/build/test.js.map +1 -0
- package/test/build/tsconfig.tsbuildinfo +1 -0
- package/test/src/test-codecs.ts +256 -0
- package/test/src/test-compatible-engine.ts +45 -0
- package/test/src/test-compatible-engines.ts +129 -0
- package/test/src/test-engine.ts +144 -0
- package/test/src/test-helpers.ts +53 -0
- package/test/src/test-native-engines.ts +75 -0
- package/test/src/test.ts +5 -0
- package/test/src/tsconfig.json +30 -0
- package/build/api-types/anthropic.d.ts +0 -29
- package/build/api-types/anthropic.js +0 -93
- package/build/api-types/anthropic.js.map +0 -1
- package/build/api-types/google.d.ts +0 -28
- package/build/api-types/google.js.map +0 -1
- package/build/api-types/openai-chat-completions.d.ts +0 -31
- package/build/api-types/openai-chat-completions.js +0 -113
- package/build/api-types/openai-chat-completions.js.map +0 -1
- package/build/api-types/openai-responses.d.ts +0 -23
- package/build/api-types/openai-responses.js +0 -71
- package/build/api-types/openai-responses.js.map +0 -1
- package/build/compatible-engine.d.ts +0 -51
- package/build/compatible-engine.js +0 -67
- package/build/compatible-engine.js.map +0 -1
- package/build/compatible-engines.d/aliyun.d.ts +0 -69
- package/build/compatible-engines.d/aliyun.js +0 -149
- package/build/compatible-engines.d/aliyun.js.map +0 -1
- package/build/compatible-engines.d/anthropic.d.ts +0 -78
- package/build/compatible-engines.d/anthropic.js +0 -312
- package/build/compatible-engines.d/anthropic.js.map +0 -1
- package/build/compatible-engines.d/google.d.ts +0 -83
- package/build/compatible-engines.d/google.js +0 -279
- package/build/compatible-engines.d/google.js.map +0 -1
- package/build/compatible-engines.d/openai-chatcompletions.d/monolith.d.ts +0 -15
- package/build/compatible-engines.d/openai-chatcompletions.d/monolith.js +0 -75
- package/build/compatible-engines.d/openai-chatcompletions.d/monolith.js.map +0 -1
- package/build/compatible-engines.d/openai-chatcompletions.d/stream.d.ts +0 -21
- package/build/compatible-engines.d/openai-chatcompletions.d/stream.js.map +0 -1
- package/build/compatible-engines.d/openai-chatcompletions.d.ts +0 -27
- package/build/compatible-engines.d/openai-chatcompletions.js +0 -76
- package/build/compatible-engines.d/openai-chatcompletions.js.map +0 -1
- package/build/compatible-engines.d/openai-responses.d.ts +0 -93
- package/build/compatible-engines.d/openai-responses.js +0 -300
- package/build/compatible-engines.d/openai-responses.js.map +0 -1
- package/build/test.js +0 -198
- package/build/test.js.map +0 -1
- /package/{build/test.d.ts → test/build/test-codecs.d.ts} +0 -0
package/build/engine.js
CHANGED
|
@@ -1,37 +1,86 @@
|
|
|
1
|
-
import { Function } from
|
|
2
|
-
import { EndpointSpec } from
|
|
3
|
-
import { Throttle } from
|
|
1
|
+
import { Function } from '#@/function.ts';
|
|
2
|
+
import { EndpointSpec } from '#@/endpoint-spec.ts';
|
|
3
|
+
import { Throttle } from '#@/throttle.ts';
|
|
4
4
|
import { ProxyAgent } from 'undici';
|
|
5
5
|
import { env } from 'node:process';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
import {} from '#@/inference-context.ts';
|
|
7
|
+
import { logger } from '#@/telemetry.ts';
|
|
8
|
+
import {} from '#@/session.ts';
|
|
9
|
+
export class Engine {
|
|
10
|
+
providerSpec;
|
|
11
|
+
inferenceParams;
|
|
12
|
+
name;
|
|
13
|
+
pricing;
|
|
14
|
+
fdm;
|
|
15
|
+
throttle;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
const proxyUrl = env.https_proxy || env.HTTPS_PROXY;
|
|
18
|
+
this.providerSpec = {
|
|
19
|
+
baseUrl: options.baseUrl,
|
|
20
|
+
apiKey: options.apiKey,
|
|
21
|
+
proxyAgent: proxyUrl ? new ProxyAgent(proxyUrl) : undefined,
|
|
22
|
+
};
|
|
23
|
+
this.name = options.name;
|
|
24
|
+
this.inferenceParams = {
|
|
25
|
+
model: options.model,
|
|
26
|
+
additionalOptions: options.additionalOptions,
|
|
27
|
+
timeout: options.timeout,
|
|
28
|
+
maxTokens: options.maxTokens,
|
|
29
|
+
};
|
|
30
|
+
const inputPrice = options.inputPrice ?? 0;
|
|
31
|
+
this.pricing = {
|
|
32
|
+
inputPrice,
|
|
33
|
+
outputPrice: options.outputPrice ?? 0,
|
|
34
|
+
cachePrice: options.cachePrice ?? inputPrice,
|
|
35
|
+
};
|
|
36
|
+
this.fdm = options.functionDeclarationMap;
|
|
37
|
+
this.throttle = options.throttle;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @throws {@link UserAbortion} 用户中止
|
|
41
|
+
* @throws {@link InferenceTimeout} 推理超时
|
|
42
|
+
* @throws {@link ResponseInvalid} 模型抽风
|
|
43
|
+
* @throws {TypeError} 网络故障
|
|
44
|
+
*/
|
|
45
|
+
async stateless(wfctx, session) {
|
|
46
|
+
for (let retry = 0;; retry++) {
|
|
47
|
+
const signalTimeout = this.inferenceParams.timeout ? AbortSignal.timeout(this.inferenceParams.timeout) : undefined;
|
|
48
|
+
const signal = wfctx.signal && signalTimeout ? AbortSignal.any([
|
|
49
|
+
wfctx.signal,
|
|
50
|
+
signalTimeout,
|
|
51
|
+
]) : wfctx.signal || signalTimeout;
|
|
52
|
+
try {
|
|
53
|
+
return await this.infer(wfctx, session, signal);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
if (wfctx.signal?.aborted)
|
|
57
|
+
throw new UserAbortion(); // 用户中止
|
|
58
|
+
else if (signalTimeout?.aborted)
|
|
59
|
+
e = new InferenceTimeout(undefined, { cause: e }); // 推理超时
|
|
60
|
+
else if (e instanceof ResponseInvalid) { } // 模型抽风
|
|
61
|
+
else if (e instanceof TypeError) { } // 网络故障
|
|
62
|
+
else
|
|
63
|
+
throw e;
|
|
64
|
+
if (retry < 3)
|
|
65
|
+
logger.message.warn(e);
|
|
66
|
+
else
|
|
67
|
+
throw e;
|
|
68
|
+
}
|
|
28
69
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @param session mutable
|
|
73
|
+
*/
|
|
74
|
+
async stateful(wfctx, session) {
|
|
75
|
+
const response = await this.stateless(wfctx, session);
|
|
76
|
+
session.chatMessages.push(response);
|
|
77
|
+
return response;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
32
80
|
export class ResponseInvalid extends Error {
|
|
33
81
|
}
|
|
34
|
-
export
|
|
82
|
+
export class UserAbortion {
|
|
83
|
+
}
|
|
35
84
|
export class InferenceTimeout extends Error {
|
|
36
85
|
}
|
|
37
86
|
//# sourceMappingURL=engine.js.map
|
package/build/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MA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M,MAAM,CAAC,CAAC;YACxD,CAAC;QACL,CAAC;IACL,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,QAAQ,CACjB,KAAuB,EACvB,OAAgB;QAEhB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACtD,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,OAAO,QAAQ,CAAC;IACpB,CAAC;CAcJ;AAcD,MAAM,OAAO,eAAgB,SAAQ,KAAK;CAAG;AAC7C,MAAM,OAAO,YAAY;CAAG;AAC5B,MAAM,OAAO,gBAAiB,SAAQ,KAAK;CAAG"}
|
package/build/exports.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from '
|
|
3
|
-
export * from '
|
|
4
|
-
export * from '
|
|
5
|
-
export * from '
|
|
6
|
-
export * from '
|
|
7
|
-
export * from '
|
|
8
|
-
export * from '
|
|
9
|
-
export * from '
|
|
10
|
-
export * from '
|
|
11
|
-
export * from '
|
|
12
|
-
export * from '
|
|
13
|
-
export * from '
|
|
1
|
+
export * from '#@/adaptor.ts';
|
|
2
|
+
export * from '#@/throttle.ts';
|
|
3
|
+
export * from '#@/session.ts';
|
|
4
|
+
export * from '#@/compatible/session.ts';
|
|
5
|
+
export * from '#@/compatible/engine.ts';
|
|
6
|
+
export * from '#@/function.ts';
|
|
7
|
+
export * from '#@/config.ts';
|
|
8
|
+
export * from '#@/inference-context.ts';
|
|
9
|
+
export * from '#@/endpoint-spec.ts';
|
|
10
|
+
export * from '#@/agentloop.ts';
|
|
11
|
+
export * from '#@/engine.ts';
|
|
12
|
+
export * from '#@/compatible/engine.ts';
|
|
13
|
+
export * from '#@/frontmatter.ts';
|
|
14
|
+
export * from '#@/telemetry.ts';
|
package/build/exports.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
1
|
+
export * from '#@/adaptor.ts';
|
|
2
|
+
export * from '#@/throttle.ts';
|
|
3
|
+
export * from '#@/session.ts';
|
|
4
|
+
export * from '#@/compatible/session.ts';
|
|
5
|
+
export * from '#@/compatible/engine.ts';
|
|
6
|
+
export * from '#@/function.ts';
|
|
7
|
+
export * from '#@/config.ts';
|
|
8
|
+
export * from '#@/inference-context.ts';
|
|
9
|
+
export * from '#@/endpoint-spec.ts';
|
|
10
|
+
export * from '#@/agentloop.ts';
|
|
11
|
+
export * from '#@/engine.ts';
|
|
12
|
+
export * from '#@/compatible/engine.ts';
|
|
13
|
+
export * from '#@/frontmatter.ts';
|
|
14
|
+
export * from '#@/telemetry.ts';
|
|
14
15
|
//# sourceMappingURL=exports.js.map
|
package/build/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
package/build/function.d.ts
CHANGED
|
@@ -33,20 +33,26 @@ export declare namespace Function {
|
|
|
33
33
|
name: fd['name'];
|
|
34
34
|
args: Static<fd['paraschema']>;
|
|
35
35
|
private constructor();
|
|
36
|
-
static create<
|
|
37
|
-
static restore<
|
|
38
|
-
static capture<
|
|
36
|
+
static create<fdm extends Declaration.Map>(fc: Call.create.Options<fdm>): Call.From<fdm>;
|
|
37
|
+
static restore<fdm extends Declaration.Map>(snapshot: Call.Snapshot.Distributive<fdm>): Call.From<fdm>;
|
|
38
|
+
static capture<fdm extends Declaration.Map>(fc: Call.From<fdm>): Call.Snapshot.Distributive<fdm>;
|
|
39
39
|
}
|
|
40
40
|
namespace Call {
|
|
41
|
+
type From<fdm extends Declaration.Map> = {
|
|
42
|
+
[name in Declaration.Map.NameOf<fdm>]: Call<Declaration.From<fdm, name>>;
|
|
43
|
+
}[Declaration.Map.NameOf<fdm>];
|
|
41
44
|
type Snapshot<fd extends Declaration> = Omit<Call<fd>, never>;
|
|
42
45
|
namespace Snapshot {
|
|
43
|
-
type Distributive<
|
|
46
|
+
type Distributive<fdm extends Declaration.Map> = {
|
|
47
|
+
[name in Declaration.Map.NameOf<fdm>]: Snapshot<Declaration.From<fdm, name>>;
|
|
48
|
+
}[Declaration.Map.NameOf<fdm>];
|
|
44
49
|
}
|
|
45
|
-
type Distributive<fdu extends Declaration> = fdu extends infer fd extends Declaration ? Call<fd> : never;
|
|
46
50
|
namespace create {
|
|
47
|
-
type Options<
|
|
51
|
+
type Options<fdm extends Declaration.Map> = {
|
|
52
|
+
[name in Declaration.Map.NameOf<fdm>]: Omit<Call<Declaration.From<fdm, name>>, never>;
|
|
53
|
+
}[Declaration.Map.NameOf<fdm>];
|
|
48
54
|
}
|
|
49
|
-
function validate<fdm extends Function.Declaration.Map>(toolCalls: Function.Call.
|
|
55
|
+
function validate<fdm extends Function.Declaration.Map>(toolCalls: Function.Call.From<fdm>[], toolChoice: Function.ToolChoice<fdm>, e: Error): void;
|
|
50
56
|
}
|
|
51
57
|
class Response<in out fd extends Declaration> {
|
|
52
58
|
static readonly NOMINAL: unique symbol;
|
|
@@ -55,18 +61,24 @@ export declare namespace Function {
|
|
|
55
61
|
name: fd['name'];
|
|
56
62
|
text: string;
|
|
57
63
|
private constructor();
|
|
58
|
-
static create<
|
|
59
|
-
static capture<
|
|
60
|
-
static restore<
|
|
64
|
+
static create<fdm extends Declaration.Map>(fr: Response.create.Options<fdm>): Response.Distributive<fdm>;
|
|
65
|
+
static capture<fdm extends Declaration.Map>(response: Response.Distributive<fdm>): Response.Snapshot.Distributive<fdm>;
|
|
66
|
+
static restore<fdm extends Declaration.Map>(snapshot: Response.Snapshot.Distributive<fdm>): Response.Distributive<fdm>;
|
|
61
67
|
}
|
|
62
68
|
namespace Response {
|
|
63
69
|
type Snapshot<fd extends Declaration> = Omit<Response<fd>, never>;
|
|
64
70
|
namespace Snapshot {
|
|
65
|
-
type Distributive<
|
|
71
|
+
type Distributive<fdm extends Declaration.Map> = {
|
|
72
|
+
[name in Declaration.Map.NameOf<fdm>]: Snapshot<Declaration.From<fdm, name>>;
|
|
73
|
+
}[Declaration.Map.NameOf<fdm>];
|
|
66
74
|
}
|
|
67
|
-
type Distributive<
|
|
75
|
+
type Distributive<fdm extends Declaration.Map> = {
|
|
76
|
+
[name in Declaration.Map.NameOf<fdm>]: Response<Declaration.From<fdm, name>>;
|
|
77
|
+
}[Declaration.Map.NameOf<fdm>];
|
|
68
78
|
namespace create {
|
|
69
|
-
type Options<
|
|
79
|
+
type Options<fdm extends Declaration.Map> = {
|
|
80
|
+
[name in Declaration.Map.NameOf<fdm>]: Omit<Response<Declaration.From<fdm, name>>, never>;
|
|
81
|
+
}[Declaration.Map.NameOf<fdm>];
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
84
|
type ToolChoice<fdm extends Function.Declaration.Map> = Function.Declaration.Map.NameOf<fdm>[] | typeof ToolChoice.NONE | typeof ToolChoice.REQUIRED | typeof ToolChoice.AUTO;
|
package/build/function.js
CHANGED
|
@@ -29,10 +29,11 @@ export var Function;
|
|
|
29
29
|
else
|
|
30
30
|
throw e;
|
|
31
31
|
else if (toolChoice instanceof Array)
|
|
32
|
-
for (const fc of toolCalls)
|
|
32
|
+
for (const fc of toolCalls) {
|
|
33
33
|
if (toolChoice.includes(fc.name)) { }
|
|
34
34
|
else
|
|
35
35
|
throw e;
|
|
36
|
+
}
|
|
36
37
|
else if (toolChoice === Function.ToolChoice.NONE)
|
|
37
38
|
if (!toolCalls.length) { }
|
|
38
39
|
else
|
package/build/function.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sourceRoot":"","sources":["../src/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,MAAM,mBAAmB,CAAC;AAO9D,MAAM,KAAW,QAAQ,
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../src/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,MAAM,mBAAmB,CAAC;AAO9D,MAAM,KAAW,QAAQ,CAoIxB;AApID,WAAiB,QAAQ;IA4BrB,MAAa,IAAI;QACN,MAAM,CAAU,OAAO,GAAG,MAAM,EAAE,CAAC;QAEnC,EAAE,CAAU;QACZ,IAAI,CAAa;QACjB,IAAI,CAA2B;QACtC,YAAoB,EAAyB;YACzC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;QACxB,CAAC;QACM,MAAM,CAAC,MAAM,CAA8B,EAA4B;YAC1E,OAAO,IAAI,IAAI,CAAC,EAAE,CAAmB,CAAC;QAC1C,CAAC;QACM,MAAM,CAAC,OAAO,CAA8B,QAAyC;YACxF,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAmB,CAAC;QAChD,CAAC;QACM,MAAM,CAAC,OAAO,CAA8B,EAAkB;Y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;QACM,MAAM,CAAC,OAAO,CAA8B,QAA6C;YAC5F,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAA+B,CAAC;QAChE,CAAC;;IAnBQ,iBAAQ,WAoBpB,CAAA;IAuBD,IAAiB,UAAU,CAI1B;IAJD,WAAiB,UAAU;QACV,eAAI,GAAG,MAAM,EAAE,CAAC;QAChB,mBAAQ,GAAG,MAAM,EAAE,CAAC;QACpB,eAAI,GAAG,MAAM,EAAE,CAAC;IACjC,CAAC,EAJgB,UAAU,GAAV,mBAAU,KAAV,mBAAU,QAI1B;AAKL,CAAC,EApIgB,QAAQ,KAAR,QAAQ,QAoIxB"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { type InferenceContext } from '
|
|
2
|
-
import { type Session } from '
|
|
3
|
-
import { Function } from '
|
|
4
|
-
import { type GoogleNativeEngine } from '
|
|
5
|
-
import * as CompatibleAgentloopModule from '
|
|
1
|
+
import { type InferenceContext } from '#@/inference-context.ts';
|
|
2
|
+
import { type Session } from '#@/native-engines.d/google/session.ts';
|
|
3
|
+
import { Function } from '#@/function.ts';
|
|
4
|
+
import { type GoogleNativeEngine } from '#@/native-engines.d/google/engine.ts';
|
|
5
|
+
import * as CompatibleAgentloopModule from '#@/agentloop.ts';
|
|
6
6
|
/**
|
|
7
7
|
* @param session mutable
|
|
8
8
|
*/
|
|
9
|
-
export declare function agentloop<fdm extends Function.Declaration.Map>(wfctx: InferenceContext, session: Session<
|
|
9
|
+
export declare function agentloop<fdm extends Function.Declaration.Map>(wfctx: InferenceContext, session: Session<fdm>, engine: GoogleNativeEngine<fdm>, fnm: Function.Map<fdm>, limit?: number): AsyncGenerator<string, string, void>;
|
|
10
10
|
export declare namespace agentloop {
|
|
11
11
|
export import FunctionCallLimitExceeded = CompatibleAgentloopModule.agentloop.FunctionCallLimitExceeded;
|
|
12
12
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {} from
|
|
2
|
-
import { RoleMessage } from
|
|
3
|
-
import { Function } from
|
|
4
|
-
import {} from
|
|
5
|
-
import * as CompatibleAgentloopModule from
|
|
1
|
+
import {} from '#@/inference-context.ts';
|
|
2
|
+
import { RoleMessage } from '#@/native-engines.d/google/session.ts';
|
|
3
|
+
import { Function } from '#@/function.ts';
|
|
4
|
+
import {} from '#@/native-engines.d/google/engine.ts';
|
|
5
|
+
import * as CompatibleAgentloopModule from '#@/agentloop.ts';
|
|
6
6
|
/**
|
|
7
7
|
* @param session mutable
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentloop.js","sourceRoot":"","sources":["../../../src/native-engines.d/google/agentloop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,MAAM,
|
|
1
|
+
{"version":3,"file":"agentloop.js","sourceRoot":"","sources":["../../../src/native-engines.d/google/agentloop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAgB,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAA2B,MAAM,sCAAsC,CAAC;AAC/E,OAAO,KAAK,yBAAyB,MAAM,iBAAiB,CAAC;AAG7D;;GAEG;AACH,MAAM,CAAC,KAAK,SAAU,CAAC,CAAA,SAAS,CAC5B,KAAuB,EACvB,OAAqB,EACrB,MAA+B,EAC/B,GAAsB,EACtB,KAAK,GAAG,MAAM,CAAC,iBAAiB;IAEhC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,GAAG,GAAG,QAAQ,CAAC,gBAAgB,EAAE,CAAC;QACxC,IAAI,CAAC,GAAG,CAAC,MAAM;YAAE,OAAO,QAAQ,CAAC,WAAW,EA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2
|
-
import { RoleMessage, type
|
|
3
|
-
import { Engine } from '
|
|
4
|
-
import { type InferenceContext } from '
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
pushUserMessage(session: Session<
|
|
1
|
+
import { Function } from '#@/function.ts';
|
|
2
|
+
import { RoleMessage, type Session } from '#@/native-engines.d/google/session.ts';
|
|
3
|
+
import { Engine } from '#@/engine.ts';
|
|
4
|
+
import { type InferenceContext } from '#@/inference-context.ts';
|
|
5
|
+
import { GoogleToolCodec } from '#@/api-types/google/tool-codec.ts';
|
|
6
|
+
import { GoogleBilling } from '#@/api-types/google/billing.ts';
|
|
7
|
+
import { ToolCallValidator } from '#@/compatible/tool-call-validator.ts';
|
|
8
|
+
import { GoogleCompatibleMessageCodec } from '#@/compatible.d/google/message-codec.ts';
|
|
9
|
+
import { GoogleNativeMessageCodec } from '#@/native-engines.d/google/message-codec.ts';
|
|
10
|
+
import { GoogleNativeTransport } from '#@/native-engines.d/google/transport.ts';
|
|
11
|
+
export declare class GoogleNativeEngine<in out fdm extends Function.Declaration.Map> extends Engine<fdm, RoleMessage.User<fdm>, RoleMessage.Ai<fdm>, RoleMessage.Developer, Session<fdm>> {
|
|
12
|
+
protected toolChoice: Function.ToolChoice<fdm>;
|
|
13
|
+
protected codeExecution: boolean;
|
|
14
|
+
protected urlContext: boolean;
|
|
15
|
+
protected googleSearch: boolean;
|
|
16
|
+
protected toolCodec: GoogleToolCodec<fdm>;
|
|
17
|
+
protected compatibleMessageCodec: GoogleCompatibleMessageCodec<fdm>;
|
|
18
|
+
protected messageCodec: GoogleNativeMessageCodec<fdm>;
|
|
19
|
+
protected billing: GoogleBilling;
|
|
20
|
+
protected toolCallValidator: ToolCallValidator<fdm>;
|
|
21
|
+
protected transport: GoogleNativeTransport<fdm>;
|
|
22
|
+
protected parallelToolCall: boolean;
|
|
23
|
+
constructor(options: GoogleNativeEngine.Options<fdm>);
|
|
24
|
+
protected infer(wfctx: InferenceContext, session: Session<fdm>, signal?: AbortSignal): Promise<RoleMessage.Ai<fdm>>;
|
|
25
|
+
appendUserMessage(session: Session<fdm>, message: RoleMessage.User<fdm>): Session<fdm>;
|
|
26
|
+
pushUserMessage(session: Session<fdm>, message: RoleMessage.User<fdm>): Session<fdm>;
|
|
27
27
|
}
|
|
28
28
|
export declare namespace GoogleNativeEngine {
|
|
29
|
-
interface Options<in out fdm extends Function.Declaration.Map> extends Engine.Options<fdm
|
|
29
|
+
interface Options<in out fdm extends Function.Declaration.Map> extends Engine.Options<fdm> {
|
|
30
|
+
toolChoice?: Function.ToolChoice<fdm>;
|
|
30
31
|
codeExecution?: boolean;
|
|
31
32
|
urlContext?: boolean;
|
|
32
33
|
googleSearch?: boolean;
|
|
33
34
|
}
|
|
34
|
-
interface OwnProps<in out fdm extends Function.Declaration.Map> {
|
|
35
|
-
apiURL: URL;
|
|
36
|
-
codeExecution: boolean;
|
|
37
|
-
urlContext: boolean;
|
|
38
|
-
googleSearch: boolean;
|
|
39
|
-
toolChoice: Function.ToolChoice<fdm>;
|
|
40
|
-
}
|
|
41
|
-
interface ParentUnderhood<in out fdm extends Function.Declaration.Map> extends Engine.Underhood<fdm>, GoogleEngine.Underhood<fdm> {
|
|
42
|
-
}
|
|
43
|
-
namespace OwnProps {
|
|
44
|
-
function init<fdm extends Function.Declaration.Map>(this: ParentUnderhood<fdm>, options: Options<fdm>): OwnProps<fdm>;
|
|
45
|
-
}
|
|
46
|
-
interface Underhood<in out fdm extends Function.Declaration.Map> extends ParentUnderhood<fdm>, GoogleNativeEngine<fdm>, OwnProps<fdm> {
|
|
47
|
-
stateless(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
48
|
-
stateful(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
49
|
-
convertFromUserMessage(userMessage: RoleMessage.User<Function.Declaration.From<fdm>>): Google.Content;
|
|
50
|
-
convertFromAiMessage(aiMessage: RoleMessage.Ai<Function.Declaration.From<fdm>>): Google.Content;
|
|
51
|
-
convertFromDeveloperMessage(developerMessage: RoleMessage.Developer): Google.Content;
|
|
52
|
-
convertFromChatMessages(chatMessages: ChatMessage<Function.Declaration.From<fdm>>[]): Google.Content[];
|
|
53
|
-
convertToAiMessage(content: Google.Content): RoleMessage.Ai<Function.Declaration.From<fdm>>;
|
|
54
|
-
convertFromToolChoice(toolChoice: Function.ToolChoice<fdm>): Google.FunctionCallingConfig;
|
|
55
|
-
appendUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
56
|
-
pushUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
57
|
-
fetch(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
58
|
-
validateToolCallsByToolChoice(toolCalls: Function.Call.Distributive<Function.Declaration.From<fdm>>[]): void;
|
|
59
|
-
}
|
|
60
|
-
function stateless<fdm extends Function.Declaration.Map>(this: GoogleNativeEngine.Underhood<fdm>, wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
61
|
-
function stateful<fdm extends Function.Declaration.Map>(this: GoogleNativeEngine.Underhood<fdm>, wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
62
|
-
function appendUserMessage<fdm extends Function.Declaration.Map>(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
63
|
-
function pushUserMessage<fdm extends Function.Declaration.Map>(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm>>;
|
|
64
|
-
function convertToAiMessage<fdm extends Function.Declaration.Map>(this: GoogleNativeEngine.Underhood<fdm>, content: Google.Content): RoleMessage.Ai<Function.Declaration.From<fdm>>;
|
|
65
|
-
function convertFromAiMessage<fdm extends Function.Declaration.Map>(aiMessage: RoleMessage.Ai<Function.Declaration.From<fdm>>): Google.Content;
|
|
66
|
-
function convertFromUserMessage<fdm extends Function.Declaration.Map>(this: Engine.Underhood<fdm>, userMessage: RoleMessage.User<Function.Declaration.From<fdm>>): Google.Content;
|
|
67
|
-
function convertFromDeveloperMessage<fdm extends Function.Declaration.Map>(this: Engine.Underhood<fdm>, developerMessage: RoleMessage.Developer): Google.Content;
|
|
68
|
-
function convertFromChatMessages<fdm extends Function.Declaration.Map>(this: GoogleNativeEngine.Underhood<fdm>, chatMessages: ChatMessage<Function.Declaration.From<fdm>>[]): Google.Content[];
|
|
69
|
-
function convertFromToolChoice<fdm extends Function.Declaration.Map>(this: Engine.Underhood<fdm>, toolChoice: Function.ToolChoice<fdm>): Google.FunctionCallingConfig;
|
|
70
|
-
function fetch<fdm extends Function.Declaration.Map>(this: GoogleNativeEngine.Underhood<fdm>, wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
71
|
-
function validateToolCallsByToolChoice<fdm extends Function.Declaration.Map>(this: GoogleNativeEngine.Underhood<fdm>, toolCalls: Function.Call.Distributive<Function.Declaration.From<fdm>>[]): void;
|
|
72
|
-
class Instance<in out fdm extends Function.Declaration.Map> implements GoogleNativeEngine.Underhood<fdm> {
|
|
73
|
-
baseUrl: string;
|
|
74
|
-
apiKey: string;
|
|
75
|
-
model: string;
|
|
76
|
-
name: string;
|
|
77
|
-
inputPrice: number;
|
|
78
|
-
outputPrice: number;
|
|
79
|
-
cachePrice: number;
|
|
80
|
-
fdm: fdm;
|
|
81
|
-
additionalOptions?: Record<string, unknown>;
|
|
82
|
-
throttle: Throttle;
|
|
83
|
-
timeout?: number;
|
|
84
|
-
maxTokens?: number;
|
|
85
|
-
proxyAgent?: Undici.ProxyAgent;
|
|
86
|
-
parallelToolCall: boolean;
|
|
87
|
-
apiURL: URL;
|
|
88
|
-
codeExecution: boolean;
|
|
89
|
-
urlContext: boolean;
|
|
90
|
-
googleSearch: boolean;
|
|
91
|
-
toolChoice: Function.ToolChoice<fdm>;
|
|
92
|
-
constructor(options: GoogleNativeEngine.Options<fdm>);
|
|
93
|
-
stateless(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
94
|
-
stateful(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
95
|
-
appendUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>;
|
|
96
|
-
pushUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>;
|
|
97
|
-
validateToolCallsByToolChoice(toolCalls: Function.Call.Distributive<Function.Declaration.From<fdm>>[]): void;
|
|
98
|
-
convertFromFunctionCall(fc: Function.Call.Distributive<Function.Declaration.From<fdm>>): Google.FunctionCall;
|
|
99
|
-
convertToFunctionCall(googlefc: Google.FunctionCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
100
|
-
convertFromFunctionDeclarationEntry(fdentry: Function.Declaration.Entry.From<fdm>): Google.FunctionDeclaration;
|
|
101
|
-
convertFromUserMessage(userMessage: RoleMessage.User<Function.Declaration.From<fdm>>): Google.Content;
|
|
102
|
-
convertFromAiMessage(aiMessage: RoleMessage.Ai<Function.Declaration.From<fdm>>): Google.Content;
|
|
103
|
-
convertFromDeveloperMessage(developerMessage: RoleMessage.Developer): Google.Content;
|
|
104
|
-
convertFromChatMessages(chatMessages: ChatMessage<Function.Declaration.From<fdm>>[]): Google.Content[];
|
|
105
|
-
convertToAiMessage(content: Google.Content): RoleMessage.Ai<Function.Declaration.From<fdm>>;
|
|
106
|
-
convertFromToolChoice(toolChoice: Function.ToolChoice<fdm>): Google.FunctionCallingConfig;
|
|
107
|
-
fetch(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
108
|
-
}
|
|
109
|
-
function create<fdm extends Function.Declaration.Map>(options: GoogleNativeEngine.Options<fdm>): GoogleNativeEngine<fdm>;
|
|
110
35
|
}
|