Add descriptions of different lengths
This commit is contained in:
parent
f39fa417b8
commit
83217a3905
@ -1,12 +1,20 @@
|
|||||||
import { streamOpenAiImageQuery } from '@/services/openai';
|
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<ImageQuery, string> = {
|
export const IMAGE_QUERIES: Record<ImageQuery, string> = {
|
||||||
title: 'Provide a short title for this image',
|
title: 'Provide a short title for this image',
|
||||||
caption: 'What is the caption of this image?',
|
caption: 'What is the caption of this image?',
|
||||||
tags: 'Describe this image three or less comma-separated keywords',
|
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) =>
|
export const streamImageQuery = (imageBase64: string, query: ImageQuery) =>
|
||||||
|
|||||||
@ -131,10 +131,16 @@ export default function PhotoForm({
|
|||||||
] = useImageQuery(imageData, 'tags');
|
] = useImageQuery(imageData, 'tags');
|
||||||
|
|
||||||
const [
|
const [
|
||||||
requestDescription,
|
requestDescriptionSmall,
|
||||||
description,
|
descriptionSmall,
|
||||||
isLoadingDescription,
|
isLoadingDescriptionSmall,
|
||||||
] = useImageQuery(imageData, 'description');
|
] = useImageQuery(imageData, 'descriptionSmall');
|
||||||
|
|
||||||
|
const [
|
||||||
|
requestDescriptionLarge,
|
||||||
|
descriptionLarge,
|
||||||
|
isLoadingDescriptionLarge,
|
||||||
|
] = useImageQuery(imageData, 'descriptionLarge');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8 max-w-[38rem]">
|
<div className="space-y-8 max-w-[38rem]">
|
||||||
@ -145,8 +151,17 @@ export default function PhotoForm({
|
|||||||
<button onClick={requestTags} disabled={isLoadingTags}>
|
<button onClick={requestTags} disabled={isLoadingTags}>
|
||||||
Tags ✨
|
Tags ✨
|
||||||
</button>
|
</button>
|
||||||
<button onClick={requestDescription} disabled={isLoadingDescription}>
|
<button
|
||||||
Description ✨
|
onClick={requestDescriptionSmall}
|
||||||
|
disabled={isLoadingDescriptionSmall}
|
||||||
|
>
|
||||||
|
Description (S) ✨
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={requestDescriptionLarge}
|
||||||
|
disabled={isLoadingDescriptionLarge}
|
||||||
|
>
|
||||||
|
Description (L) ✨
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
@ -195,7 +210,14 @@ export default function PhotoForm({
|
|||||||
</>}
|
</>}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
✨ DESCRIPTION: {description} {isLoadingDescription && <>
|
✨ DESCRIPTION (S): {descriptionSmall} {isLoadingDescriptionSmall && <>
|
||||||
|
<span className="inline-flex translate-y-[1.5px]">
|
||||||
|
<Spinner />
|
||||||
|
</span>
|
||||||
|
</>}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
✨ DESCRIPTION (L): {descriptionLarge} {isLoadingDescriptionLarge && <>
|
||||||
<span className="inline-flex translate-y-[1.5px]">
|
<span className="inline-flex translate-y-[1.5px]">
|
||||||
<Spinner />
|
<Spinner />
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user