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.d.mts
CHANGED
|
@@ -257,6 +257,13 @@ interface GenericPayload {
|
|
|
257
257
|
* adapters. Forwarded as the request body's `provider` field.
|
|
258
258
|
*/
|
|
259
259
|
provider?: OpenRouterProviderPreferences;
|
|
260
|
+
/**
|
|
261
|
+
* Per-request HTTP timeout in ms for the underlying provider call (applied
|
|
262
|
+
* per attempt, not across retries). Currently honored by the Google adapter;
|
|
263
|
+
* defaults to 60s when omitted. Raise it for slow, large generations (e.g.
|
|
264
|
+
* single-file app codegen) so a long-but-valid response isn't cut short.
|
|
265
|
+
*/
|
|
266
|
+
requestTimeoutMs?: number;
|
|
260
267
|
}
|
|
261
268
|
|
|
262
269
|
declare function parseModelString(model: string): {
|
package/dist/index.d.ts
CHANGED
|
@@ -257,6 +257,13 @@ interface GenericPayload {
|
|
|
257
257
|
* adapters. Forwarded as the request body's `provider` field.
|
|
258
258
|
*/
|
|
259
259
|
provider?: OpenRouterProviderPreferences;
|
|
260
|
+
/**
|
|
261
|
+
* Per-request HTTP timeout in ms for the underlying provider call (applied
|
|
262
|
+
* per attempt, not across retries). Currently honored by the Google adapter;
|
|
263
|
+
* defaults to 60s when omitted. Raise it for slow, large generations (e.g.
|
|
264
|
+
* single-file app codegen) so a long-but-valid response isn't cut short.
|
|
265
|
+
*/
|
|
266
|
+
requestTimeoutMs?: number;
|
|
260
267
|
}
|
|
261
268
|
|
|
262
269
|
declare function parseModelString(model: string): {
|
package/dist/index.js
CHANGED
|
@@ -874,6 +874,7 @@ async function prepareGoogleAIPayload(_identifier, payload) {
|
|
|
874
874
|
const preparedPayload = {
|
|
875
875
|
model: payload.model,
|
|
876
876
|
messages: [],
|
|
877
|
+
requestTimeoutMs: payload.requestTimeoutMs,
|
|
877
878
|
tools: payload.functions ? {
|
|
878
879
|
functionDeclarations: payload.functions.map((fn) => ({
|
|
879
880
|
name: fn.name,
|
|
@@ -959,7 +960,7 @@ async function prepareGoogleAIPayload(_identifier, payload) {
|
|
|
959
960
|
return preparedPayload;
|
|
960
961
|
}
|
|
961
962
|
async function callGoogleAI(id, payload) {
|
|
962
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
963
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
963
964
|
const contents = jigGoogleMessages(payload.messages);
|
|
964
965
|
const requestBody = {
|
|
965
966
|
contents,
|
|
@@ -982,47 +983,50 @@ async function callGoogleAI(id, payload) {
|
|
|
982
983
|
"content-type": "application/json",
|
|
983
984
|
"x-goog-api-key": process.env.GEMINI_API_KEY
|
|
984
985
|
},
|
|
985
|
-
timeout
|
|
986
|
+
// Per-attempt timeout. Defaults to 60s; callers pass a larger value via
|
|
987
|
+
// payload.requestTimeoutMs for slow, large generations (e.g. single-file
|
|
988
|
+
// app codegen) so a long-but-valid response isn't cut short.
|
|
989
|
+
timeout: (_a = payload.requestTimeoutMs) != null ? _a : 6e4
|
|
986
990
|
}
|
|
987
991
|
);
|
|
988
992
|
response = httpResponse.data;
|
|
989
993
|
} catch (err) {
|
|
990
|
-
const apiError = (
|
|
994
|
+
const apiError = (_c = (_b = err == null ? void 0 : err.response) == null ? void 0 : _b.data) == null ? void 0 : _c.error;
|
|
991
995
|
const wrapped = new Error(
|
|
992
996
|
(apiError == null ? void 0 : apiError.message) || (err == null ? void 0 : err.message) || "Google AI API request failed"
|
|
993
997
|
);
|
|
994
|
-
wrapped.status = (
|
|
998
|
+
wrapped.status = (_e = apiError == null ? void 0 : apiError.status) != null ? _e : (_d = err == null ? void 0 : err.response) == null ? void 0 : _d.status;
|
|
995
999
|
wrapped.code = apiError == null ? void 0 : apiError.code;
|
|
996
1000
|
wrapped.details = apiError == null ? void 0 : apiError.details;
|
|
997
|
-
wrapped.promptFeedback = (
|
|
1001
|
+
wrapped.promptFeedback = (_g = (_f = err == null ? void 0 : err.response) == null ? void 0 : _f.data) == null ? void 0 : _g.promptFeedback;
|
|
998
1002
|
throw wrapped;
|
|
999
1003
|
}
|
|
1000
1004
|
let text = "";
|
|
1001
1005
|
const files = [];
|
|
1002
1006
|
const reasoningParts = [];
|
|
1003
1007
|
const functionCalls = [];
|
|
1004
|
-
for (const part of ((
|
|
1008
|
+
for (const part of ((_j = (_i = (_h = response.candidates) == null ? void 0 : _h[0]) == null ? void 0 : _i.content) == null ? void 0 : _j.parts) || []) {
|
|
1005
1009
|
if (part.thought) {
|
|
1006
1010
|
reasoningParts.push(part);
|
|
1007
1011
|
continue;
|
|
1008
1012
|
}
|
|
1009
1013
|
if (part.functionCall) {
|
|
1010
1014
|
functionCalls.push({
|
|
1011
|
-
id: (
|
|
1012
|
-
name: (
|
|
1013
|
-
arguments: (
|
|
1015
|
+
id: (_k = part.functionCall.id) != null ? _k : `call_${functionCalls.length}`,
|
|
1016
|
+
name: (_l = part.functionCall.name) != null ? _l : "",
|
|
1017
|
+
arguments: (_m = part.functionCall.args) != null ? _m : {},
|
|
1014
1018
|
thoughtSignature: part.thoughtSignature
|
|
1015
1019
|
});
|
|
1016
1020
|
continue;
|
|
1017
1021
|
}
|
|
1018
1022
|
if (part.text)
|
|
1019
1023
|
text += part.text;
|
|
1020
|
-
if ((
|
|
1024
|
+
if ((_n = part.inlineData) == null ? void 0 : _n.data) {
|
|
1021
1025
|
files.push({ mimeType: "image/png", data: part.inlineData.data });
|
|
1022
1026
|
}
|
|
1023
1027
|
}
|
|
1024
1028
|
if (!text && !functionCalls.length && !files.length) {
|
|
1025
|
-
const candidate = (
|
|
1029
|
+
const candidate = (_o = response.candidates) == null ? void 0 : _o[0];
|
|
1026
1030
|
const finishReason = candidate == null ? void 0 : candidate.finishReason;
|
|
1027
1031
|
logger_default.error(id, "Missing text & functions in Google AI API response:", {
|
|
1028
1032
|
finishReason,
|
|
@@ -1057,10 +1061,10 @@ async function callGoogleAI(id, payload) {
|
|
|
1057
1061
|
function_calls: functionCalls,
|
|
1058
1062
|
reasoningDetails: reasoningParts.length ? reasoningParts : void 0,
|
|
1059
1063
|
usage: response.usageMetadata ? {
|
|
1060
|
-
prompt_tokens: (
|
|
1061
|
-
completion_tokens: (
|
|
1062
|
-
total_tokens: (
|
|
1063
|
-
cached_tokens: (
|
|
1064
|
+
prompt_tokens: (_p = response.usageMetadata.promptTokenCount) != null ? _p : 0,
|
|
1065
|
+
completion_tokens: (_q = response.usageMetadata.candidatesTokenCount) != null ? _q : 0,
|
|
1066
|
+
total_tokens: (_r = response.usageMetadata.totalTokenCount) != null ? _r : 0,
|
|
1067
|
+
cached_tokens: (_s = response.usageMetadata.cachedContentTokenCount) != null ? _s : 0
|
|
1064
1068
|
} : null
|
|
1065
1069
|
};
|
|
1066
1070
|
}
|