feat: add reset progress and flagged media analysis

This commit is contained in:
Jamie Brunton committed 2026-01-03 13:08:23 +00:00
1 parent a7e29682c1
commit 7e686c147a
15 files changed
+1049 -215

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
import { getOpenAI, getModel } from '../client';
export async function describeImage(imageBase64OrUrl: string): Promise<string> {
const openai = getOpenAI();
const model = getModel('describe_image');
// If it's a data URL or http URL, use it as is.
// If it's raw base64, prepend the data URI scheme.
let imageUrl = imageBase64OrUrl;
if (!imageBase64OrUrl.startsWith('http') && !imageBase64OrUrl.startsWith('data:')) {
imageUrl = `data:image/jpeg;base64,${imageBase64OrUrl}`;
}
try {
const response = await openai.chat.completions.create({
model: model,
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Describe this image in detail. Focus on any potentially inappropriate content or safety concerns.' },
{
type: 'image_url',
image_url: {
"url": imageUrl,
},
},
],
},
],
max_tokens: 300,
});
return response.choices[0].message.content || 'No description available.';
} catch (error) {
console.error('Error describing image:', error);
throw error;
}
}