@ank1015/providers 0.0.1 → 0.0.3
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/LICENSE +21 -0
- package/README.md +93 -383
- package/dist/agent/conversation.d.ts +97 -0
- package/dist/agent/conversation.d.ts.map +1 -0
- package/dist/agent/conversation.js +328 -0
- package/dist/agent/conversation.js.map +1 -0
- package/dist/agent/runner.d.ts +37 -0
- package/dist/agent/runner.d.ts.map +1 -0
- package/dist/agent/runner.js +169 -0
- package/dist/agent/runner.js.map +1 -0
- package/dist/agent/tools/calculate.d.ts +15 -0
- package/dist/agent/tools/calculate.d.ts.map +1 -0
- package/dist/agent/tools/calculate.js +23 -0
- package/dist/agent/tools/calculate.js.map +1 -0
- package/dist/agent/tools/get-current-time.d.ts +15 -0
- package/dist/agent/tools/get-current-time.d.ts.map +1 -0
- package/dist/agent/tools/get-current-time.js +38 -0
- package/dist/agent/tools/get-current-time.js.map +1 -0
- package/dist/agent/tools/index.d.ts +3 -0
- package/dist/agent/tools/index.d.ts.map +1 -0
- package/dist/agent/tools/index.js +3 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/types.d.ts +53 -31
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js +1 -2
- package/dist/agent/utils.d.ts +14 -0
- package/dist/agent/utils.d.ts.map +1 -0
- package/dist/agent/utils.js +59 -0
- package/dist/agent/utils.js.map +1 -0
- package/dist/index.d.ts +16 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -28
- package/dist/index.js.map +1 -1
- package/dist/llm.d.ts +15 -0
- package/dist/llm.d.ts.map +1 -0
- package/dist/llm.js +92 -0
- package/dist/llm.js.map +1 -0
- package/dist/models.d.ts +8 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.generated.d.ts +25 -112
- package/dist/models.generated.d.ts.map +1 -1
- package/dist/models.generated.js +72 -227
- package/dist/models.generated.js.map +1 -1
- package/dist/models.js +30 -32
- package/dist/models.js.map +1 -1
- package/dist/providers/google/complete.d.ts +3 -0
- package/dist/providers/google/complete.d.ts.map +1 -0
- package/dist/providers/google/complete.js +53 -0
- package/dist/providers/google/complete.js.map +1 -0
- package/dist/providers/google/index.d.ts +6 -0
- package/dist/providers/google/index.d.ts.map +1 -0
- package/dist/providers/google/index.js +6 -0
- package/dist/providers/google/index.js.map +1 -0
- package/dist/providers/google/stream.d.ts +3 -0
- package/dist/providers/google/stream.d.ts.map +1 -0
- package/dist/providers/{google.js → google/stream.js} +67 -231
- package/dist/providers/google/stream.js.map +1 -0
- package/dist/providers/google/types.d.ts +8 -0
- package/dist/providers/google/types.d.ts.map +1 -0
- package/dist/providers/google/types.js +2 -0
- package/dist/providers/google/types.js.map +1 -0
- package/dist/providers/google/utils.d.ts +30 -0
- package/dist/providers/google/utils.d.ts.map +1 -0
- package/dist/providers/google/utils.js +354 -0
- package/dist/providers/google/utils.js.map +1 -0
- package/dist/providers/openai/complete.d.ts +3 -0
- package/dist/providers/openai/complete.d.ts.map +1 -0
- package/dist/providers/openai/complete.js +57 -0
- package/dist/providers/openai/complete.js.map +1 -0
- package/dist/providers/openai/index.d.ts +4 -0
- package/dist/providers/openai/index.d.ts.map +1 -0
- package/dist/providers/openai/index.js +4 -0
- package/dist/providers/openai/index.js.map +1 -0
- package/dist/providers/openai/stream.d.ts +3 -0
- package/dist/providers/openai/stream.d.ts.map +1 -0
- package/dist/providers/{openai.js → openai/stream.js} +74 -152
- package/dist/providers/openai/stream.js.map +1 -0
- package/dist/providers/openai/types.d.ts +8 -0
- package/dist/providers/openai/types.d.ts.map +1 -0
- package/dist/providers/openai/types.js +2 -0
- package/dist/providers/openai/types.js.map +1 -0
- package/dist/providers/openai/utils.d.ts +13 -0
- package/dist/providers/openai/utils.d.ts.map +1 -0
- package/dist/providers/openai/utils.js +285 -0
- package/dist/providers/openai/utils.js.map +1 -0
- package/dist/types.d.ts +95 -87
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -9
- package/dist/types.js.map +1 -1
- package/dist/utils/event-stream.d.ts +2 -2
- package/dist/utils/event-stream.d.ts.map +1 -1
- package/dist/utils/event-stream.js +2 -7
- package/dist/utils/event-stream.js.map +1 -1
- package/dist/utils/json-parse.js +3 -6
- package/dist/utils/json-parse.js.map +1 -1
- package/dist/utils/overflow.d.ts +51 -0
- package/dist/utils/overflow.d.ts.map +1 -0
- package/dist/utils/overflow.js +106 -0
- package/dist/utils/overflow.js.map +1 -0
- package/dist/utils/sanitize-unicode.js +1 -4
- package/dist/utils/sanitize-unicode.js.map +1 -1
- package/dist/utils/uuid.d.ts +6 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/uuid.js +9 -0
- package/dist/utils/uuid.js.map +1 -0
- package/dist/utils/validation.d.ts +10 -3
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +20 -12
- package/dist/utils/validation.js.map +1 -1
- package/package.json +47 -8
- package/biome.json +0 -43
- package/dist/agent/agent-loop.d.ts +0 -5
- package/dist/agent/agent-loop.d.ts.map +0 -1
- package/dist/agent/agent-loop.js +0 -219
- package/dist/agent/agent-loop.js.map +0 -1
- package/dist/providers/convert.d.ts +0 -6
- package/dist/providers/convert.d.ts.map +0 -1
- package/dist/providers/convert.js +0 -207
- package/dist/providers/convert.js.map +0 -1
- package/dist/providers/google.d.ts +0 -26
- package/dist/providers/google.d.ts.map +0 -1
- package/dist/providers/google.js.map +0 -1
- package/dist/providers/openai.d.ts +0 -17
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js.map +0 -1
- package/dist/stream.d.ts +0 -4
- package/dist/stream.d.ts.map +0 -1
- package/dist/stream.js +0 -40
- package/dist/stream.js.map +0 -1
- package/dist/test-google-agent-loop.d.ts +0 -2
- package/dist/test-google-agent-loop.d.ts.map +0 -1
- package/dist/test-google-agent-loop.js +0 -186
- package/dist/test-google-agent-loop.js.map +0 -1
- package/dist/test-google.d.ts +0 -2
- package/dist/test-google.d.ts.map +0 -1
- package/dist/test-google.js +0 -41
- package/dist/test-google.js.map +0 -1
- package/src/agent/agent-loop.ts +0 -275
- package/src/agent/types.ts +0 -80
- package/src/index.ts +0 -72
- package/src/models.generated.ts +0 -314
- package/src/models.ts +0 -45
- package/src/providers/convert.ts +0 -222
- package/src/providers/google.ts +0 -496
- package/src/providers/openai.ts +0 -437
- package/src/stream.ts +0 -60
- package/src/types.ts +0 -198
- package/src/utils/event-stream.ts +0 -60
- package/src/utils/json-parse.ts +0 -28
- package/src/utils/sanitize-unicode.ts +0 -25
- package/src/utils/validation.ts +0 -69
- package/test/core/agent-loop.test.ts +0 -958
- package/test/core/stream.test.ts +0 -409
- package/test/data/red-circle.png +0 -0
- package/test/data/superintelligentwill.pdf +0 -0
- package/test/edge-cases/general.test.ts +0 -565
- package/test/integration/e2e.test.ts +0 -530
- package/test/models/cost.test.ts +0 -499
- package/test/models/registry.test.ts +0 -298
- package/test/providers/convert.test.ts +0 -846
- package/test/providers/google-schema.test.ts +0 -666
- package/test/providers/google-stream.test.ts +0 -369
- package/test/providers/openai-stream.test.ts +0 -251
- package/test/utils/event-stream.test.ts +0 -289
- package/test/utils/json-parse.test.ts +0 -344
- package/test/utils/sanitize-unicode.test.ts +0 -329
- package/test/utils/validation.test.ts +0 -614
- package/tsconfig.json +0 -21
- package/vitest.config.ts +0 -9
package/dist/models.js
CHANGED
|
@@ -1,36 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { KnownApis } from "./types.js";
|
|
2
|
+
import { MODELS } from "./models.generated.js";
|
|
3
|
+
import { getApiKeyFromEnv } from "./llm.js";
|
|
4
|
+
export function getProviders() {
|
|
5
|
+
return [...KnownApis];
|
|
6
|
+
}
|
|
7
|
+
export function getModel(api, modelId) {
|
|
8
|
+
const modelsForApi = MODELS[api];
|
|
9
|
+
if (!modelsForApi)
|
|
10
|
+
return undefined;
|
|
11
|
+
// Safe cast: ModelIdsForApi<TApi> guarantees modelId is a valid key for this API's models
|
|
12
|
+
return modelsForApi[modelId];
|
|
13
|
+
}
|
|
14
|
+
export function getModels(api) {
|
|
15
|
+
const modelsForApi = MODELS[api];
|
|
16
|
+
if (!modelsForApi)
|
|
17
|
+
return [];
|
|
18
|
+
return Object.values(modelsForApi);
|
|
13
19
|
}
|
|
14
|
-
|
|
15
|
-
// TProvider extends KnownProvider,
|
|
16
|
-
// TModelId extends keyof (typeof MODELS)[TProvider],
|
|
17
|
-
// > = (typeof MODELS)[TProvider][TModelId] extends { api: infer TApi } ? (TApi extends Api ? TApi : never) : never;
|
|
18
|
-
// export function getModel<TProvider extends KnownProvider, TModelId extends keyof (typeof MODELS)[TProvider]>(
|
|
19
|
-
// provider: TProvider,
|
|
20
|
-
// modelId: TModelId,
|
|
21
|
-
// ): Model<ModelApi<TProvider, TModelId>> {
|
|
22
|
-
// return modelRegistry.get(provider)?.get(modelId as string) as Model<ModelApi<TProvider, TModelId>>;
|
|
23
|
-
// }
|
|
24
|
-
// export function getProviders(): KnownProvider[] {
|
|
25
|
-
// return Array.from(modelRegistry.keys()) as KnownProvider[];
|
|
26
|
-
// }
|
|
27
|
-
// export function getModels<TProvider extends KnownProvider>(
|
|
28
|
-
// provider: TProvider,
|
|
29
|
-
// ): Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[] {
|
|
30
|
-
// const models = modelRegistry.get(provider);
|
|
31
|
-
// return models ? (Array.from(models.values()) as Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[]) : [];
|
|
32
|
-
// }
|
|
33
|
-
function calculateCost(model, usage) {
|
|
20
|
+
export function calculateCost(model, usage) {
|
|
34
21
|
usage.cost.input = (model.cost.input / 1000000) * usage.input;
|
|
35
22
|
usage.cost.output = (model.cost.output / 1000000) * usage.output;
|
|
36
23
|
usage.cost.cacheRead = (model.cost.cacheRead / 1000000) * usage.cacheRead;
|
|
@@ -38,4 +25,15 @@ function calculateCost(model, usage) {
|
|
|
38
25
|
usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
|
|
39
26
|
return usage.cost;
|
|
40
27
|
}
|
|
28
|
+
export function getAvailableModels() {
|
|
29
|
+
const availableModels = [];
|
|
30
|
+
for (const api of KnownApis) {
|
|
31
|
+
const apiKey = getApiKeyFromEnv(api);
|
|
32
|
+
if (apiKey) {
|
|
33
|
+
const modelsForApi = getModels(api);
|
|
34
|
+
availableModels.push(...modelsForApi);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return availableModels;
|
|
38
|
+
}
|
|
41
39
|
//# sourceMappingURL=models.js.map
|
package/dist/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,SAAS,EAAgB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAO5C,MAAM,UAAU,YAAY;IAC3B,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,QAAQ,CACvB,GAAS,EACT,OAA6B;IAE7B,MAAM,YAAY,GAAG,MAAM,CAAC,GAA0B,CAAC,CAAC;IACxD,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IAEpC,0FAA0F;IAC1F,OAAO,YAAY,CAAC,OAAoC,CAA4B,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,SAAS,CAAmB,GAAS;IACpD,MAAM,YAAY,GAAG,MAAM,CAAC,GAA0B,CAAC,CAAC;IACxD,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AC;IAED,OAAO,eAAe,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../../../src/providers/google/complete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAqC,MAAM,gBAAgB,CAAA;AAMpF,eAAO,MAAM,cAAc,EAAC,gBAAgB,CAAC,QAAQ,CA8DpD,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createClient, buildParams, getResponseAssistantResponse, getResponseUsage, getAssistantStopReason } from "./utils.js";
|
|
2
|
+
export const completeGoogle = async (model, context, options, id) => {
|
|
3
|
+
const startTimestamp = Date.now();
|
|
4
|
+
const client = createClient(model, options?.apiKey);
|
|
5
|
+
const params = buildParams(model, context, options);
|
|
6
|
+
try {
|
|
7
|
+
const response = await client.models.generateContent(params);
|
|
8
|
+
// Cache processed content to ensure stable tool call IDs
|
|
9
|
+
const content = getResponseAssistantResponse(response);
|
|
10
|
+
const usage = getResponseUsage(response, model);
|
|
11
|
+
const stopReason = getAssistantStopReason(response);
|
|
12
|
+
return {
|
|
13
|
+
role: "assistant",
|
|
14
|
+
message: response,
|
|
15
|
+
id,
|
|
16
|
+
model,
|
|
17
|
+
api: model.api,
|
|
18
|
+
timestamp: Date.now(),
|
|
19
|
+
duration: Date.now() - startTimestamp,
|
|
20
|
+
stopReason,
|
|
21
|
+
content,
|
|
22
|
+
usage
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
27
|
+
const isAborted = options.signal?.aborted;
|
|
28
|
+
const stopReason = isAborted ? "aborted" : "error";
|
|
29
|
+
// Return error response with empty content and zero usage
|
|
30
|
+
const emptyUsage = {
|
|
31
|
+
input: 0,
|
|
32
|
+
output: 0,
|
|
33
|
+
cacheRead: 0,
|
|
34
|
+
cacheWrite: 0,
|
|
35
|
+
totalTokens: 0,
|
|
36
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
role: "assistant",
|
|
40
|
+
message: {}, // Empty response object for error case
|
|
41
|
+
id,
|
|
42
|
+
model,
|
|
43
|
+
api: model.api,
|
|
44
|
+
errorMessage,
|
|
45
|
+
timestamp: Date.now(),
|
|
46
|
+
duration: Date.now() - startTimestamp,
|
|
47
|
+
stopReason,
|
|
48
|
+
content: [],
|
|
49
|
+
usage: emptyUsage
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=complete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complete.js","sourceRoot":"","sources":["../../../src/providers/google/complete.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAI/H,MAAM,CAAC,MAAM,cAAc,GAA8B,KAAK,EAC1D,KAAsB,EACtB,OAAgB,EAChB,OAA8B,EAC9B,EAAU,EACZ,EAAE;IAEA,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAElC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAEpD,IAAG,CAAC;QACA,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAE7D,yDAAyD;QACzD,MAAM,OAAO,GAAG,4BAA4B,CAAC,QAAQ,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAChD,MAAM,UAAU,GAAG,sBAAsB,CAAC,QAAQ,C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AAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/google/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAC,aAAa,IAAI,mBAAmB,EAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/google/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAC,aAAa,IAAI,mBAAmB,EAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/providers/google/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuJ,MAAM,gBAAgB,CAAA;AAQpM,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,QAAQ,CA0SjD,CAAA"}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const event_stream_1 = require("../utils/event-stream");
|
|
8
|
-
const convert_1 = require("./convert");
|
|
9
|
-
const models_1 = require("../models");
|
|
10
|
-
const validation_1 = require("../utils/validation");
|
|
11
|
-
// Counter for generating unique tool call IDs
|
|
12
|
-
let toolCallCounter = 0;
|
|
13
|
-
const streamGoogle = (model, context, options) => {
|
|
14
|
-
const stream = new event_stream_1.AssistantMessageEventStream();
|
|
1
|
+
import { createClient, buildParams, mapStopReason } from "./utils.js";
|
|
2
|
+
import { AssistantMessageEventStream } from "../../utils/event-stream.js";
|
|
3
|
+
import { validateToolArguments } from "../../utils/validation.js";
|
|
4
|
+
import { calculateCost } from "../../models.js";
|
|
5
|
+
export const streamGoogle = (model, context, options, id) => {
|
|
6
|
+
const stream = new AssistantMessageEventStream();
|
|
15
7
|
(async () => {
|
|
8
|
+
const startTimestamp = Date.now();
|
|
16
9
|
const output = {
|
|
17
10
|
role: "assistant",
|
|
11
|
+
api: model.api,
|
|
12
|
+
model: model,
|
|
13
|
+
id,
|
|
18
14
|
content: [],
|
|
19
|
-
api: "google-generative-ai",
|
|
20
|
-
model: model.id,
|
|
21
15
|
usage: {
|
|
22
16
|
input: 0,
|
|
23
17
|
output: 0,
|
|
@@ -27,7 +21,8 @@ const streamGoogle = (model, context, options) => {
|
|
|
27
21
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
28
22
|
},
|
|
29
23
|
stopReason: "stop",
|
|
30
|
-
timestamp:
|
|
24
|
+
timestamp: startTimestamp,
|
|
25
|
+
duration: 0
|
|
31
26
|
};
|
|
32
27
|
let finalResponse = {
|
|
33
28
|
text: '',
|
|
@@ -36,11 +31,13 @@ const streamGoogle = (model, context, options) => {
|
|
|
36
31
|
executableCode: '',
|
|
37
32
|
codeExecutionResult: ''
|
|
38
33
|
};
|
|
34
|
+
// Counter for generating unique tool call IDs
|
|
35
|
+
let toolCallCounter = 0;
|
|
39
36
|
try {
|
|
40
37
|
const client = createClient(model, options?.apiKey);
|
|
41
38
|
const params = buildParams(model, context, options);
|
|
42
39
|
const googleStream = await client.models.generateContentStream(params);
|
|
43
|
-
stream.push({ type: "start",
|
|
40
|
+
stream.push({ type: "start", message: { ...output, timestamp: Date.now() } });
|
|
44
41
|
let currentBlock = null;
|
|
45
42
|
const blocks = output.content;
|
|
46
43
|
const blockIndex = () => blocks.length - 1;
|
|
@@ -78,84 +75,87 @@ const streamGoogle = (model, context, options) => {
|
|
|
78
75
|
const isThinking = part.thought === true;
|
|
79
76
|
if (!currentBlock ||
|
|
80
77
|
(isThinking && currentBlock.type !== "thinking") ||
|
|
81
|
-
(!isThinking && currentBlock.type !== "
|
|
78
|
+
(!isThinking && currentBlock.type !== "response")) {
|
|
82
79
|
if (currentBlock) {
|
|
83
|
-
if (currentBlock.type === "
|
|
80
|
+
if (currentBlock.type === "response") {
|
|
84
81
|
stream.push({
|
|
85
82
|
type: "text_end",
|
|
86
83
|
contentIndex: blocks.length - 1,
|
|
87
|
-
content: currentBlock.
|
|
88
|
-
|
|
84
|
+
content: currentBlock.content,
|
|
85
|
+
message: { ...output, timestamp: Date.now() },
|
|
89
86
|
});
|
|
90
87
|
}
|
|
91
88
|
else {
|
|
92
89
|
stream.push({
|
|
93
90
|
type: "thinking_end",
|
|
94
91
|
contentIndex: blockIndex(),
|
|
95
|
-
content: currentBlock.
|
|
96
|
-
|
|
92
|
+
content: currentBlock.thinkingText,
|
|
93
|
+
message: { ...output, timestamp: Date.now() },
|
|
97
94
|
});
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
97
|
if (isThinking) {
|
|
101
|
-
currentBlock = { type: "thinking",
|
|
98
|
+
currentBlock = { type: "thinking", thinkingText: "" };
|
|
102
99
|
output.content.push(currentBlock);
|
|
103
|
-
stream.push({ type: "thinking_start", contentIndex: blockIndex(),
|
|
100
|
+
stream.push({ type: "thinking_start", contentIndex: blockIndex(), message: { ...output, timestamp: Date.now() } });
|
|
104
101
|
}
|
|
105
102
|
else {
|
|
106
|
-
currentBlock = { type: "
|
|
103
|
+
currentBlock = { type: "response", content: [{ type: 'text', content: "" }] };
|
|
107
104
|
output.content.push(currentBlock);
|
|
108
|
-
stream.push({ type: "text_start", contentIndex: blockIndex(),
|
|
105
|
+
stream.push({ type: "text_start", contentIndex: blockIndex(), message: { ...output, timestamp: Date.now() } });
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
108
|
if (currentBlock.type === "thinking") {
|
|
112
|
-
currentBlock.
|
|
109
|
+
currentBlock.thinkingText += part.text;
|
|
113
110
|
stream.push({
|
|
114
111
|
type: "thinking_delta",
|
|
115
112
|
contentIndex: blockIndex(),
|
|
116
113
|
delta: part.text,
|
|
117
|
-
|
|
114
|
+
message: { ...output, timestamp: Date.now() },
|
|
118
115
|
});
|
|
119
116
|
}
|
|
120
117
|
else {
|
|
121
|
-
currentBlock.
|
|
118
|
+
const index = currentBlock.content.findIndex((c) => c.type === 'text');
|
|
119
|
+
if (index !== -1) {
|
|
120
|
+
currentBlock.content[index].content += part.text;
|
|
121
|
+
}
|
|
122
122
|
stream.push({
|
|
123
123
|
type: "text_delta",
|
|
124
124
|
contentIndex: blockIndex(),
|
|
125
125
|
delta: part.text,
|
|
126
|
-
|
|
126
|
+
message: { ...output, timestamp: Date.now() },
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
if (part.functionCall) {
|
|
131
131
|
if (currentBlock) {
|
|
132
|
-
if (currentBlock.type === "
|
|
132
|
+
if (currentBlock.type === "response") {
|
|
133
133
|
stream.push({
|
|
134
134
|
type: "text_end",
|
|
135
135
|
contentIndex: blockIndex(),
|
|
136
|
-
content: currentBlock.
|
|
137
|
-
|
|
136
|
+
content: currentBlock.content,
|
|
137
|
+
message: { ...output, timestamp: Date.now() },
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
else {
|
|
141
141
|
stream.push({
|
|
142
142
|
type: "thinking_end",
|
|
143
143
|
contentIndex: blockIndex(),
|
|
144
|
-
content: currentBlock.
|
|
145
|
-
|
|
144
|
+
content: currentBlock.thinkingText,
|
|
145
|
+
message: { ...output, timestamp: Date.now() },
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
currentBlock = null;
|
|
149
149
|
}
|
|
150
150
|
// Generate unique ID if not provided or if it's a duplicate
|
|
151
151
|
const providedId = part.functionCall.id;
|
|
152
|
-
const needsNewId = !providedId || output.content.some((b) => b.type === "toolCall" && b.
|
|
152
|
+
const needsNewId = !providedId || output.content.some((b) => b.type === "toolCall" && b.toolCallId === providedId);
|
|
153
153
|
const toolCallId = needsNewId
|
|
154
154
|
? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}`
|
|
155
155
|
: providedId;
|
|
156
156
|
const toolCall = {
|
|
157
157
|
type: "toolCall",
|
|
158
|
-
|
|
158
|
+
toolCallId: toolCallId,
|
|
159
159
|
name: part.functionCall.name || "",
|
|
160
160
|
arguments: part.functionCall.args,
|
|
161
161
|
...(part.thoughtSignature && { thoughtSignature: part.thoughtSignature }),
|
|
@@ -164,18 +164,18 @@ const streamGoogle = (model, context, options) => {
|
|
|
164
164
|
if (context.tools) {
|
|
165
165
|
const tool = context.tools.find((t) => t.name === toolCall.name);
|
|
166
166
|
if (tool) {
|
|
167
|
-
toolCall.arguments =
|
|
167
|
+
toolCall.arguments = validateToolArguments(tool, toolCall);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
output.content.push(toolCall);
|
|
171
|
-
stream.push({ type: "toolcall_start", contentIndex: blockIndex(),
|
|
171
|
+
stream.push({ type: "toolcall_start", contentIndex: blockIndex(), message: { ...output, timestamp: Date.now() } });
|
|
172
172
|
stream.push({
|
|
173
173
|
type: "toolcall_delta",
|
|
174
174
|
contentIndex: blockIndex(),
|
|
175
175
|
delta: JSON.stringify(toolCall.arguments),
|
|
176
|
-
|
|
176
|
+
message: { ...output, timestamp: Date.now() },
|
|
177
177
|
});
|
|
178
|
-
stream.push({ type: "toolcall_end", contentIndex: blockIndex(), toolCall,
|
|
178
|
+
stream.push({ type: "toolcall_end", contentIndex: blockIndex(), toolCall, message: { ...output, timestamp: Date.now() } });
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -200,24 +200,24 @@ const streamGoogle = (model, context, options) => {
|
|
|
200
200
|
total: 0,
|
|
201
201
|
},
|
|
202
202
|
};
|
|
203
|
-
|
|
203
|
+
calculateCost(model, output.usage);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
if (currentBlock) {
|
|
207
|
-
if (currentBlock.type === "
|
|
207
|
+
if (currentBlock.type === "response") {
|
|
208
208
|
stream.push({
|
|
209
209
|
type: "text_end",
|
|
210
210
|
contentIndex: blockIndex(),
|
|
211
|
-
content: currentBlock.
|
|
212
|
-
|
|
211
|
+
content: currentBlock.content,
|
|
212
|
+
message: { ...output, timestamp: Date.now() },
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
else {
|
|
216
216
|
stream.push({
|
|
217
217
|
type: "thinking_end",
|
|
218
218
|
contentIndex: blockIndex(),
|
|
219
|
-
content: currentBlock.
|
|
220
|
-
|
|
219
|
+
content: currentBlock.thinkingText,
|
|
220
|
+
message: { ...output, timestamp: Date.now() },
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
223
|
}
|
|
@@ -240,195 +240,31 @@ const streamGoogle = (model, context, options) => {
|
|
|
240
240
|
content: messageInputs[i]
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
|
-
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
243
|
+
stream.push({ type: "done", reason: output.stopReason, message: { ...output, timestamp: Date.now() } });
|
|
244
|
+
const baseAssistantMessage = {
|
|
245
|
+
...output,
|
|
246
|
+
message: finalResponse,
|
|
247
|
+
timestamp: Date.now(),
|
|
248
|
+
duration: Date.now() - startTimestamp
|
|
249
|
+
};
|
|
250
|
+
stream.end(baseAssistantMessage);
|
|
249
251
|
}
|
|
250
252
|
catch (error) {
|
|
251
253
|
for (const block of output.content)
|
|
252
254
|
delete block.index;
|
|
253
255
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
254
256
|
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
255
|
-
stream.push({ type: "error", reason: output.stopReason,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
stream.push({ type: "error", reason: output.stopReason, message: { ...output, timestamp: Date.now() } });
|
|
258
|
+
const baseAssistantMessage = {
|
|
259
|
+
...output,
|
|
260
|
+
message: finalResponse,
|
|
261
|
+
timestamp: Date.now(),
|
|
262
|
+
duration: Date.now() - startTimestamp,
|
|
263
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
264
|
+
};
|
|
265
|
+
stream.end(baseAssistantMessage);
|
|
261
266
|
}
|
|
262
267
|
})();
|
|
263
268
|
return stream;
|
|
264
269
|
};
|
|
265
|
-
|
|
266
|
-
function createClient(model, apiKey) {
|
|
267
|
-
if (!apiKey) {
|
|
268
|
-
if (!process.env.GEMINI_API_KEY) {
|
|
269
|
-
throw new Error("Gemini API key is required. Set GEMINI_API_KEY environment variable or pass it as an argument.");
|
|
270
|
-
}
|
|
271
|
-
apiKey = process.env.GEMINI_API_KEY;
|
|
272
|
-
}
|
|
273
|
-
return new genai_1.GoogleGenAI({
|
|
274
|
-
apiKey,
|
|
275
|
-
httpOptions: model.headers ? { headers: model.headers } : undefined,
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
function buildParams(model, context, options) {
|
|
279
|
-
const contents = (0, convert_1.buildGoogleMessages)(model, context);
|
|
280
|
-
const config = {};
|
|
281
|
-
if (options?.signal) {
|
|
282
|
-
config.abortSignal = options.signal;
|
|
283
|
-
}
|
|
284
|
-
if (context.systemPrompt) {
|
|
285
|
-
config.systemInstruction = (0, sanitize_unicode_1.sanitizeSurrogates)(context.systemPrompt);
|
|
286
|
-
}
|
|
287
|
-
if (options?.temperature) {
|
|
288
|
-
config.temperature = options.temperature;
|
|
289
|
-
}
|
|
290
|
-
if (options?.maxOutputTokens) {
|
|
291
|
-
config.maxOutputTokens = options.maxOutputTokens;
|
|
292
|
-
}
|
|
293
|
-
if (options?.responseMimeType) {
|
|
294
|
-
config.responseMimeType = options.responseMimeType;
|
|
295
|
-
}
|
|
296
|
-
if (context.tools) {
|
|
297
|
-
config.tools = convertTools(context.tools);
|
|
298
|
-
}
|
|
299
|
-
if (options?.thinkingConfig) {
|
|
300
|
-
config.thinkingConfig = {
|
|
301
|
-
includeThoughts: true,
|
|
302
|
-
thinkingLevel: options.thinkingConfig.thinkingLevel
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
if (options?.imageConfig) {
|
|
306
|
-
config.imageConfig = {
|
|
307
|
-
imageSize: options.imageConfig.imageSize,
|
|
308
|
-
aspectRatio: options.imageConfig.aspectRatio
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
const params = {
|
|
312
|
-
model: model.id,
|
|
313
|
-
contents,
|
|
314
|
-
config
|
|
315
|
-
};
|
|
316
|
-
return params;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Transforms a JSON Schema to Google's supported subset.
|
|
320
|
-
* Main transformations:
|
|
321
|
-
* - Converts { "const": "value" } to { "enum": ["value"] }
|
|
322
|
-
* - Converts { "anyOf": [{ "const": "a" }, { "const": "b" }] } to { "enum": ["a", "b"] }
|
|
323
|
-
* - Recursively processes nested objects and arrays
|
|
324
|
-
*/
|
|
325
|
-
function transformSchemaForGoogle(schema) {
|
|
326
|
-
if (!schema || typeof schema !== 'object') {
|
|
327
|
-
return schema;
|
|
328
|
-
}
|
|
329
|
-
// Handle arrays
|
|
330
|
-
if (Array.isArray(schema)) {
|
|
331
|
-
return schema.map(transformSchemaForGoogle);
|
|
332
|
-
}
|
|
333
|
-
const transformed = {};
|
|
334
|
-
// Handle const keyword - convert to enum
|
|
335
|
-
if ('const' in schema) {
|
|
336
|
-
transformed.enum = [schema.const];
|
|
337
|
-
// Copy over other properties except const
|
|
338
|
-
for (const key in schema) {
|
|
339
|
-
if (key !== 'const') {
|
|
340
|
-
transformed[key] = schema[key];
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return transformed;
|
|
344
|
-
}
|
|
345
|
-
// Handle anyOf with const values - convert to enum
|
|
346
|
-
if ('anyOf' in schema && Array.isArray(schema.anyOf) && schema.anyOf.length > 0) {
|
|
347
|
-
const allConst = schema.anyOf.every((item) => item && typeof item === 'object' && 'const' in item);
|
|
348
|
-
if (allConst) {
|
|
349
|
-
// Extract all const values into a single enum
|
|
350
|
-
transformed.enum = schema.anyOf.map((item) => item.const);
|
|
351
|
-
// Copy over other properties from the parent schema
|
|
352
|
-
for (const key in schema) {
|
|
353
|
-
if (key !== 'anyOf') {
|
|
354
|
-
transformed[key] = schema[key];
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
// Copy type and other properties from the first anyOf item if not already set
|
|
358
|
-
if (schema.anyOf.length > 0) {
|
|
359
|
-
const firstItem = schema.anyOf[0];
|
|
360
|
-
for (const key in firstItem) {
|
|
361
|
-
if (key !== 'const' && !(key in transformed)) {
|
|
362
|
-
transformed[key] = firstItem[key];
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
return transformed;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
// Recursively process all properties
|
|
370
|
-
for (const key in schema) {
|
|
371
|
-
if (key === 'properties' && typeof schema.properties === 'object') {
|
|
372
|
-
// Recursively transform each property
|
|
373
|
-
transformed.properties = {};
|
|
374
|
-
for (const propKey in schema.properties) {
|
|
375
|
-
transformed.properties[propKey] = transformSchemaForGoogle(schema.properties[propKey]);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
else if (key === 'items' && schema.items) {
|
|
379
|
-
// Recursively transform array items schema
|
|
380
|
-
transformed.items = transformSchemaForGoogle(schema.items);
|
|
381
|
-
}
|
|
382
|
-
else if (key === 'anyOf' || key === 'oneOf' || key === 'allOf') {
|
|
383
|
-
// Recursively transform union/intersection schemas
|
|
384
|
-
transformed[key] = Array.isArray(schema[key])
|
|
385
|
-
? schema[key].map(transformSchemaForGoogle)
|
|
386
|
-
: transformSchemaForGoogle(schema[key]);
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
// Copy other properties as-is
|
|
390
|
-
transformed[key] = schema[key];
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return transformed;
|
|
394
|
-
}
|
|
395
|
-
function convertTools(tools) {
|
|
396
|
-
if (tools.length === 0)
|
|
397
|
-
return undefined;
|
|
398
|
-
return [
|
|
399
|
-
{
|
|
400
|
-
functionDeclarations: tools.map((tool) => ({
|
|
401
|
-
name: tool.name,
|
|
402
|
-
description: tool.description,
|
|
403
|
-
parameters: transformSchemaForGoogle(tool.parameters),
|
|
404
|
-
})),
|
|
405
|
-
},
|
|
406
|
-
];
|
|
407
|
-
}
|
|
408
|
-
function mapStopReason(reason) {
|
|
409
|
-
switch (reason) {
|
|
410
|
-
case genai_1.FinishReason.STOP:
|
|
411
|
-
return "stop";
|
|
412
|
-
case genai_1.FinishReason.MAX_TOKENS:
|
|
413
|
-
return "length";
|
|
414
|
-
case genai_1.FinishReason.BLOCKLIST:
|
|
415
|
-
case genai_1.FinishReason.PROHIBITED_CONTENT:
|
|
416
|
-
case genai_1.FinishReason.SPII:
|
|
417
|
-
case genai_1.FinishReason.SAFETY:
|
|
418
|
-
case genai_1.FinishReason.IMAGE_SAFETY:
|
|
419
|
-
case genai_1.FinishReason.IMAGE_PROHIBITED_CONTENT:
|
|
420
|
-
case genai_1.FinishReason.RECITATION:
|
|
421
|
-
case genai_1.FinishReason.FINISH_REASON_UNSPECIFIED:
|
|
422
|
-
case genai_1.FinishReason.OTHER:
|
|
423
|
-
case genai_1.FinishReason.LANGUAGE:
|
|
424
|
-
case genai_1.FinishReason.MALFORMED_FUNCTION_CALL:
|
|
425
|
-
case genai_1.FinishReason.UNEXPECTED_TOOL_CALL:
|
|
426
|
-
case genai_1.FinishReason.NO_IMAGE:
|
|
427
|
-
return "error";
|
|
428
|
-
default: {
|
|
429
|
-
const _exhaustive = reason;
|
|
430
|
-
throw new Error(`Unhandled stop reason: ${_exhaustive}`);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
//# sourceMappingURL=google.js.map
|
|
270
|
+
//# sourceMappingURL=stream.js.map
|
|
@@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