@steve31415/baselib 3.39.1 → 3.40.0
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/llm/complete.js
CHANGED
|
@@ -83,6 +83,7 @@ export async function llmComplete(request) {
|
|
|
83
83
|
continue;
|
|
84
84
|
}
|
|
85
85
|
const provider = providers[modelEntry.provider];
|
|
86
|
+
const attemptStartedAt = Date.now();
|
|
86
87
|
try {
|
|
87
88
|
const result = await provider.complete({
|
|
88
89
|
apiModelId: modelEntry.apiModelId,
|
|
@@ -124,6 +125,7 @@ export async function llmComplete(request) {
|
|
|
124
125
|
fallbackModel: modelName,
|
|
125
126
|
fallbackProvider: modelEntry.provider,
|
|
126
127
|
attemptsBeforeSuccess: failedAttempts.length,
|
|
128
|
+
...(request.callSite ? { callSite: request.callSite } : {}),
|
|
127
129
|
});
|
|
128
130
|
}
|
|
129
131
|
return {
|
|
@@ -162,6 +164,12 @@ export async function llmComplete(request) {
|
|
|
162
164
|
declined: err instanceof LLMError && err.declined === true,
|
|
163
165
|
attemptNumber: failedAttempts.length,
|
|
164
166
|
nextModel: modelsToTry[failedAttempts.length] ?? 'none',
|
|
167
|
+
// Which caller, and whether it ran out its own deadline: a timeout tail is a
|
|
168
|
+
// headroom question for that call site, an HTTP error is not (reader task 58b65ec9).
|
|
169
|
+
...(request.callSite ? { callSite: request.callSite } : {}),
|
|
170
|
+
timedOut: err instanceof LLMError && err.timedOut === true,
|
|
171
|
+
timeoutMs,
|
|
172
|
+
attemptMs: Date.now() - attemptStartedAt,
|
|
165
173
|
});
|
|
166
174
|
}
|
|
167
175
|
}
|
package/dist/llm/types.d.ts
CHANGED
|
@@ -155,6 +155,8 @@ export declare class LLMError extends Error {
|
|
|
155
155
|
* not a defect.
|
|
156
156
|
*/
|
|
157
157
|
declined: boolean;
|
|
158
|
+
/** True when the attempt hit its per-provider `timeoutMs` deadline. */
|
|
159
|
+
timedOut: boolean;
|
|
158
160
|
constructor(opts: {
|
|
159
161
|
message: string;
|
|
160
162
|
provider: ProviderName;
|
|
@@ -162,6 +164,7 @@ export declare class LLMError extends Error {
|
|
|
162
164
|
statusCode?: number;
|
|
163
165
|
isRetryable: boolean;
|
|
164
166
|
declined?: boolean;
|
|
167
|
+
timedOut?: boolean;
|
|
165
168
|
});
|
|
166
169
|
}
|
|
167
170
|
export interface ProviderAdapter {
|
package/dist/llm/types.js
CHANGED
|
@@ -20,6 +20,8 @@ export class LLMError extends Error {
|
|
|
20
20
|
* not a defect.
|
|
21
21
|
*/
|
|
22
22
|
declined;
|
|
23
|
+
/** True when the attempt hit its per-provider `timeoutMs` deadline. */
|
|
24
|
+
timedOut;
|
|
23
25
|
constructor(opts) {
|
|
24
26
|
super(opts.message);
|
|
25
27
|
this.name = 'LLMError';
|
|
@@ -28,5 +30,6 @@ export class LLMError extends Error {
|
|
|
28
30
|
this.statusCode = opts.statusCode;
|
|
29
31
|
this.isRetryable = opts.isRetryable;
|
|
30
32
|
this.declined = opts.declined ?? false;
|
|
33
|
+
this.timedOut = opts.timedOut ?? false;
|
|
31
34
|
}
|
|
32
35
|
}
|
package/package.json
CHANGED