190proof 1.0.97 → 1.0.98
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/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +19 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -843,6 +843,7 @@ async function prepareGoogleAIPayload(_identifier, payload) {
|
|
|
843
843
|
const preparedPayload = {
|
|
844
844
|
model: payload.model,
|
|
845
845
|
messages: [],
|
|
846
|
+
requestTimeoutMs: payload.requestTimeoutMs,
|
|
846
847
|
tools: payload.functions ? {
|
|
847
848
|
functionDeclarations: payload.functions.map((fn) => ({
|
|
848
849
|
name: fn.name,
|
|
@@ -928,7 +929,7 @@ async function prepareGoogleAIPayload(_identifier, payload) {
|
|
|
928
929
|
return preparedPayload;
|
|
929
930
|
}
|
|
930
931
|
async function callGoogleAI(id, payload) {
|
|
931
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
932
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
932
933
|
const contents = jigGoogleMessages(payload.messages);
|
|
933
934
|
const requestBody = {
|
|
934
935
|
contents,
|
|
@@ -951,47 +952,50 @@ async function callGoogleAI(id, payload) {
|
|
|
951
952
|
"content-type": "application/json",
|
|
952
953
|
"x-goog-api-key": process.env.GEMINI_API_KEY
|
|
953
954
|
},
|
|
954
|
-
timeout
|
|
955
|
+
// Per-attempt timeout. Defaults to 60s; callers pass a larger value via
|
|
956
|
+
// payload.requestTimeoutMs for slow, large generations (e.g. single-file
|
|
957
|
+
// app codegen) so a long-but-valid response isn't cut short.
|
|
958
|
+
timeout: (_a = payload.requestTimeoutMs) != null ? _a : 6e4
|
|
955
959
|
}
|
|
956
960
|
);
|
|
957
961
|
response = httpResponse.data;
|
|
958
962
|
} catch (err) {
|
|
959
|
-
const apiError = (
|
|
963
|
+
const apiError = (_c = (_b = err == null ? void 0 : err.response) == null ? void 0 : _b.data) == null ? void 0 : _c.error;
|
|
960
964
|
const wrapped = new Error(
|
|
961
965
|
(apiError == null ? void 0 : apiError.message) || (err == null ? void 0 : err.message) || "Google AI API request failed"
|
|
962
966
|
);
|
|
963
|
-
wrapped.status = (
|
|
967
|
+
wrapped.status = (_e = apiError == null ? void 0 : apiError.status) != null ? _e : (_d = err == null ? void 0 : err.response) == null ? void 0 : _d.status;
|
|
964
968
|
wrapped.code = apiError == null ? void 0 : apiError.code;
|
|
965
969
|
wrapped.details = apiError == null ? void 0 : apiError.details;
|
|
966
|
-
wrapped.promptFeedback = (
|
|
970
|
+
wrapped.promptFeedback = (_g = (_f = err == null ? void 0 : err.response) == null ? void 0 : _f.data) == null ? void 0 : _g.promptFeedback;
|
|
967
971
|
throw wrapped;
|
|
968
972
|
}
|
|
969
973
|
let text = "";
|
|
970
974
|
const files = [];
|
|
971
975
|
const reasoningParts = [];
|
|
972
976
|
const functionCalls = [];
|
|
973
|
-
for (const part of ((
|
|
977
|
+
for (const part of ((_j = (_i = (_h = response.candidates) == null ? void 0 : _h[0]) == null ? void 0 : _i.content) == null ? void 0 : _j.parts) || []) {
|
|
974
978
|
if (part.thought) {
|
|
975
979
|
reasoningParts.push(part);
|
|
976
980
|
continue;
|
|
977
981
|
}
|
|
978
982
|
if (part.functionCall) {
|
|
979
983
|
functionCalls.push({
|
|
980
|
-
id: (
|
|
981
|
-
name: (
|
|
982
|
-
arguments: (
|
|
984
|
+
id: (_k = part.functionCall.id) != null ? _k : `call_${functionCalls.length}`,
|
|
985
|
+
name: (_l = part.functionCall.name) != null ? _l : "",
|
|
986
|
+
arguments: (_m = part.functionCall.args) != null ? _m : {},
|
|
983
987
|
thoughtSignature: part.thoughtSignature
|
|
984
988
|
});
|
|
985
989
|
continue;
|
|
986
990
|
}
|
|
987
991
|
if (part.text)
|
|
988
992
|
text += part.text;
|
|
989
|
-
if ((
|
|
993
|
+
if ((_n = part.inlineData) == null ? void 0 : _n.data) {
|
|
990
994
|
files.push({ mimeType: "image/png", data: part.inlineData.data });
|
|
991
995
|
}
|
|
992
996
|
}
|
|
993
997
|
if (!text && !functionCalls.length && !files.length) {
|
|
994
|
-
const candidate = (
|
|
998
|
+
const candidate = (_o = response.candidates) == null ? void 0 : _o[0];
|
|
995
999
|
const finishReason = candidate == null ? void 0 : candidate.finishReason;
|
|
996
1000
|
logger_default.error(id, "Missing text & functions in Google AI API response:", {
|
|
997
1001
|
finishReason,
|
|
@@ -1026,10 +1030,10 @@ async function callGoogleAI(id, payload) {
|
|
|
1026
1030
|
function_calls: functionCalls,
|
|
1027
1031
|
reasoningDetails: reasoningParts.length ? reasoningParts : void 0,
|
|
1028
1032
|
usage: response.usageMetadata ? {
|
|
1029
|
-
prompt_tokens: (
|
|
1030
|
-
completion_tokens: (
|
|
1031
|
-
total_tokens: (
|
|
1032
|
-
cached_tokens: (
|
|
1033
|
+
prompt_tokens: (_p = response.usageMetadata.promptTokenCount) != null ? _p : 0,
|
|
1034
|
+
completion_tokens: (_q = response.usageMetadata.candidatesTokenCount) != null ? _q : 0,
|
|
1035
|
+
total_tokens: (_r = response.usageMetadata.totalTokenCount) != null ? _r : 0,
|
|
1036
|
+
cached_tokens: (_s = response.usageMetadata.cachedContentTokenCount) != null ? _s : 0
|
|
1033
1037
|
} : null
|
|
1034
1038
|
};
|
|
1035
1039
|
}
|