@zimtsui/brainswitch 0.0.55 → 0.0.57
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 +110 -62
- package/assets/verbatim/declarations.handlebars +11 -0
- package/assets/verbatim/instruction.md +49 -0
- package/build/adaptor.d.ts +38 -7
- package/build/adaptor.js +35 -37
- package/build/adaptor.js.map +1 -1
- package/build/api-types/anthropic/billing.d.ts +12 -0
- package/build/api-types/anthropic/billing.js +14 -0
- package/build/api-types/anthropic/billing.js.map +1 -0
- package/build/api-types/anthropic/tool-codec.d.ts +16 -0
- package/build/api-types/anthropic/tool-codec.js +58 -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 +23 -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 +1 -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} +32 -29
- package/build/api-types/google/tool-codec.js.map +1 -0
- package/build/api-types/openai-chatcompletions/billing.d.ts +12 -0
- package/build/api-types/openai-chatcompletions/billing.js +14 -0
- package/build/api-types/openai-chatcompletions/billing.js.map +1 -0
- package/build/api-types/openai-chatcompletions/tool-codec.d.ts +17 -0
- package/build/api-types/openai-chatcompletions/tool-codec.js +80 -0
- package/build/api-types/openai-chatcompletions/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 +14 -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 +76 -0
- package/build/api-types/openai-responses/tool-codec.js.map +1 -0
- package/build/assets.d.ts +7 -0
- package/build/assets.js +8 -0
- package/build/assets.js.map +1 -0
- package/build/compatible-engine/session.d.ts +67 -0
- package/build/compatible-engine/session.js +92 -0
- package/build/compatible-engine/session.js.map +1 -0
- package/build/compatible-engine/structuring.d.ts +36 -0
- package/build/compatible-engine/structuring.js +34 -0
- package/build/compatible-engine/structuring.js.map +1 -0
- package/build/compatible-engine/validation.d.ts +21 -0
- package/build/compatible-engine/validation.js +82 -0
- package/build/compatible-engine/validation.js.map +1 -0
- package/build/compatible-engine.d/agentloop.d.ts +12 -0
- package/build/compatible-engine.d/agentloop.js +52 -0
- package/build/compatible-engine.d/agentloop.js.map +1 -0
- package/build/compatible-engine.d/aliyun/transport.d.ts +12 -0
- package/build/compatible-engine.d/aliyun/transport.js +7 -0
- package/build/compatible-engine.d/aliyun/transport.js.map +1 -0
- package/build/compatible-engine.d/aliyun.d.ts +24 -0
- package/build/compatible-engine.d/aliyun.js +46 -0
- package/build/compatible-engine.d/aliyun.js.map +1 -0
- package/build/compatible-engine.d/anthropic/choice-codec.d.ts +5 -0
- package/build/compatible-engine.d/anthropic/choice-codec.js +26 -0
- package/build/compatible-engine.d/anthropic/choice-codec.js.map +1 -0
- package/build/compatible-engine.d/anthropic/message-codec.d.ts +36 -0
- package/build/compatible-engine.d/anthropic/message-codec.js +86 -0
- package/build/compatible-engine.d/anthropic/message-codec.js.map +1 -0
- package/build/compatible-engine.d/anthropic/transport.d.ts +34 -0
- package/build/compatible-engine.d/anthropic/transport.js +150 -0
- package/build/compatible-engine.d/anthropic/transport.js.map +1 -0
- package/build/compatible-engine.d/anthropic.d.ts +26 -0
- package/build/compatible-engine.d/anthropic.js +46 -0
- package/build/compatible-engine.d/anthropic.js.map +1 -0
- package/build/compatible-engine.d/google/choice-codec.d.ts +5 -0
- package/build/compatible-engine.d/google/choice-codec.js +27 -0
- package/build/compatible-engine.d/google/choice-codec.js.map +1 -0
- package/build/compatible-engine.d/google/message-codec.d.ts +36 -0
- package/build/compatible-engine.d/google/message-codec.js +94 -0
- package/build/compatible-engine.d/google/message-codec.js.map +1 -0
- package/build/compatible-engine.d/google/transport.d.ts +30 -0
- package/build/compatible-engine.d/google/transport.js +78 -0
- package/build/compatible-engine.d/google/transport.js.map +1 -0
- package/build/compatible-engine.d/google.d.ts +26 -0
- package/build/compatible-engine.d/google.js +50 -0
- package/build/compatible-engine.d/google.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions/choice-codec.d.ts +5 -0
- package/build/compatible-engine.d/openai-chatcompletions/choice-codec.js +31 -0
- package/build/compatible-engine.d/openai-chatcompletions/choice-codec.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions/message-codec.d.ts +24 -0
- package/build/compatible-engine.d/openai-chatcompletions/message-codec.js +71 -0
- package/build/compatible-engine.d/openai-chatcompletions/message-codec.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/monolith.d.ts +38 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/monolith.js +77 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/monolith.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/stream.d.ts +37 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/stream.js +190 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d/stream.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.d.ts +10 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.js +11 -0
- package/build/compatible-engine.d/openai-chatcompletions/transport.js.map +1 -0
- package/build/compatible-engine.d/openai-chatcompletions.d.ts +17 -0
- package/build/compatible-engine.d/openai-chatcompletions.js +14 -0
- package/build/compatible-engine.d/openai-chatcompletions.js.map +1 -0
- package/build/compatible-engine.d/openai-responses/choice-codec.d.ts +5 -0
- package/build/compatible-engine.d/openai-responses/choice-codec.js +30 -0
- package/build/compatible-engine.d/openai-responses/choice-codec.js.map +1 -0
- package/build/compatible-engine.d/openai-responses/message-codec.d.ts +36 -0
- package/build/compatible-engine.d/openai-responses/message-codec.js +96 -0
- package/build/compatible-engine.d/openai-responses/message-codec.js.map +1 -0
- package/build/compatible-engine.d/openai-responses/transport.d.ts +35 -0
- package/build/compatible-engine.d/openai-responses/transport.js +80 -0
- package/build/compatible-engine.d/openai-responses/transport.js.map +1 -0
- package/build/compatible-engine.d/openai-responses.d.ts +26 -0
- package/build/compatible-engine.d/openai-responses.js +46 -0
- package/build/compatible-engine.d/openai-responses.js.map +1 -0
- package/build/compatible-engine.d.ts +17 -46
- package/build/compatible-engine.js +20 -58
- package/build/compatible-engine.js.map +1 -1
- package/build/config.d.ts +1 -0
- package/build/config.js +0 -1
- package/build/config.js.map +1 -1
- package/build/endpoint-spec.d.ts +1 -0
- package/build/endpoint-spec.js +2 -1
- package/build/endpoint-spec.js.map +1 -1
- package/build/engine/session.d.ts +7 -0
- package/build/engine/session.js +1 -0
- package/build/engine/session.js.map +1 -0
- package/build/engine/transport.d.ts +5 -0
- package/build/engine/transport.js +1 -0
- package/build/engine/transport.js.map +1 -0
- package/build/engine/validation.d.ts +9 -0
- package/build/engine/validation.js +1 -0
- package/build/engine/validation.js.map +1 -0
- package/build/engine.d.ts +60 -29
- package/build/engine.js +86 -19
- package/build/engine.js.map +1 -1
- package/build/exports.d.ts +4 -3
- package/build/exports.js +4 -3
- package/build/exports.js.map +1 -1
- package/build/function.d.ts +79 -54
- package/build/function.js +30 -46
- package/build/function.js.map +1 -1
- package/build/inference-context.d.ts +2 -2
- package/build/inference-context.js +0 -1
- package/build/inference-context.js.map +1 -1
- package/build/native-engines.d/google/message-codec.d.ts +23 -0
- package/build/native-engines.d/google/message-codec.js +67 -0
- package/build/native-engines.d/google/message-codec.js.map +1 -0
- package/build/native-engines.d/google/session.d.ts +45 -51
- package/build/native-engines.d/google/session.js +84 -80
- package/build/native-engines.d/google/session.js.map +1 -1
- package/build/native-engines.d/google/transport.d.ts +34 -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/google/validation.d.ts +22 -0
- package/build/native-engines.d/google/validation.js +20 -0
- package/build/native-engines.d/google/validation.js.map +1 -0
- package/build/native-engines.d/google.d/agentloop.d.ts +12 -0
- package/build/native-engines.d/google.d/agentloop.js +57 -0
- package/build/native-engines.d/google.d/agentloop.js.map +1 -0
- package/build/native-engines.d/google.d/exports.d.ts +3 -0
- package/build/native-engines.d/google.d/exports.js +4 -0
- package/build/native-engines.d/google.d/exports.js.map +1 -0
- package/build/native-engines.d/google.d.ts +42 -0
- package/build/native-engines.d/google.js +83 -0
- package/build/native-engines.d/google.js.map +1 -0
- package/build/native-engines.d/openai-responses/choice-codec.d.ts +5 -0
- package/build/native-engines.d/openai-responses/choice-codec.js +30 -0
- package/build/native-engines.d/openai-responses/choice-codec.js.map +1 -0
- package/build/native-engines.d/openai-responses/message-codec.d.ts +23 -0
- package/build/native-engines.d/openai-responses/message-codec.js +75 -0
- package/build/native-engines.d/openai-responses/message-codec.js.map +1 -0
- package/build/native-engines.d/openai-responses/session.d.ts +47 -44
- package/build/native-engines.d/openai-responses/session.js +73 -103
- package/build/native-engines.d/openai-responses/session.js.map +1 -1
- package/build/native-engines.d/openai-responses/structuring.d.ts +19 -0
- package/build/native-engines.d/openai-responses/structuring.js +19 -0
- package/build/native-engines.d/openai-responses/structuring.js.map +1 -0
- package/build/native-engines.d/openai-responses/tool.d.ts +14 -11
- package/build/native-engines.d/openai-responses/tool.js +1 -12
- package/build/native-engines.d/openai-responses/tool.js.map +1 -1
- package/build/native-engines.d/openai-responses/transport.d.ts +35 -0
- package/build/native-engines.d/openai-responses/transport.js +84 -0
- package/build/native-engines.d/openai-responses/transport.js.map +1 -0
- package/build/native-engines.d/openai-responses/validation.d.ts +20 -0
- package/build/native-engines.d/openai-responses/validation.js +80 -0
- package/build/native-engines.d/openai-responses/validation.js.map +1 -0
- package/build/native-engines.d/openai-responses.d/agentloop.d.ts +12 -0
- package/build/native-engines.d/openai-responses.d/agentloop.js +61 -0
- package/build/native-engines.d/openai-responses.d/agentloop.js.map +1 -0
- package/build/native-engines.d/{google → openai-responses.d}/exports.d.ts +1 -2
- package/build/native-engines.d/{google → openai-responses.d}/exports.js +1 -2
- package/build/native-engines.d/openai-responses.d/exports.js.map +1 -0
- package/build/native-engines.d/openai-responses.d.ts +44 -0
- package/build/native-engines.d/openai-responses.js +78 -0
- package/build/native-engines.d/openai-responses.js.map +1 -0
- package/build/throttle.d.ts +5 -4
- package/build/throttle.js +17 -14
- package/build/throttle.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/verbatim/codec/declarations.d.ts +2 -0
- package/build/verbatim/codec/declarations.js +22 -0
- package/build/verbatim/codec/declarations.js.map +1 -0
- package/build/verbatim/codec/request.d.ts +7 -0
- package/build/verbatim/codec/request.js +53 -0
- package/build/verbatim/codec/request.js.map +1 -0
- package/build/verbatim/codec.d.ts +2 -0
- package/build/verbatim/codec.js +3 -0
- package/build/verbatim/codec.js.map +1 -0
- package/build/verbatim.d.ts +74 -0
- package/build/verbatim.js +17 -0
- package/build/verbatim.js.map +1 -0
- package/examples/agent.ts +65 -0
- package/examples/chat.ts +24 -0
- package/examples/config.ts +24 -0
- package/examples/tsconfig.json +34 -0
- package/examples/verbatim.ts +44 -0
- package/package.json +10 -9
- package/build/agentloop.d.ts +0 -12
- package/build/agentloop.js +0 -43
- package/build/agentloop.js.map +0 -1
- 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-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 +0 -186
- 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/frontmatter.d.ts +0 -5
- package/build/frontmatter.js +0 -13
- package/build/frontmatter.js.map +0 -1
- package/build/native-engines.d/google/agentloop.d.ts +0 -12
- package/build/native-engines.d/google/agentloop.js +0 -42
- package/build/native-engines.d/google/agentloop.js.map +0 -1
- package/build/native-engines.d/google/engine.d.ts +0 -110
- package/build/native-engines.d/google/engine.js +0 -314
- package/build/native-engines.d/google/engine.js.map +0 -1
- package/build/native-engines.d/google/exports.js.map +0 -1
- package/build/native-engines.d/openai-responses/agentloop.d.ts +0 -13
- package/build/native-engines.d/openai-responses/agentloop.js +0 -53
- package/build/native-engines.d/openai-responses/agentloop.js.map +0 -1
- package/build/native-engines.d/openai-responses/engine.d.ts +0 -112
- package/build/native-engines.d/openai-responses/engine.js +0 -344
- package/build/native-engines.d/openai-responses/engine.js.map +0 -1
- package/build/native-engines.d/openai-responses/exports.d.ts +0 -7
- package/build/native-engines.d/openai-responses/exports.js +0 -8
- package/build/native-engines.d/openai-responses/exports.js.map +0 -1
- package/build/session.d.ts +0 -77
- package/build/session.js +0 -137
- package/build/session.js.map +0 -1
- package/build/test.d.ts +0 -1
- package/build/test.js +0 -198
- package/build/test.js.map +0 -1
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type Engine } from '../engine.ts';
|
|
2
|
-
import { Function } from '../function.ts';
|
|
3
|
-
import * as Google from '@google/genai';
|
|
4
|
-
export declare namespace GoogleEngine {
|
|
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 {
|
|
14
|
-
convertFromFunctionCall(fc: Function.Call.Distributive<Function.Declaration.From<fdm>>): Google.FunctionCall;
|
|
15
|
-
convertToFunctionCall(googlefc: Google.FunctionCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
16
|
-
convertFromFunctionDeclarationEntry(fdentry: Function.Declaration.Entry.From<fdm>): Google.FunctionDeclaration;
|
|
17
|
-
}
|
|
18
|
-
function convertFromFunctionCall<fdm extends Function.Declaration.Map>(this: GoogleEngine.Underhood<fdm>, fc: Function.Call.Distributive<Function.Declaration.From<fdm>>): Google.FunctionCall;
|
|
19
|
-
function convertFromFunctionDeclarationEntry<fdm extends Function.Declaration.Map>(this: GoogleEngine.Underhood<fdm>, fdentry: Function.Declaration.Entry.From<fdm>): Google.FunctionDeclaration;
|
|
20
|
-
function convertToFunctionCall<fdm extends Function.Declaration.Map>(this: GoogleEngine.Underhood<fdm>, googlefc: Google.FunctionCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
21
|
-
interface RestfulRequest {
|
|
22
|
-
contents: Google.Content[];
|
|
23
|
-
tools?: Google.Tool[];
|
|
24
|
-
toolConfig?: Google.ToolConfig;
|
|
25
|
-
systemInstruction?: Google.Content;
|
|
26
|
-
generationConfig?: Google.GenerationConfig;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google.js","sourceRoot":"","sources":["../../src/api-types/google.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;AAItB,MAAM,KAAW,YAAY,CAoF5B;AApFD,WAAiB,YAAY;IAMzB,IAAiB,QAAQ,CAQxB;IARD,WAAiB,QAAQ;QACrB,SAAgB,IAAI,CAAuC,OAAqB;YAC5E,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,IAAI,CAAC;YAC1D,IAAI,gBAAgB,EAAE,CAAC,CAAA,CAAC;;gBAAM,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;YAC1F,OAAO;gBACH,gBAAgB;aACnB,CAAC;QACN,CAAC;QANe,aAAI,OAMnB,CAAA;IACL,CAAC,EARgB,QAAQ,GAAR,qBAAQ,KAAR,qBAAQ,QAQxB;IAWD,SAAgB,uBAAuB,CAEnC,EAA8D;QAE9D,OAAO;YACH,EAAE,EAAE,EAAE,CAAC,EAAE;YACT,IAAI,EAAE,EAAE,CAAC,IAAI;YACb,IAAI,EAAE,EAAE,CAAC,IAA+B;SAC3C,CAAC;IACN,CAAC;IATe,oCAAuB,0BAStC,CAAA;IAED,SAAgB,mCAAmC,CAE/C,OAA6C;QA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AAI,CAAoD,CAAC;QAC1F,IAAI,MAAM,EAAE,CAAC,CAAA,CAAC;;YAAM,MAAM,IAAI,eAAe,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5F,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA,CAAC;;YACjD,MAAM,IAAI,eAAe,CAAC,wCAAwC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9F,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;YACxB,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,QAAQ,CAAC,IAAI;SAC0C,CAAC,CAAC;IACvE,CAAC;IAde,kCAAqB,wBAcpC,CAAA;AAUL,CAAC,EApFgB,YAAY,KAAZ,YAAY,QAoF5B"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type Engine } from '../engine.ts';
|
|
2
|
-
import { Function } from '../function.ts';
|
|
3
|
-
import OpenAI from 'openai';
|
|
4
|
-
export declare namespace OpenAIChatCompletionsEngine {
|
|
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 {
|
|
14
|
-
convertFromFunctionCall(fc: Function.Call.Distributive<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionMessageToolCall;
|
|
15
|
-
convertToFunctionCall(apifc: OpenAI.ChatCompletionMessageFunctionToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
16
|
-
convertFromFunctionResponse(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionToolMessageParam;
|
|
17
|
-
convertFromFunctionDeclarationEntry(fdentry: Function.Declaration.Entry.From<fdm>): OpenAI.ChatCompletionTool;
|
|
18
|
-
convertFromToolChoice(mode: Function.ToolChoice<fdm>): OpenAI.ChatCompletionToolChoiceOption;
|
|
19
|
-
calcCost(usage: OpenAI.CompletionUsage): number;
|
|
20
|
-
extractContent(completionContent: string): string;
|
|
21
|
-
handleFinishReason(completion: OpenAI.ChatCompletion, finishReason: OpenAI.ChatCompletion.Choice['finish_reason']): void;
|
|
22
|
-
}
|
|
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;
|
|
31
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { ResponseInvalid } from "../engine.js";
|
|
2
|
-
import { Function } from "../function.js";
|
|
3
|
-
import OpenAI from 'openai';
|
|
4
|
-
import { Ajv } from 'ajv';
|
|
5
|
-
const ajv = new Ajv();
|
|
6
|
-
export var OpenAIChatCompletionsEngine;
|
|
7
|
-
(function (OpenAIChatCompletionsEngine) {
|
|
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);
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
return new ResponseInvalid('Invalid JSON of function call', { cause: apifc });
|
|
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] } };
|
|
89
|
-
}
|
|
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;
|
|
112
|
-
})(OpenAIChatCompletionsEngine || (OpenAIChatCompletionsEngine = {}));
|
|
113
|
-
//# sourceMappingURL=openai-chat-completions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,WA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1
|
-
import OpenAI from 'openai';
|
|
2
|
-
import { Function } from '../function.ts';
|
|
3
|
-
import { type Engine } from '../engine.ts';
|
|
4
|
-
export declare namespace OpenAIResponsesEngine {
|
|
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 {
|
|
14
|
-
convertFromFunctionResponse(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): OpenAI.Responses.ResponseInputItem.FunctionCallOutput;
|
|
15
|
-
calcCost(usage: OpenAI.Responses.ResponseUsage): number;
|
|
16
|
-
convertFromFunctionDeclarationEntry(fdentry: Function.Declaration.Entry.From<fdm>): OpenAI.Responses.FunctionTool;
|
|
17
|
-
convertToFunctionCall(apifc: OpenAI.Responses.ResponseFunctionToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
18
|
-
}
|
|
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
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import OpenAI from 'openai';
|
|
2
|
-
import { Function } from "../function.js";
|
|
3
|
-
import { ResponseInvalid } from "../engine.js";
|
|
4
|
-
import Ajv from 'ajv';
|
|
5
|
-
import {} from "../engine.js";
|
|
6
|
-
const ajv = new Ajv();
|
|
7
|
-
export var OpenAIResponsesEngine;
|
|
8
|
-
(function (OpenAIResponsesEngine) {
|
|
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);
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
return new ResponseInvalid('Invalid JSON of function call', { cause: apifc });
|
|
58
|
-
}
|
|
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;
|
|
70
|
-
})(OpenAIResponsesEngine || (OpenAIResponsesEngine = {}));
|
|
71
|
-
//# sourceMappingURL=openai-responses.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,WAA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SAAgB,qBAAqB,CAEjC,KAAgD;QAEhD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,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"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Function } from '../function.ts';
|
|
2
|
-
import { CompatibleEngine } from '../compatible-engine.ts';
|
|
3
|
-
import { OpenAIChatCompletionsCompatibleStreamEngine } from './openai-chatcompletions.d/stream.ts';
|
|
4
|
-
import { type InferenceContext } from '../inference-context.ts';
|
|
5
|
-
import { type Session, RoleMessage } from '../session.ts';
|
|
6
|
-
import * as Undici from 'undici';
|
|
7
|
-
import { Throttle } from '../throttle.ts';
|
|
8
|
-
import OpenAI from 'openai';
|
|
9
|
-
export declare namespace AliyunEngine {
|
|
10
|
-
interface Options<in out fdm extends Function.Declaration.Map> extends OpenAIChatCompletionsCompatibleStreamEngine.Options<fdm> {
|
|
11
|
-
}
|
|
12
|
-
interface OwnProps {
|
|
13
|
-
client: OpenAI;
|
|
14
|
-
}
|
|
15
|
-
namespace OwnProps {
|
|
16
|
-
function init<fdm extends Function.Declaration.Map>(this: OpenAIChatCompletionsCompatibleStreamEngine.Underhood<fdm>, options: Options<fdm>): OwnProps;
|
|
17
|
-
}
|
|
18
|
-
interface ChatCompletionChunkChoiceDelta extends OpenAI.ChatCompletionChunk.Choice.Delta {
|
|
19
|
-
reasoning_content?: string;
|
|
20
|
-
}
|
|
21
|
-
interface Underhood<in out fdm extends Function.Declaration.Map> extends OpenAIChatCompletionsCompatibleStreamEngine.Underhood<fdm> {
|
|
22
|
-
getDeltaThoughts(delta: OpenAI.ChatCompletionChunk.Choice.Delta): string;
|
|
23
|
-
}
|
|
24
|
-
function getDeltaThoughts(delta: OpenAI.ChatCompletionChunk.Choice.Delta): string;
|
|
25
|
-
class Instance<in out fdm extends Function.Declaration.Map> implements AliyunEngine.Underhood<fdm> {
|
|
26
|
-
baseUrl: string;
|
|
27
|
-
apiKey: string;
|
|
28
|
-
model: string;
|
|
29
|
-
name: string;
|
|
30
|
-
inputPrice: number;
|
|
31
|
-
outputPrice: number;
|
|
32
|
-
cachePrice: number;
|
|
33
|
-
fdm: fdm;
|
|
34
|
-
additionalOptions?: Record<string, unknown>;
|
|
35
|
-
throttle: Throttle;
|
|
36
|
-
timeout?: number;
|
|
37
|
-
maxTokens?: number;
|
|
38
|
-
proxyAgent?: Undici.ProxyAgent;
|
|
39
|
-
toolChoice: Function.ToolChoice<fdm>;
|
|
40
|
-
parallelToolCall: boolean;
|
|
41
|
-
client: OpenAI;
|
|
42
|
-
constructor(options: AliyunEngine.Options<fdm>);
|
|
43
|
-
stateless(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
44
|
-
stateful(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
45
|
-
appendUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>;
|
|
46
|
-
pushUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>;
|
|
47
|
-
convertFromFunctionCall(fc: Function.Call.Distributive<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionMessageToolCall;
|
|
48
|
-
convertFromFunctionResponse(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionToolMessageParam;
|
|
49
|
-
convertFromToolChoice(mode: Function.ToolChoice<fdm>): OpenAI.ChatCompletionToolChoiceOption;
|
|
50
|
-
convertToFunctionCall(apifc: OpenAI.ChatCompletionMessageFunctionToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
51
|
-
convertFromFunctionDeclarationEntry(fdentry: Function.Declaration.Entry.From<fdm>): OpenAI.ChatCompletionTool;
|
|
52
|
-
calcCost(usage: OpenAI.CompletionUsage): number;
|
|
53
|
-
extractContent(completionContent: string): string;
|
|
54
|
-
handleFinishReason(completion: OpenAI.ChatCompletion, finishReason: OpenAI.ChatCompletion.Choice['finish_reason']): void;
|
|
55
|
-
fetch(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
56
|
-
convertToAiMessage(message: OpenAI.ChatCompletionMessage): RoleMessage.Ai<Function.Declaration.From<fdm>>;
|
|
57
|
-
convertFromAiMessage(aiMessage: RoleMessage.Ai<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionAssistantMessageParam;
|
|
58
|
-
convertFromDeveloperMessage(developerMessage: RoleMessage.Developer): OpenAI.ChatCompletionSystemMessageParam;
|
|
59
|
-
convertFromUserMessage(userMessage: RoleMessage.User<Function.Declaration.From<fdm>>): [OpenAI.ChatCompletionUserMessageParam] | OpenAI.ChatCompletionToolMessageParam[];
|
|
60
|
-
convertFromRoleMessage(roleMessage: RoleMessage): OpenAI.ChatCompletionMessageParam[];
|
|
61
|
-
validateToolCallsByToolChoice(toolCalls: Function.Call.Distributive<Function.Declaration.From<fdm>>[]): void;
|
|
62
|
-
makeParams(session: Session<Function.Declaration.From<fdm>>): OpenAI.ChatCompletionCreateParamsStreaming;
|
|
63
|
-
convertToFunctionCallFromDelta(apifc: OpenAI.ChatCompletionChunk.Choice.Delta.ToolCall): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
64
|
-
convertCompletionStockToCompletion(stock: OpenAI.ChatCompletionChunk): OpenAI.ChatCompletion;
|
|
65
|
-
fetchRaw(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
66
|
-
getDeltaThoughts(delta: OpenAI.ChatCompletionChunk.Choice.Delta): string;
|
|
67
|
-
}
|
|
68
|
-
function create<fdm extends Function.Declaration.Map>(options: CompatibleEngine.Options<fdm>): CompatibleEngine<fdm>;
|
|
69
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { Function } from "../function.js";
|
|
2
|
-
import { OpenAIChatCompletionsEngine } from "../api-types/openai-chat-completions.js";
|
|
3
|
-
import { OpenAIChatCompletionsCompatibleEngine } from "./openai-chatcompletions.js";
|
|
4
|
-
import { CompatibleEngine } from "../compatible-engine.js";
|
|
5
|
-
import { OpenAIChatCompletionsCompatibleStreamEngine } from "./openai-chatcompletions.d/stream.js";
|
|
6
|
-
import {} from "../inference-context.js";
|
|
7
|
-
import { RoleMessage } from "../session.js";
|
|
8
|
-
import * as Undici from 'undici';
|
|
9
|
-
import { Throttle } from "../throttle.js";
|
|
10
|
-
import { Engine } from "../engine.js";
|
|
11
|
-
import OpenAI from 'openai';
|
|
12
|
-
export var AliyunEngine;
|
|
13
|
-
(function (AliyunEngine) {
|
|
14
|
-
let OwnProps;
|
|
15
|
-
(function (OwnProps) {
|
|
16
|
-
function init(options) {
|
|
17
|
-
return {
|
|
18
|
-
client: new OpenAI({
|
|
19
|
-
baseURL: this.baseUrl,
|
|
20
|
-
apiKey: this.apiKey,
|
|
21
|
-
fetchOptions: {
|
|
22
|
-
dispatcher: this.proxyAgent,
|
|
23
|
-
},
|
|
24
|
-
}),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
OwnProps.init = init;
|
|
28
|
-
})(OwnProps = AliyunEngine.OwnProps || (AliyunEngine.OwnProps = {}));
|
|
29
|
-
function getDeltaThoughts(delta) {
|
|
30
|
-
return delta.reasoning_content ?? '';
|
|
31
|
-
}
|
|
32
|
-
AliyunEngine.getDeltaThoughts = getDeltaThoughts;
|
|
33
|
-
class Instance {
|
|
34
|
-
baseUrl;
|
|
35
|
-
apiKey;
|
|
36
|
-
model;
|
|
37
|
-
name;
|
|
38
|
-
inputPrice;
|
|
39
|
-
outputPrice;
|
|
40
|
-
cachePrice;
|
|
41
|
-
fdm;
|
|
42
|
-
additionalOptions;
|
|
43
|
-
throttle;
|
|
44
|
-
timeout;
|
|
45
|
-
maxTokens;
|
|
46
|
-
proxyAgent;
|
|
47
|
-
toolChoice;
|
|
48
|
-
parallelToolCall;
|
|
49
|
-
client;
|
|
50
|
-
constructor(options) {
|
|
51
|
-
({
|
|
52
|
-
baseUrl: this.baseUrl,
|
|
53
|
-
apiKey: this.apiKey,
|
|
54
|
-
model: this.model,
|
|
55
|
-
name: this.name,
|
|
56
|
-
inputPrice: this.inputPrice,
|
|
57
|
-
outputPrice: this.outputPrice,
|
|
58
|
-
cachePrice: this.cachePrice,
|
|
59
|
-
fdm: this.fdm,
|
|
60
|
-
additionalOptions: this.additionalOptions,
|
|
61
|
-
throttle: this.throttle,
|
|
62
|
-
timeout: this.timeout,
|
|
63
|
-
maxTokens: this.maxTokens,
|
|
64
|
-
proxyAgent: this.proxyAgent,
|
|
65
|
-
} = (Engine.OwnProps.init).call(this, options));
|
|
66
|
-
({ toolChoice: this.toolChoice } = (CompatibleEngine.OwnProps.init).call(this, options));
|
|
67
|
-
({ parallelToolCall: this.parallelToolCall } = (OpenAIChatCompletionsEngine.OwnProps.init).call(this, options));
|
|
68
|
-
({ client: this.client } = (AliyunEngine.OwnProps.init).call(this, options));
|
|
69
|
-
}
|
|
70
|
-
stateless(wfctx, session) {
|
|
71
|
-
return (CompatibleEngine.stateless).call(this, wfctx, session);
|
|
72
|
-
}
|
|
73
|
-
stateful(wfctx, session) {
|
|
74
|
-
return (CompatibleEngine.stateful).call(this, wfctx, session);
|
|
75
|
-
}
|
|
76
|
-
appendUserMessage(session, message) {
|
|
77
|
-
return (CompatibleEngine.appendUserMessage).call(this, session, message);
|
|
78
|
-
}
|
|
79
|
-
pushUserMessage(session, message) {
|
|
80
|
-
return (CompatibleEngine.pushUserMessage).call(this, session, message);
|
|
81
|
-
}
|
|
82
|
-
convertFromFunctionCall(fc) {
|
|
83
|
-
return (OpenAIChatCompletionsEngine.convertFromFunctionCall).call(this, fc);
|
|
84
|
-
}
|
|
85
|
-
convertFromFunctionResponse(fr) {
|
|
86
|
-
return (OpenAIChatCompletionsEngine.convertFromFunctionResponse).call(this, fr);
|
|
87
|
-
}
|
|
88
|
-
convertFromToolChoice(mode) {
|
|
89
|
-
return (OpenAIChatCompletionsEngine.convertFromToolChoice).call(this, mode);
|
|
90
|
-
}
|
|
91
|
-
convertToFunctionCall(apifc) {
|
|
92
|
-
return (OpenAIChatCompletionsEngine.convertToFunctionCall).call(this, apifc);
|
|
93
|
-
}
|
|
94
|
-
convertFromFunctionDeclarationEntry(fdentry) {
|
|
95
|
-
return (OpenAIChatCompletionsEngine.convertFromFunctionDeclarationEntry).call(this, fdentry);
|
|
96
|
-
}
|
|
97
|
-
calcCost(usage) {
|
|
98
|
-
return (OpenAIChatCompletionsEngine.calcCost).call(this, usage);
|
|
99
|
-
}
|
|
100
|
-
extractContent(completionContent) {
|
|
101
|
-
return (OpenAIChatCompletionsEngine.extractContent).call(this, completionContent);
|
|
102
|
-
}
|
|
103
|
-
handleFinishReason(completion, finishReason) {
|
|
104
|
-
return (OpenAIChatCompletionsEngine.handleFinishReason).call(this, completion, finishReason);
|
|
105
|
-
}
|
|
106
|
-
fetch(wfctx, session, signal) {
|
|
107
|
-
return (OpenAIChatCompletionsCompatibleEngine.fetch).call(this, wfctx, session, signal);
|
|
108
|
-
}
|
|
109
|
-
convertToAiMessage(message) {
|
|
110
|
-
return (OpenAIChatCompletionsCompatibleEngine.convertToAiMessage).call(this, message);
|
|
111
|
-
}
|
|
112
|
-
convertFromAiMessage(aiMessage) {
|
|
113
|
-
return (OpenAIChatCompletionsCompatibleEngine.convertFromAiMessage).call(this, aiMessage);
|
|
114
|
-
}
|
|
115
|
-
convertFromDeveloperMessage(developerMessage) {
|
|
116
|
-
return (OpenAIChatCompletionsCompatibleEngine.convertFromDeveloperMessage).call(this, developerMessage);
|
|
117
|
-
}
|
|
118
|
-
convertFromUserMessage(userMessage) {
|
|
119
|
-
return (OpenAIChatCompletionsCompatibleEngine.convertFromUserMessage).call(this, userMessage);
|
|
120
|
-
}
|
|
121
|
-
convertFromRoleMessage(roleMessage) {
|
|
122
|
-
return (OpenAIChatCompletionsCompatibleEngine.convertFromRoleMessage).call(this, roleMessage);
|
|
123
|
-
}
|
|
124
|
-
validateToolCallsByToolChoice(toolCalls) {
|
|
125
|
-
return (OpenAIChatCompletionsCompatibleEngine.validateToolCallsByToolChoice).call(this, toolCalls);
|
|
126
|
-
}
|
|
127
|
-
makeParams(session) {
|
|
128
|
-
return (OpenAIChatCompletionsCompatibleStreamEngine.makeParams).call(this, session);
|
|
129
|
-
}
|
|
130
|
-
convertToFunctionCallFromDelta(apifc) {
|
|
131
|
-
return (OpenAIChatCompletionsCompatibleStreamEngine.convertToFunctionCallFromDelta).call(this, apifc);
|
|
132
|
-
}
|
|
133
|
-
convertCompletionStockToCompletion(stock) {
|
|
134
|
-
return (OpenAIChatCompletionsCompatibleStreamEngine.convertCompletionStockToCompletion).call(this, stock);
|
|
135
|
-
}
|
|
136
|
-
fetchRaw(wfctx, session, signal) {
|
|
137
|
-
return (OpenAIChatCompletionsCompatibleStreamEngine.fetchRaw).call(this, wfctx, session, signal);
|
|
138
|
-
}
|
|
139
|
-
getDeltaThoughts(delta) {
|
|
140
|
-
return (AliyunEngine.getDeltaThoughts).call(this, delta);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
AliyunEngine.Instance = Instance;
|
|
144
|
-
function create(options) {
|
|
145
|
-
return new AliyunEngine.Instance(options);
|
|
146
|
-
}
|
|
147
|
-
AliyunEngine.create = create;
|
|
148
|
-
})(AliyunEngine || (AliyunEngine = {}));
|
|
149
|
-
//# sourceMappingURL=aliyun.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aliyun.js","sourceRoot":"","sources":["../../src/compatible-engines.d/aliyun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,qCAAqC,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,2CAA2C,EAAE,MAAM,sCAAsC,CAAC;AACnG,OAAO,EAAyB,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAgB,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,MAAM,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CAA2C,CAAC,UAAe,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7F,CAAC;QACM,8BAA8B,CAAC,KAAuD;YACzF,OAAO,CAAC,2CAA2C,CAAC,8BAAmC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/G,CAAC;QACM,kCAAkC,CAAC,KAAiC;YACvE,OAAO,CAAC,2CAA2C,CAAC,kCAAkC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC9G,CAAC;QACM,QAAQ,CAAC,KAAuB,EAAE,OAAgD,EAAE,MAAoB;YAC3G,OAAO,CAAC,2CAA2C,CAAC,QAAa,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1G,CAAC;QAGM,gBAAgB,CAAC,KAA8C;YAClE,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC;KACJ;IAzHY,qBAAQ,WAyHpB,CAAA;IAGD,SAAgB,MAAM,CAAuC,OAAsC;QAC/F,OAAO,IAAI,YAAY,CAAC,QAAQ,CAAM,OAAO,CAAC,CAAC;IACnD,CAAC;IAFe,mBAAM,SAErB,CAAA;AACL,CAAC,EArKgB,YAAY,KAAZ,YAAY,QAqK5B"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { CompatibleEngine } from '../compatible-engine.ts';
|
|
2
|
-
import { Function } from '../function.ts';
|
|
3
|
-
import { RoleMessage, type ChatMessage, type Session } from '../session.ts';
|
|
4
|
-
import { type InferenceContext } from '../inference-context.ts';
|
|
5
|
-
import Anthropic from '@anthropic-ai/sdk';
|
|
6
|
-
import { AnthropicEngine } from '../api-types/anthropic.ts';
|
|
7
|
-
import * as Undici from 'undici';
|
|
8
|
-
import { Throttle } from '../throttle.ts';
|
|
9
|
-
export declare namespace AnthropicCompatibleEngine {
|
|
10
|
-
interface Options<in out fdm extends Function.Declaration.Map> extends CompatibleEngine.Options<fdm>, AnthropicEngine.Options<fdm> {
|
|
11
|
-
}
|
|
12
|
-
interface Underhood<in out fdm extends Function.Declaration.Map> extends CompatibleEngine.Underhood<fdm>, AnthropicEngine.Underhood<fdm> {
|
|
13
|
-
convertFromUserMessage(userMessage: RoleMessage.User<Function.Declaration.From<fdm>>): Anthropic.ContentBlockParam[];
|
|
14
|
-
convertFromAiMessage(aiMessage: RoleMessage.Ai<Function.Declaration.From<fdm>>): Anthropic.ContentBlockParam[];
|
|
15
|
-
convertFromDeveloperMessage(developerMessage: RoleMessage.Developer): Anthropic.TextBlockParam[];
|
|
16
|
-
convertFromChatMessage(chatMessage: ChatMessage<Function.Declaration.From<fdm>>): Anthropic.MessageParam;
|
|
17
|
-
makeParams(session: Session<Function.Declaration.From<fdm>>): Anthropic.MessageCreateParamsStreaming;
|
|
18
|
-
convertToAiMessage(raw: Anthropic.ContentBlock[]): AnthropicCompatibleEngine.Message.Ai<Function.Declaration.From<fdm>>;
|
|
19
|
-
fetch(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
20
|
-
}
|
|
21
|
-
function convertFromUserMessage<fdm extends Function.Declaration.Map>(this: AnthropicEngine.Underhood<fdm>, userMessage: RoleMessage.User<Function.Declaration.From<fdm>>): Anthropic.ContentBlockParam[];
|
|
22
|
-
function convertFromAiMessage<fdm extends Function.Declaration.Map>(this: AnthropicEngine.Underhood<fdm>, aiMessage: RoleMessage.Ai<Function.Declaration.From<fdm>>): Anthropic.ContentBlockParam[];
|
|
23
|
-
function convertFromDeveloperMessage(developerMessage: RoleMessage.Developer): Anthropic.TextBlockParam[];
|
|
24
|
-
function convertFromChatMessage<fdm extends Function.Declaration.Map>(this: AnthropicCompatibleEngine.Underhood<fdm>, chatMessage: ChatMessage<Function.Declaration.From<fdm>>): Anthropic.MessageParam;
|
|
25
|
-
function makeParams<fdm extends Function.Declaration.Map>(this: AnthropicCompatibleEngine.Underhood<fdm>, session: Session<Function.Declaration.From<fdm>>): Anthropic.MessageCreateParamsStreaming;
|
|
26
|
-
function convertToAiMessage<fdm extends Function.Declaration.Map>(this: AnthropicEngine.Underhood<fdm>, raw: Anthropic.ContentBlock[]): AnthropicCompatibleEngine.Message.Ai<Function.Declaration.From<fdm>>;
|
|
27
|
-
function fetch<fdm extends Function.Declaration.Map>(this: AnthropicCompatibleEngine.Underhood<fdm>, wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
28
|
-
namespace Message {
|
|
29
|
-
type Ai<fdu extends Function.Declaration> = Ai.Instance<fdu>;
|
|
30
|
-
namespace Ai {
|
|
31
|
-
function create<fdu extends Function.Declaration>(parts: RoleMessage.Ai.Part<fdu>[], raw: Anthropic.ContentBlock[]): Ai<fdu>;
|
|
32
|
-
const NOMINAL: unique symbol;
|
|
33
|
-
class Instance<out fdu extends Function.Declaration> extends RoleMessage.Ai.Instance<fdu> {
|
|
34
|
-
raw: Anthropic.ContentBlock[];
|
|
35
|
-
readonly [NOMINAL]: void;
|
|
36
|
-
constructor(parts: RoleMessage.Ai.Part<fdu>[], raw: Anthropic.ContentBlock[]);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
class Instance<in out fdm extends Function.Declaration.Map> implements AnthropicCompatibleEngine.Underhood<fdm> {
|
|
41
|
-
baseUrl: string;
|
|
42
|
-
apiKey: string;
|
|
43
|
-
model: string;
|
|
44
|
-
name: string;
|
|
45
|
-
inputPrice: number;
|
|
46
|
-
outputPrice: number;
|
|
47
|
-
cachePrice: number;
|
|
48
|
-
fdm: fdm;
|
|
49
|
-
additionalOptions?: Record<string, unknown>;
|
|
50
|
-
throttle: Throttle;
|
|
51
|
-
timeout?: number;
|
|
52
|
-
maxTokens?: number;
|
|
53
|
-
proxyAgent?: Undici.ProxyAgent;
|
|
54
|
-
toolChoice: Function.ToolChoice<fdm>;
|
|
55
|
-
anthropic: Anthropic;
|
|
56
|
-
parallelToolCall: boolean;
|
|
57
|
-
constructor(options: AnthropicCompatibleEngine.Options<fdm>);
|
|
58
|
-
stateless(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
59
|
-
stateful(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>): Promise<RoleMessage.Ai<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>>;
|
|
60
|
-
appendUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>;
|
|
61
|
-
pushUserMessage(session: Session<Function.Declaration.From<fdm>>, message: RoleMessage.User<Function.Declaration.From<fdm>>): Session<Function.Declaration.From<fdm, Extract<keyof fdm, string>>>;
|
|
62
|
-
validateToolCallsByToolChoice(toolCalls: Function.Call.Distributive<Function.Declaration.From<fdm>>[]): void;
|
|
63
|
-
convertFromFunctionCall(fc: Function.Call.Distributive<Function.Declaration.From<fdm>>): Anthropic.ToolUseBlock;
|
|
64
|
-
convertToFunctionCall(apifc: Anthropic.ToolUseBlock): Function.Call.Distributive<Function.Declaration.From<fdm>>;
|
|
65
|
-
convertFromFunctionResponse(fr: Function.Response.Distributive<Function.Declaration.From<fdm>>): Anthropic.ToolResultBlockParam;
|
|
66
|
-
convertFromFunctionDeclarationEntry(fdentry: Function.Declaration.Entry.From<fdm>): Anthropic.Tool;
|
|
67
|
-
convertFromToolChoice(toolChoice: Function.ToolChoice<fdm>, parallel: boolean): Anthropic.ToolChoice;
|
|
68
|
-
calcCost(usage: Anthropic.Usage): number;
|
|
69
|
-
convertFromUserMessage(userMessage: RoleMessage.User<Function.Declaration.From<fdm>>): Anthropic.ContentBlockParam[];
|
|
70
|
-
convertFromAiMessage(aiMessage: RoleMessage.Ai<Function.Declaration.From<fdm>>): Anthropic.ContentBlockParam[];
|
|
71
|
-
convertFromDeveloperMessage(developerMessage: RoleMessage.Developer): Anthropic.TextBlockParam[];
|
|
72
|
-
convertFromChatMessage(chatMessage: ChatMessage<Function.Declaration.From<fdm>>): Anthropic.MessageParam;
|
|
73
|
-
makeParams(session: Session<Function.Declaration.From<fdm>>): Anthropic.MessageCreateParamsStreaming;
|
|
74
|
-
convertToAiMessage(raw: Anthropic.ContentBlock[]): AnthropicCompatibleEngine.Message.Ai<Function.Declaration.From<fdm>>;
|
|
75
|
-
fetch(wfctx: InferenceContext, session: Session<Function.Declaration.From<fdm>>, signal?: AbortSignal): Promise<RoleMessage.Ai<Function.Declaration.From<fdm>>>;
|
|
76
|
-
}
|
|
77
|
-
function create<fdm extends Function.Declaration.Map>(options: AnthropicCompatibleEngine.Options<fdm>): CompatibleEngine<fdm>;
|
|
78
|
-
}
|