@loonylabs/tti-middleware 1.4.0 → 1.4.1
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/middleware/services/tti/providers/base-tti-provider.d.ts +2 -1
- package/dist/middleware/services/tti/providers/base-tti-provider.js +2 -1
- package/dist/middleware/services/tti/providers/google-cloud-provider.js +8 -3
- package/dist/middleware/services/tti/utils/debug-tti.utils.d.ts +2 -0
- package/dist/middleware/services/tti/utils/debug-tti.utils.js +4 -0
- package/package.json +1 -1
|
@@ -22,7 +22,8 @@ export declare class ProviderUnavailableError extends TTIError {
|
|
|
22
22
|
constructor(provider: string, message?: string, cause?: Error);
|
|
23
23
|
}
|
|
24
24
|
export declare class GenerationFailedError extends TTIError {
|
|
25
|
-
|
|
25
|
+
readonly modelResponse?: string;
|
|
26
|
+
constructor(provider: string, message: string, cause?: Error, modelResponse?: string);
|
|
26
27
|
}
|
|
27
28
|
export declare class NetworkError extends TTIError {
|
|
28
29
|
constructor(provider: string, message: string, cause?: Error);
|
|
@@ -55,9 +55,10 @@ class ProviderUnavailableError extends TTIError {
|
|
|
55
55
|
}
|
|
56
56
|
exports.ProviderUnavailableError = ProviderUnavailableError;
|
|
57
57
|
class GenerationFailedError extends TTIError {
|
|
58
|
-
constructor(provider, message, cause) {
|
|
58
|
+
constructor(provider, message, cause, modelResponse) {
|
|
59
59
|
super(provider, 'GENERATION_FAILED', message, cause);
|
|
60
60
|
this.name = 'GenerationFailedError';
|
|
61
|
+
this.modelResponse = modelResponse;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
exports.GenerationFailedError = GenerationFailedError;
|
|
@@ -486,9 +486,12 @@ IMPORTANT: Maintain exact visual consistency with the subject in the reference -
|
|
|
486
486
|
}
|
|
487
487
|
if (images.length === 0) {
|
|
488
488
|
const firstParts = candidates[0]?.content?.parts || [];
|
|
489
|
+
const fullTexts = [];
|
|
489
490
|
const partTypes = firstParts.map((p) => {
|
|
490
|
-
if (p.text)
|
|
491
|
-
|
|
491
|
+
if (p.text) {
|
|
492
|
+
fullTexts.push(p.text);
|
|
493
|
+
return `text(${p.text.substring(0, 200)}${p.text.length > 200 ? '...' : ''})`;
|
|
494
|
+
}
|
|
492
495
|
if (p.inlineData)
|
|
493
496
|
return `inlineData(${p.inlineData.mimeType})`;
|
|
494
497
|
return 'unknown';
|
|
@@ -496,9 +499,11 @@ IMPORTANT: Maintain exact visual consistency with the subject in the reference -
|
|
|
496
499
|
this.log('error', 'No images in Gemini response', {
|
|
497
500
|
candidateCount: candidates.length,
|
|
498
501
|
partTypes,
|
|
502
|
+
...(fullTexts.length > 0 && { modelResponse: fullTexts.join('\n') }),
|
|
499
503
|
});
|
|
504
|
+
const fullModelResponse = fullTexts.length > 0 ? fullTexts.join('\n') : undefined;
|
|
500
505
|
throw new base_tti_provider_1.GenerationFailedError(this.providerName, `No images in response. Model returned: ${partTypes.join(', ')}. ` +
|
|
501
|
-
'Make sure responseModalities includes IMAGE.');
|
|
506
|
+
'Make sure responseModalities includes IMAGE.', undefined, fullModelResponse);
|
|
502
507
|
}
|
|
503
508
|
const usage = {
|
|
504
509
|
imagesGenerated: images.length,
|
|
@@ -45,6 +45,7 @@ export interface TTIDebugInfo {
|
|
|
45
45
|
message: string;
|
|
46
46
|
code?: string;
|
|
47
47
|
details?: unknown;
|
|
48
|
+
modelResponse?: string;
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
@@ -145,6 +146,7 @@ export declare class TTIDebugger {
|
|
|
145
146
|
static updateWithError(debugInfo: TTIDebugInfo, error: Error & {
|
|
146
147
|
code?: string;
|
|
147
148
|
cause?: unknown;
|
|
149
|
+
modelResponse?: string;
|
|
148
150
|
}): TTIDebugInfo;
|
|
149
151
|
}
|
|
150
152
|
export default TTIDebugger;
|
|
@@ -297,6 +297,9 @@ class TTIDebugger {
|
|
|
297
297
|
if (debugInfo.error.code) {
|
|
298
298
|
sections.push(`- **Code**: ${debugInfo.error.code}`);
|
|
299
299
|
}
|
|
300
|
+
if (debugInfo.error.modelResponse) {
|
|
301
|
+
sections.push(`- **Model Response**: ${debugInfo.error.modelResponse}`);
|
|
302
|
+
}
|
|
300
303
|
if (debugInfo.error.details) {
|
|
301
304
|
sections.push('- **Details**:');
|
|
302
305
|
sections.push('```json');
|
|
@@ -401,6 +404,7 @@ class TTIDebugger {
|
|
|
401
404
|
message: error.message,
|
|
402
405
|
code: error.code,
|
|
403
406
|
details: error.cause,
|
|
407
|
+
modelResponse: error.modelResponse,
|
|
404
408
|
},
|
|
405
409
|
};
|
|
406
410
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loonylabs/tti-middleware",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Provider-agnostic Text-to-Image middleware with GDPR compliance. Supports Google Cloud (Imagen, Gemini), Eden AI, and IONOS.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|