@zimtsui/typechat 0.0.135 → 0.0.137
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/build/adaptor.d.ts +13 -5
- package/build/adaptor.js +22 -18
- package/build/adaptor.js.map +1 -1
- package/build/assets.js +1 -1
- package/build/assets.js.map +1 -1
- package/build/config.d.ts +35 -2
- package/build/config.js +40 -2
- package/build/config.js.map +1 -1
- package/build/engine/exceptions.d.ts +7 -0
- package/build/engine/exceptions.js +7 -0
- package/build/engine/exceptions.js.map +1 -1
- package/build/engine/message-validator.js +0 -3
- package/build/engine/message-validator.js.map +1 -1
- package/build/engine.d.ts +4 -6
- package/build/engine.js +21 -78
- package/build/engine.js.map +1 -1
- package/build/engines/anthropic.d.ts +1 -1
- package/build/engines/anthropic.js +3 -2
- package/build/engines/anthropic.js.map +1 -1
- package/build/engines/google.d.ts +1 -2
- package/build/engines/google.js +2 -12
- package/build/engines/google.js.map +1 -1
- package/build/engines/openai-chatcompletions.d.ts +1 -1
- package/build/engines/openai-chatcompletions.js +4 -4
- package/build/engines/openai-chatcompletions.js.map +1 -1
- package/build/engines/openai-compatible/message-codec.js +1 -1
- package/build/engines/openai-compatible/message-codec.js.map +1 -1
- package/build/engines/openai-compatible.d.ts +1 -1
- package/build/engines/openai-compatible.js +3 -3
- package/build/engines/openai-compatible.js.map +1 -1
- package/build/engines/openai-responses/message-codec.js +1 -1
- package/build/engines/openai-responses/message-codec.js.map +1 -1
- package/build/engines/openai-responses.d.ts +1 -2
- package/build/engines/openai-responses.js +1 -12
- package/build/engines/openai-responses.js.map +1 -1
- package/build/exports.d.ts +0 -1
- package/build/exports.js +0 -1
- package/build/exports.js.map +1 -1
- package/build/repetition.d.ts +5 -0
- package/build/repetition.js +7 -0
- package/build/repetition.js.map +1 -1
- package/build/retry.d.ts +11 -0
- package/build/retry.js +31 -0
- package/build/retry.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -5
- package/build/endpoint-spec.d.ts +0 -20
- package/build/endpoint-spec.js +0 -27
- package/build/endpoint-spec.js.map +0 -1
package/build/adaptor.d.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import { Config } from './config.ts';
|
|
1
|
+
import { Config, Secret } from './config.ts';
|
|
2
2
|
import { Function } from './function.ts';
|
|
3
3
|
import { Throttle } from './throttle.ts';
|
|
4
4
|
import { Engine } from './engine.ts';
|
|
5
|
+
import { ToolChoice } from './tool-choice.ts';
|
|
5
6
|
export declare class Adaptor {
|
|
6
|
-
|
|
7
|
-
static create(config: Config): Adaptor;
|
|
7
|
+
static create(options: Adaptor.Options): Adaptor;
|
|
8
8
|
protected throttles: Map<string, Throttle>;
|
|
9
|
-
|
|
9
|
+
config: Config;
|
|
10
|
+
protected secret: Secret;
|
|
11
|
+
protected constructor(options: Adaptor.Options);
|
|
10
12
|
[Symbol.dispose](): void;
|
|
11
13
|
makeEngine<fdm extends Function.Decl.Map.Proto>(adaptorOptions: Adaptor.Params<fdm>): Engine<fdm>;
|
|
12
14
|
}
|
|
13
15
|
export declare namespace Adaptor {
|
|
14
|
-
interface Params<in out fdm extends Function.Decl.Map.Proto>
|
|
16
|
+
interface Params<in out fdm extends Function.Decl.Map.Proto> {
|
|
15
17
|
endpoint: string;
|
|
18
|
+
functionDeclarationMap: fdm;
|
|
19
|
+
toolChoice?: ToolChoice;
|
|
20
|
+
}
|
|
21
|
+
interface Options {
|
|
22
|
+
config: Config;
|
|
23
|
+
secret: Secret;
|
|
16
24
|
}
|
|
17
25
|
}
|
package/build/adaptor.js
CHANGED
|
@@ -5,13 +5,15 @@ import { OpenAIChatCompletionsEngine } from "./engines/openai-chatcompletions.js
|
|
|
5
5
|
import { AnthropicEngine } from "./engines/anthropic.js";
|
|
6
6
|
import { OpenAICompatibleEngine } from "./engines/openai-compatible.js";
|
|
7
7
|
export class Adaptor {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return new Adaptor(config);
|
|
8
|
+
static create(options) {
|
|
9
|
+
return new Adaptor(options);
|
|
11
10
|
}
|
|
12
11
|
throttles = new Map();
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
config;
|
|
13
|
+
secret;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.config = options.config;
|
|
16
|
+
this.secret = options.secret;
|
|
15
17
|
for (const endpointId in this.config.endpoints) {
|
|
16
18
|
const rpm = this.config.endpoints[endpointId].rpm ?? Number.POSITIVE_INFINITY;
|
|
17
19
|
this.throttles.set(endpointId, new Throttle(rpm));
|
|
@@ -22,8 +24,9 @@ export class Adaptor {
|
|
|
22
24
|
throttle.throw(new Error('Adaptor disposed'));
|
|
23
25
|
}
|
|
24
26
|
makeEngine(adaptorOptions) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
+
const endpointConfig = this.config.endpoints[adaptorOptions.endpoint];
|
|
28
|
+
const endpointSecret = this.secret.endpoints[adaptorOptions.endpoint];
|
|
29
|
+
if (endpointConfig && endpointSecret) { }
|
|
27
30
|
else
|
|
28
31
|
throw new Error();
|
|
29
32
|
const throttle = this.throttles.get(adaptorOptions.endpoint);
|
|
@@ -32,19 +35,20 @@ export class Adaptor {
|
|
|
32
35
|
throw new Error();
|
|
33
36
|
const options = {
|
|
34
37
|
...adaptorOptions,
|
|
35
|
-
|
|
38
|
+
endpointConfig,
|
|
39
|
+
endpointSecret,
|
|
36
40
|
throttle,
|
|
37
41
|
};
|
|
38
|
-
if (
|
|
39
|
-
return OpenAIResponsesEngine.
|
|
40
|
-
else if (
|
|
41
|
-
return GoogleEngine.
|
|
42
|
-
else if (
|
|
43
|
-
return AnthropicEngine.
|
|
44
|
-
else if (
|
|
45
|
-
return OpenAIChatCompletionsEngine.
|
|
46
|
-
else if (
|
|
47
|
-
return OpenAICompatibleEngine.
|
|
42
|
+
if (endpointConfig.apiType === 'openai-responses')
|
|
43
|
+
return OpenAIResponsesEngine.create(options);
|
|
44
|
+
else if (endpointConfig.apiType === 'google')
|
|
45
|
+
return GoogleEngine.create(options);
|
|
46
|
+
else if (endpointConfig.apiType === 'anthropic')
|
|
47
|
+
return AnthropicEngine.create(options);
|
|
48
|
+
else if (endpointConfig.apiType === 'openai-chatcompletions')
|
|
49
|
+
return OpenAIChatCompletionsEngine.create(options);
|
|
50
|
+
else if (endpointConfig.apiType === 'openai-compatible')
|
|
51
|
+
return OpenAICompatibleEngine.create(options);
|
|
48
52
|
else
|
|
49
53
|
throw new Error();
|
|
50
54
|
}
|
package/build/adaptor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../src/adaptor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../src/adaptor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAKxE,MAAM,OAAO,OAAO;IACT,MAAM,CAAC,MAAM,CAAC,OAAwB;QACzC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,C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cAAc;YACjB,cAAc;YACd,cAAc;YACd,QAAQ;SACX,CAAC;QACF,IAAI,cAAc,CAAC,OAAO,KAAK,kBAAkB;YAC7C,OAAO,qBAAqB,CAAC,MAAM,CAAM,OAAO,CAAC,CAAC;aACjD,IAAI,cAAc,CAAC,OAAO,KAAK,QAAQ;YACxC,OAAO,YAAY,CAAC,MAAM,CAAM,OAAO,CAAC,CAAC;aACxC,IAAI,cAAc,CAAC,OAAO,KAAK,WAAW;YAC3C,OAAO,eAAe,CAAC,MAAM,CAAM,OAAO,CAAC,CAAC;aAC3C,IAAI,cAAc,CAAC,OAAO,KAAK,wBAAwB;YACxD,OAAO,2BAA2B,CAAC,MAAM,CAAM,OAAO,CAAC,CAAC;aACvD,IAAI,cAAc,CAAC,OAAO,KAAK,mBAAmB;YACnD,OAAO,sBAAsB,CAAC,MAAM,CAAM,OAAO,CAAC,CAAC;;YAClD,MAAM,IAAI,KAAK,EAAE,CAAC;IAC3B,CAAC;CACJ"}
|
package/build/assets.js
CHANGED
package/build/assets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,eAAe;IACX,GAAG,EAAE;QACD,WAAW,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAC;QACzF,SAAS,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,oCAAoC,CAAC,CAAC,CAAC;QAC7F,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC,CAAC;KAC1F;CACK,CAAC"}
|
package/build/config.d.ts
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
import { Type, type Static } from 'typebox';
|
|
2
|
+
export declare namespace Endpoint {
|
|
3
|
+
type Config = Static<typeof Config.schema>;
|
|
4
|
+
namespace Config {
|
|
5
|
+
const schema: Type.TObject<{
|
|
6
|
+
baseUrl: Type.TString;
|
|
7
|
+
model: Type.TString;
|
|
8
|
+
name: Type.TString;
|
|
9
|
+
apiType: Type.TUnion<[Type.TLiteral<"openai-chatcompletions">, Type.TLiteral<"openai-responses">, Type.TLiteral<"google">, Type.TLiteral<"anthropic">, Type.TLiteral<"openai-compatible">]>;
|
|
10
|
+
inputPrice: Type.TOptional<Type.TNumber>;
|
|
11
|
+
outputPrice: Type.TOptional<Type.TNumber>;
|
|
12
|
+
cachePrice: Type.TOptional<Type.TNumber>;
|
|
13
|
+
parallelToolCall: Type.TOptional<Type.TBoolean>;
|
|
14
|
+
additionalHeaders: Type.TOptional<Type.TRecord<"^.*$", Type.TString>>;
|
|
15
|
+
additionalOptions: Type.TOptional<Type.TRecord<"^.*$", Type.TAny>>;
|
|
16
|
+
rpm: Type.TOptional<Type.TNumber>;
|
|
17
|
+
timeout: Type.TOptional<Type.TNumber>;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
type Secret = Static<typeof Secret.schema>;
|
|
21
|
+
namespace Secret {
|
|
22
|
+
const schema: Type.TObject<{
|
|
23
|
+
proxy: Type.TOptional<Type.TString>;
|
|
24
|
+
apiKey: Type.TString;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
2
28
|
export type Config = Static<typeof Config.schema>;
|
|
3
29
|
export declare namespace Config {
|
|
4
30
|
const schema: Type.TObject<{
|
|
5
31
|
endpoints: Type.TRecord<"^.*$", Type.TObject<{
|
|
6
32
|
baseUrl: Type.TString;
|
|
7
|
-
proxy: Type.TOptional<Type.TString>;
|
|
8
|
-
apiKey: Type.TString;
|
|
9
33
|
model: Type.TString;
|
|
10
34
|
name: Type.TString;
|
|
11
35
|
apiType: Type.TUnion<[Type.TLiteral<"openai-chatcompletions">, Type.TLiteral<"openai-responses">, Type.TLiteral<"google">, Type.TLiteral<"anthropic">, Type.TLiteral<"openai-compatible">]>;
|
|
@@ -20,3 +44,12 @@ export declare namespace Config {
|
|
|
20
44
|
}>>;
|
|
21
45
|
}>;
|
|
22
46
|
}
|
|
47
|
+
export type Secret = Static<typeof Secret.schema>;
|
|
48
|
+
export declare namespace Secret {
|
|
49
|
+
const schema: Type.TObject<{
|
|
50
|
+
endpoints: Type.TRecord<"^.*$", Type.TObject<{
|
|
51
|
+
proxy: Type.TOptional<Type.TString>;
|
|
52
|
+
apiKey: Type.TString;
|
|
53
|
+
}>>;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
package/build/config.js
CHANGED
|
@@ -1,9 +1,47 @@
|
|
|
1
1
|
import { Type } from 'typebox';
|
|
2
|
-
|
|
2
|
+
export var Endpoint;
|
|
3
|
+
(function (Endpoint) {
|
|
4
|
+
let Config;
|
|
5
|
+
(function (Config) {
|
|
6
|
+
Config.schema = Type.Object({
|
|
7
|
+
baseUrl: Type.String(),
|
|
8
|
+
model: Type.String(),
|
|
9
|
+
name: Type.String(),
|
|
10
|
+
apiType: Type.Union([
|
|
11
|
+
Type.Literal('openai-chatcompletions'),
|
|
12
|
+
Type.Literal('openai-responses'),
|
|
13
|
+
Type.Literal('google'),
|
|
14
|
+
Type.Literal('anthropic'),
|
|
15
|
+
Type.Literal('openai-compatible'),
|
|
16
|
+
]),
|
|
17
|
+
inputPrice: Type.Optional(Type.Number()),
|
|
18
|
+
outputPrice: Type.Optional(Type.Number()),
|
|
19
|
+
cachePrice: Type.Optional(Type.Number()),
|
|
20
|
+
parallelToolCall: Type.Optional(Type.Boolean()),
|
|
21
|
+
additionalHeaders: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
22
|
+
additionalOptions: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
23
|
+
rpm: Type.Optional(Type.Number({ minimum: 1 })),
|
|
24
|
+
timeout: Type.Optional(Type.Number({ minimum: 0 })),
|
|
25
|
+
});
|
|
26
|
+
})(Config = Endpoint.Config || (Endpoint.Config = {}));
|
|
27
|
+
let Secret;
|
|
28
|
+
(function (Secret) {
|
|
29
|
+
Secret.schema = Type.Object({
|
|
30
|
+
proxy: Type.Optional(Type.String()),
|
|
31
|
+
apiKey: Type.String(),
|
|
32
|
+
});
|
|
33
|
+
})(Secret = Endpoint.Secret || (Endpoint.Secret = {}));
|
|
34
|
+
})(Endpoint || (Endpoint = {}));
|
|
3
35
|
export var Config;
|
|
4
36
|
(function (Config) {
|
|
5
37
|
Config.schema = Type.Object({
|
|
6
|
-
endpoints: Type.Record(Type.String(),
|
|
38
|
+
endpoints: Type.Record(Type.String(), Endpoint.Config.schema),
|
|
7
39
|
});
|
|
8
40
|
})(Config || (Config = {}));
|
|
41
|
+
export var Secret;
|
|
42
|
+
(function (Secret) {
|
|
43
|
+
Secret.schema = Type.Object({
|
|
44
|
+
endpoints: Type.Record(Type.String(), Endpoint.Secret.schema),
|
|
45
|
+
});
|
|
46
|
+
})(Secret || (Secret = {}));
|
|
9
47
|
//# sourceMappingURL=config.js.map
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,SAAS,CAAC;AAG5C,MAAM,KAAW,QAAQ,CAkCxB;AAlCD,WAAiB,QAAQ;IAErB,IAAiB,MAAM,CAqBtB;IArBD,WAAiB,MAAM;QACN,aAAM,GAA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C,CAAC;IACP,CAAC,EArBgB,MAAM,GAAN,eAAM,KAAN,eAAM,QAqBtB;IAID,IAAiB,MAAM,CAKtB;IALD,WAAiB,MAAM;QACN,aAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC9B,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;SACxB,CAAC,CAAC;IACP,CAAC,EALgB,MAAM,GAAN,eAAM,KAAN,eAAM,QAKtB;AAEL,CAAC,EAlCgB,QAAQ,KAAR,QAAQ,QAkCxB;AAID,MAAM,KAAW,MAAM,CAItB;AAJD,WAAiB,MAAM;IACN,aAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;KAChE,CAAC,CAAC;AACP,CAAC,EAJgB,MAAM,KAAN,MAAM,QAItB;AAGD,MAAM,KAAW,MAAM,CAItB;AAJD,WAAiB,MAAM;IACN,aAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;KAChE,CAAC,CAAC;AACP,CAAC,EAJgB,MAAM,KAAN,MAAM,QAItB"}
|
|
@@ -17,6 +17,13 @@ export declare namespace InferenceError {
|
|
|
17
17
|
constructor(response: Message.Output<fdu>, rejection: Message.Input<fdu>, ...rest: ConstructorParameters<typeof InferenceError>);
|
|
18
18
|
resume(): Message.Output<fdu>;
|
|
19
19
|
recover(): Message.Input<fdu>;
|
|
20
|
+
/**
|
|
21
|
+
* Used only as stateful middleware
|
|
22
|
+
* @param wfctx
|
|
23
|
+
* @param session
|
|
24
|
+
* @param next
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
20
27
|
static recover<fdu extends Function.Decl.Proto, aim extends Message.Output<fdu>>(wfctx: InferenceContext, session: Session<fdu>, next: () => Promise<aim>): Promise<aim>;
|
|
21
28
|
}
|
|
22
29
|
}
|
|
@@ -21,6 +21,13 @@ export class InferenceError extends Error {
|
|
|
21
21
|
recover() {
|
|
22
22
|
return this.rejection;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Used only as stateful middleware
|
|
26
|
+
* @param wfctx
|
|
27
|
+
* @param session
|
|
28
|
+
* @param next
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
24
31
|
static async recover(wfctx, session, next) {
|
|
25
32
|
try {
|
|
26
33
|
return await next();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../src/engine/exceptions.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,yBAA0B,SAAQ,KAAK;CAAG;AACvD,MAAM,OAAO,gBAAiB,SAAQ,KAAK;CAAG;AAC9C,MAAM,OAAO,QAAS,SAAQ,KAAK;CAAG;AAEtC,MAAM,OAAO,cAAe,SAAQ,KAAK;CAAG;AAC5C,WAAiB,cAAc;IAC3B,MAAa,WAEX,SAAQ,cAAc;QAEN;QACA;QAFd,YACc,QAA6B,EAC7B,SAA6B,EACvC,GAAG,IAAkD;YAErD,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YAJL,aAAQ,GAAR,QAAQ,CAAqB;YAC7B,cAAS,GAAT,SAAS,CAAoB;QAI3C,CAAC;QACM,MAAM;YACT,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;QACM,OAAO;YACV,OAAO,IAAI,CAAC,SAAS,CAAC;QAC1B,CAAC;
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../src/engine/exceptions.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,yBAA0B,SAAQ,KAAK;CAAG;AACvD,MAAM,OAAO,gBAAiB,SAAQ,KAAK;CAAG;AAC9C,MAAM,OAAO,QAAS,SAAQ,KAAK;CAAG;AAEtC,MAAM,OAAO,cAAe,SAAQ,KAAK;CAAG;AAC5C,WAAiB,cAAc;IAC3B,MAAa,WAEX,SAAQ,cAAc;QAEN;QACA;QAFd,YACc,QAA6B,EAC7B,SAA6B,EACvC,GAAG,IAAkD;YAErD,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YAJL,aAAQ,GAAR,QAAQ,CAAqB;YAC7B,cAAS,GAAT,SAAS,CAAoB;QAI3C,CAAC;QACM,MAAM;YACT,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;QACM,OAAO;YACV,OAAO,IAAI,CAAC,SAAS,CAAC;QAC1B,CAAC;QAED;;;;;;WAMG;QACI,MAAM,CAAC,KAAK,CAAC,OAAO,CAIvB,KAAuB,EACvB,OAAqB,EACrB,IAAwB;YAExB,IAAI,CAAC;gBACD,OAAO,MAAM,IAAI,EAAE,CAAC;YACxB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,IAAI,CAAC,YAAY,WAAW,EAAE,CAAC,CAAA,CAAC;;oBAAM,MAAM,CAAC,CAAC;gBAC9C,MAAM,WAAW,GAAG,CAAqB,CAAC;gBAC1C,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;gBACvE,MAAM,CAAC,CAAC;YACZ,CAAC;QACL,CAAC;KACJ;IAzCY,0BAAW,cAyCvB,CAAA;AACL,CAAC,EA3CgB,cAAc,KAAd,cAAc,QA2C9B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Function } from "../function.js";
|
|
2
|
-
import { isRepeating } from "../repetition.js";
|
|
3
2
|
import * as Exceptions from "./exceptions.js";
|
|
4
3
|
import { Text } from "../text.js";
|
|
5
4
|
import { Media } from "../media.js";
|
|
@@ -8,8 +7,6 @@ export class MessageValidator {
|
|
|
8
7
|
if (message.parts.length) { }
|
|
9
8
|
else
|
|
10
9
|
throw new Exceptions.InferenceError('Empty message.');
|
|
11
|
-
if (isRepeating(message.joinText()))
|
|
12
|
-
throw new Exceptions.InferenceError('Repeating');
|
|
13
10
|
}
|
|
14
11
|
validateInputMessage(message) {
|
|
15
12
|
let i = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-validator.js","sourceRoot":"","sources":["../../src/engine/message-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,
|
|
1
|
+
{"version":3,"file":"message-validator.js","sourceRoot":"","sources":["../../src/engine/message-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,MAAM,OAAO,gBAAgB;IAIlB,qBAAqB,CACxB,OAA4B;QAE5B,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA,CAAC;;YAAM,MAAM,IAAI,UAAU,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAC5F,CAAC;IAEM,oBAAoB,CACvB,OAA2B;QAE3B,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;YAChC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAE,YAAY,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA,CAAC;;gBAAM,MAAM;QACtE,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;YAChC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAE,YAAY,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAE,YAAY,KAAK,EAAE,CAAC,CAAA,CAAC;;gBAAM,MAAM;QAC/F,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,EAAE,CAAC;IACpD,CAAC;CAEJ"}
|
package/build/engine.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Function } from './function.ts';
|
|
2
|
-
import { EndpointSpec } from './endpoint-spec.ts';
|
|
3
2
|
import { Throttle } from './throttle.ts';
|
|
4
3
|
import * as Undici from 'undici';
|
|
5
4
|
import { type InferenceContext } from './inference-context.ts';
|
|
5
|
+
import { Endpoint } from './config.ts';
|
|
6
6
|
import * as SessionModule from './engine/session.ts';
|
|
7
7
|
import * as MessageModule from './engine/message.ts';
|
|
8
8
|
import * as MessageValidatorModule from './engine/message-validator.ts';
|
|
@@ -20,7 +20,6 @@ export interface ProviderSpecs {
|
|
|
20
20
|
baseUrl: string;
|
|
21
21
|
apiKey: string;
|
|
22
22
|
dispatcher: Undici.Dispatcher;
|
|
23
|
-
retry: number;
|
|
24
23
|
}
|
|
25
24
|
export interface InferenceOptions {
|
|
26
25
|
model: string;
|
|
@@ -28,7 +27,6 @@ export interface InferenceOptions {
|
|
|
28
27
|
additionalOptions?: Record<string, unknown>;
|
|
29
28
|
parallelToolCall?: boolean;
|
|
30
29
|
timeout?: number;
|
|
31
|
-
retry: number;
|
|
32
30
|
}
|
|
33
31
|
export type Engine<fdm extends Function.Decl.Map.Proto> = Engine.Instance<fdm>;
|
|
34
32
|
export declare namespace Engine {
|
|
@@ -68,6 +66,7 @@ export declare namespace Engine {
|
|
|
68
66
|
useStateless(middleware: Middleware.From<fdm>): this;
|
|
69
67
|
protected middlewaresStateful: Middleware.From<fdm>[];
|
|
70
68
|
useStateful(middleware: Middleware.From<fdm>): this;
|
|
69
|
+
use(middleware: Middleware.From<fdm>): this;
|
|
71
70
|
protected compose(middlewares: Middleware.From<fdm>[]): Middleware.From<fdm>;
|
|
72
71
|
/**
|
|
73
72
|
* @param session mutable
|
|
@@ -76,11 +75,10 @@ export declare namespace Engine {
|
|
|
76
75
|
}
|
|
77
76
|
interface Options<in out fdm extends Function.Decl.Map.Proto> {
|
|
78
77
|
throttle: Throttle;
|
|
79
|
-
|
|
78
|
+
endpointConfig: Endpoint.Config;
|
|
79
|
+
endpointSecret: Endpoint.Secret;
|
|
80
80
|
functionDeclarationMap: fdm;
|
|
81
81
|
toolChoice?: ToolChoice;
|
|
82
|
-
providerRetry?: number;
|
|
83
|
-
inferenceRetry?: number;
|
|
84
82
|
}
|
|
85
83
|
interface Create {
|
|
86
84
|
<fdm extends Function.Decl.Map.Proto>(options: Engine.Options<fdm>): Engine<fdm>;
|
package/build/engine.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Function } from "./function.js";
|
|
2
2
|
import * as Undici from 'undici';
|
|
3
3
|
import { env } from 'node:process';
|
|
4
|
-
import { loggers } from "./telemetry.js";
|
|
5
4
|
import * as MessageModule from "./engine/message.js";
|
|
6
5
|
import * as MessageValidatorModule from "./engine/message-validator.js";
|
|
7
6
|
import * as ExceptionsModule from "./engine/exceptions.js";
|
|
@@ -21,7 +20,7 @@ export var Engine;
|
|
|
21
20
|
toolChoiceValidator;
|
|
22
21
|
messageValidator;
|
|
23
22
|
constructor(options) {
|
|
24
|
-
const proxyUrl = options.
|
|
23
|
+
const proxyUrl = options.endpointSecret.proxy || env.https_proxy || env.HTTPS_PROXY;
|
|
25
24
|
const dispatcher = proxyUrl
|
|
26
25
|
? new Undici.ProxyAgent({
|
|
27
26
|
uri: proxyUrl,
|
|
@@ -33,24 +32,22 @@ export var Engine;
|
|
|
33
32
|
bodyTimeout: 0,
|
|
34
33
|
});
|
|
35
34
|
this.providerSpecs = {
|
|
36
|
-
baseUrl: options.
|
|
37
|
-
apiKey: options.
|
|
35
|
+
baseUrl: options.endpointConfig.baseUrl,
|
|
36
|
+
apiKey: options.endpointSecret.apiKey,
|
|
38
37
|
dispatcher,
|
|
39
|
-
retry: options.providerRetry ?? 2,
|
|
40
38
|
};
|
|
41
|
-
this.name = options.
|
|
39
|
+
this.name = options.endpointConfig.name;
|
|
42
40
|
this.inferenceOptions = {
|
|
43
|
-
model: options.
|
|
44
|
-
additionalHeaders: options.
|
|
45
|
-
additionalOptions: options.
|
|
46
|
-
timeout: options.
|
|
47
|
-
parallelToolCall: options.
|
|
48
|
-
retry: options.inferenceRetry ?? 2,
|
|
41
|
+
model: options.endpointConfig.model,
|
|
42
|
+
additionalHeaders: options.endpointConfig.additionalHeaders,
|
|
43
|
+
additionalOptions: options.endpointConfig.additionalOptions,
|
|
44
|
+
timeout: options.endpointConfig.timeout,
|
|
45
|
+
parallelToolCall: options.endpointConfig.parallelToolCall,
|
|
49
46
|
};
|
|
50
47
|
this.pricing = {
|
|
51
|
-
inputPrice: options.
|
|
52
|
-
outputPrice: options.
|
|
53
|
-
cachePrice: options.
|
|
48
|
+
inputPrice: options.endpointConfig.inputPrice ?? 0,
|
|
49
|
+
outputPrice: options.endpointConfig.outputPrice ?? 0,
|
|
50
|
+
cachePrice: options.endpointConfig.cachePrice ?? options.endpointConfig.inputPrice ?? 0,
|
|
54
51
|
};
|
|
55
52
|
this.fdm = options.functionDeclarationMap;
|
|
56
53
|
this.toolChoice = options.toolChoice ?? ToolChoice.AUTO;
|
|
@@ -95,35 +92,7 @@ export var Engine;
|
|
|
95
92
|
*/
|
|
96
93
|
async stateless(wfctx, session) {
|
|
97
94
|
const middleware = this.compose(this.middlewaresStateless);
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
return await middleware(wfctx, session, () => this.infer(wfctx, session));
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
if (e instanceof Engine.Exceptions.InferenceTimeout) {
|
|
104
|
-
if (retryInference < this.inferenceOptions.retry) { }
|
|
105
|
-
else
|
|
106
|
-
throw e;
|
|
107
|
-
loggers.message.warn(e);
|
|
108
|
-
retryInference++;
|
|
109
|
-
}
|
|
110
|
-
else if (e instanceof Engine.Exceptions.InferenceError) {
|
|
111
|
-
if (retryInference < this.inferenceOptions.retry) { }
|
|
112
|
-
else
|
|
113
|
-
throw e;
|
|
114
|
-
loggers.message.warn(e);
|
|
115
|
-
retryInference++;
|
|
116
|
-
}
|
|
117
|
-
else if (e instanceof Engine.Exceptions.APIError) {
|
|
118
|
-
if (retryProvider < this.providerSpecs.retry) { }
|
|
119
|
-
else
|
|
120
|
-
throw e;
|
|
121
|
-
loggers.message.warn(e);
|
|
122
|
-
retryProvider++;
|
|
123
|
-
}
|
|
124
|
-
else
|
|
125
|
-
throw e;
|
|
126
|
-
}
|
|
95
|
+
return middleware(wfctx, session, () => this.infer(wfctx, session));
|
|
127
96
|
}
|
|
128
97
|
/**
|
|
129
98
|
* @throws {@link Exceptions.InferenceTimeout} 推理超时
|
|
@@ -133,40 +102,9 @@ export var Engine;
|
|
|
133
102
|
*/
|
|
134
103
|
async stateful(wfctx, session) {
|
|
135
104
|
const middleware = this.compose(this.middlewaresStateful);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const aiMessage = await this.infer(wfctx, session);
|
|
140
|
-
session.chatMessages.push(aiMessage);
|
|
141
|
-
return aiMessage;
|
|
142
|
-
};
|
|
143
|
-
return await middleware(wfctx, session, next);
|
|
144
|
-
}
|
|
145
|
-
catch (e) {
|
|
146
|
-
if (e instanceof Engine.Exceptions.InferenceTimeout) {
|
|
147
|
-
if (retryInference < this.inferenceOptions.retry) { }
|
|
148
|
-
else
|
|
149
|
-
throw e;
|
|
150
|
-
loggers.message.warn(e);
|
|
151
|
-
retryInference++;
|
|
152
|
-
}
|
|
153
|
-
else if (e instanceof Engine.Exceptions.InferenceError) {
|
|
154
|
-
if (retryInference < this.inferenceOptions.retry) { }
|
|
155
|
-
else
|
|
156
|
-
throw e;
|
|
157
|
-
loggers.message.warn(e);
|
|
158
|
-
retryInference++;
|
|
159
|
-
}
|
|
160
|
-
else if (e instanceof Engine.Exceptions.APIError) {
|
|
161
|
-
if (retryProvider < this.providerSpecs.retry) { }
|
|
162
|
-
else
|
|
163
|
-
throw e;
|
|
164
|
-
loggers.message.warn(e);
|
|
165
|
-
retryProvider++;
|
|
166
|
-
}
|
|
167
|
-
else
|
|
168
|
-
throw e;
|
|
169
|
-
}
|
|
105
|
+
const aiMessage = await middleware(wfctx, session, () => this.infer(wfctx, session));
|
|
106
|
+
session.chatMessages.push(aiMessage);
|
|
107
|
+
return aiMessage;
|
|
170
108
|
}
|
|
171
109
|
middlewaresStateless = [];
|
|
172
110
|
useStateless(middleware) {
|
|
@@ -178,6 +116,11 @@ export var Engine;
|
|
|
178
116
|
this.middlewaresStateful.push(middleware);
|
|
179
117
|
return this;
|
|
180
118
|
}
|
|
119
|
+
use(middleware) {
|
|
120
|
+
this.useStateless(middleware);
|
|
121
|
+
this.useStateful(middleware);
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
181
124
|
compose(middlewares) {
|
|
182
125
|
let composed = (wfctx, session, next) => next();
|
|
183
126
|
for (const middleware of middlewares.slice().reverse()) {
|
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,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAInC,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,sBAAsB,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK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AC,CAAC,OAAO;6BAC2B,CAAC,CAAC;4BACjD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;wBACjB,CAAC;oBACL,CAAC;;wBAAM,MAAM,IAAI,KAAK,EAAE,CAAC;gBAC7B,CAAC;gBACD,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,OAAA,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YAC3D,CAAC;YACD,MAAM,IAAI,MAAM,CAAC,UAAU,CAAC,yBAAyB,CAAC,+BAA+B,CAAC,CAAC;QAC3F,CAAC;KAEJ;IApLqB,eAAQ,WAoL7B,CAAA;IAqBa,0BAAmB,GAAG,yBAAyB,CAAC,mBAAmB,CAAC;IAEpE,cAAO,GAAG,aAAa,CAAC,OAAO,CAAC;IAChC,iBAAU,GAAG,gBAAgB,CAAC;IAE9B,uBAAgB,GAAG,sBAAsB,CAAC,gBAAgB,CAAC;AAC7E,CAAC,EAhNgB,MAAM,KAAN,MAAM,QAgNtB"}
|
|
@@ -14,6 +14,6 @@ export declare namespace AnthropicEngine {
|
|
|
14
14
|
protected transport: Transport<fdm>;
|
|
15
15
|
constructor(options: Engine.Options<fdm>);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function create<fdm extends Function.Decl.Map.Proto>(options: Engine.Options<fdm>): Engine<fdm>;
|
|
18
18
|
export import Transport = TransportModule.Transport;
|
|
19
19
|
}
|
|
@@ -33,10 +33,11 @@ export var AnthropicEngine;
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
AnthropicEngine.Instance = Instance;
|
|
36
|
-
|
|
36
|
+
create;
|
|
37
|
+
function create(options) {
|
|
37
38
|
return new Instance(options);
|
|
38
39
|
}
|
|
39
|
-
AnthropicEngine.
|
|
40
|
+
AnthropicEngine.create = create;
|
|
40
41
|
AnthropicEngine.Transport = TransportModule.Transport;
|
|
41
42
|
})(AnthropicEngine || (AnthropicEngine = {}));
|
|
42
43
|
//# sourceMappingURL=anthropic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/engines/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAC;AAM5D,MAAM,KAAW,eAAe,
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/engines/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAC;AAM5D,MAAM,KAAW,eAAe,CAsC/B;AAtCD,WAAiB,eAAe;IAC5B,MAAa,QAEX,SAAQ,MAAM,CAAC,QAAa;QAMG;QALnB,SAAS,CAAiB;QAC1B,YAAY,CAAoB;QAChC,OAAO,CAAU;QACR,SAAS,CAAiB;QAE7C,YAA6B,OAA4B;YACrD,KAAK,CAAC,OAAO,CAAC,CAAC;YADU,YAAO,GAAP,OAAO,CAAqB;YAErD,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YAClD,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC;gBACjC,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;aAC1C,CAAC,CAAC;YACH,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;YACtD,IAAI,CAAC,SAAS,GAAG,IAAI,gBAAA,SAAS,CAAC;gBAC3B,YAAY,EAAE,IAAI,CAAC,aAAa;gBAChC,eAAe,EAAE,IAAI,CAAC,gBAAgB;gBACtC,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,OAAO,EAAE,IAAI,CAAC,OAAO;aACxB,CAAC,CAAC;QACP,CAAC;KACJ;IA3BY,wBAAQ,WA2BpB,CAAA;IAED,MAA8B,CAAC;IAC/B,SAAgB,MAAM,CAEpB,OAA4B;QAC1B,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAJe,sBAAM,SAIrB,CAAA;IAEa,yBAAS,GAAG,eAAe,CAAC,SAAS,CAAC;AACxD,CAAC,EAtCgB,eAAe,KAAf,eAAe,QAsC/B"}
|
|
@@ -14,7 +14,6 @@ export declare namespace GoogleEngine {
|
|
|
14
14
|
protected transport: Transport<fdm>;
|
|
15
15
|
constructor(options: Engine.Options<fdm>);
|
|
16
16
|
}
|
|
17
|
-
function create<fdm extends Function.Decl.Map.Proto>(options: Engine.Options<fdm>):
|
|
18
|
-
function createEngine<fdm extends Function.Decl.Map.Proto>(options: Engine.Options<fdm>): Engine<fdm>;
|
|
17
|
+
function create<fdm extends Function.Decl.Map.Proto>(options: Engine.Options<fdm>): Engine<fdm>;
|
|
19
18
|
export import Transport = TransportModule.Transport;
|
|
20
19
|
}
|
package/build/engines/google.js
CHANGED
|
@@ -14,7 +14,7 @@ export var GoogleEngine;
|
|
|
14
14
|
constructor(options) {
|
|
15
15
|
super(options);
|
|
16
16
|
this.options = options;
|
|
17
|
-
if (options.
|
|
17
|
+
if (options.endpointConfig.parallelToolCall === false)
|
|
18
18
|
throw new Error('Parallel tool calling is required by Google engine.');
|
|
19
19
|
this.toolCodec = new ToolCodec({
|
|
20
20
|
fdm: this.fdm,
|
|
@@ -37,21 +37,11 @@ export var GoogleEngine;
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
GoogleEngine.Instance = Instance;
|
|
40
|
+
create;
|
|
40
41
|
function create(options) {
|
|
41
42
|
return new Instance(options);
|
|
42
43
|
}
|
|
43
44
|
GoogleEngine.create = create;
|
|
44
|
-
function createEngine(options) {
|
|
45
|
-
return new Instance({
|
|
46
|
-
endpointSpec: options.endpointSpec,
|
|
47
|
-
functionDeclarationMap: options.functionDeclarationMap,
|
|
48
|
-
throttle: options.throttle,
|
|
49
|
-
toolChoice: options.toolChoice,
|
|
50
|
-
providerRetry: options.providerRetry,
|
|
51
|
-
inferenceRetry: options.inferenceRetry,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
GoogleEngine.createEngine = createEngine;
|
|
55
45
|
GoogleEngine.Transport = TransportModule.Transport;
|
|
56
46
|
})(GoogleEngine || (GoogleEngine = {}));
|
|
57
47
|
//# sourceMappingURL=google.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.js","sourceRoot":"","sources":["../../src/engines/google.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AAMzD,MAAM,KAAW,YAAY,
|
|
1
|
+
{"version":3,"file":"google.js","sourceRoot":"","sources":["../../src/engines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AAC,UAAU;gBAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,OAAO,EAAE,IAAI,CAAC,OAAO;aACxB,CAAC,CAAC;QACP,CAAC;KACJ;IA/BY,qBAAQ,WA+BpB,CAAA;IAED,MAA8B,CAAC;IAC/B,SAAgB,MAAM,CAEpB,OAA4B;QAC1B,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAJe,mBAAM,SAIrB,CAAA;IAEa,sBAAS,GAAG,eAAe,CAAC,SAAS,CAAC;AACxD,CAAC,EA1CgB,YAAY,KAAZ,YAAY,QA0C5B"}
|
|
@@ -14,6 +14,6 @@ export declare namespace OpenAIChatCompletionsEngine {
|
|
|
14
14
|
protected transport: Transport<fdm>;
|
|
15
15
|
constructor(options: Engine.Options<fdm>);
|
|
16
16
|
}
|
|
17
|
+
function create<fdm extends Function.Decl.Map.Proto>(options: Engine.Options<fdm>): Engine<fdm>;
|
|
17
18
|
export import Transport = TransportModule.Transport;
|
|
18
|
-
function createEngine<fdm extends Function.Decl.Map.Proto>(options: Engine.Options<fdm>): Engine<fdm>;
|
|
19
19
|
}
|