piclets / src /lib /services /enhancedCaption.ts
Fraser's picture
fix
ce1f183
import type { GradioClient } from '$lib/types';
export interface EnhancedCaptionResult {
caption: string; // Detailed scene description with specific objects/brands
}
export class EnhancedCaptionService {
/**
* Generate a detailed scene description for GPT-OSS to parse
*/
static async generateEnhancedCaption(
client: GradioClient,
image: Blob | File
): Promise<EnhancedCaptionResult> {
try {
const result = await client.predict("/stream_chat", [
image,
"Descriptive",
"medium-length",
[],
"",
"Describe this image in detail, identifying any recognizable objects, brands, logos, or specific models. Be specific about product names and types."
]);
const caption = result.data[1] as string;
return {
caption
};
} catch (error) {
console.error('Caption generation failed:', error);
throw error;
}
}
}