From 83217a3905f0c9782c4e68c6947eb89cfd4cdc74 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Tue, 19 Mar 2024 23:47:07 -0500 Subject: [PATCH] Add descriptions of different lengths --- src/photo/ai/index.ts | 12 ++++++++++-- src/photo/form/PhotoForm.tsx | 36 +++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/photo/ai/index.ts b/src/photo/ai/index.ts index b6fa7d07..a2ea7b8e 100644 --- a/src/photo/ai/index.ts +++ b/src/photo/ai/index.ts @@ -1,12 +1,20 @@ import { streamOpenAiImageQuery } from '@/services/openai'; -export type ImageQuery = 'title' | 'caption' | 'tags' | 'description'; +export type ImageQuery = + 'title' | + 'caption' | + 'tags' | + 'descriptionSmall' | + 'descriptionMedium' | + 'descriptionLarge'; export const IMAGE_QUERIES: Record = { title: 'Provide a short title for this image', caption: 'What is the caption of this image?', tags: 'Describe this image three or less comma-separated keywords', - description: 'Describe this image in detail', + descriptionSmall: 'Describe this image succinctly', + descriptionMedium: 'Describe this image', + descriptionLarge: 'Describe this image in detail', }; export const streamImageQuery = (imageBase64: string, query: ImageQuery) => diff --git a/src/photo/form/PhotoForm.tsx b/src/photo/form/PhotoForm.tsx index 6b5b9ba5..5faac6b7 100644 --- a/src/photo/form/PhotoForm.tsx +++ b/src/photo/form/PhotoForm.tsx @@ -131,10 +131,16 @@ export default function PhotoForm({ ] = useImageQuery(imageData, 'tags'); const [ - requestDescription, - description, - isLoadingDescription, - ] = useImageQuery(imageData, 'description'); + requestDescriptionSmall, + descriptionSmall, + isLoadingDescriptionSmall, + ] = useImageQuery(imageData, 'descriptionSmall'); + + const [ + requestDescriptionLarge, + descriptionLarge, + isLoadingDescriptionLarge, + ] = useImageQuery(imageData, 'descriptionLarge'); return (
@@ -145,8 +151,17 @@ export default function PhotoForm({ - +
@@ -195,7 +210,14 @@ export default function PhotoForm({ }

- ✨ DESCRIPTION: {description} {isLoadingDescription && <> + ✨ DESCRIPTION (S): {descriptionSmall} {isLoadingDescriptionSmall && <> + + + + } +

+

+ ✨ DESCRIPTION (L): {descriptionLarge} {isLoadingDescriptionLarge && <>