Make caption generation title aware
This commit is contained in:
parent
63fafb87af
commit
e1e8f5cef0
@ -159,6 +159,7 @@ export const addUploadsAction = async ({
|
||||
? AI_TEXT_AUTO_GENERATED_FIELDS
|
||||
.filter(field => field !== 'title')
|
||||
: AI_TEXT_AUTO_GENERATED_FIELDS,
|
||||
title,
|
||||
);
|
||||
|
||||
const form: Partial<PhotoFormData> = {
|
||||
@ -435,6 +436,7 @@ export const syncPhotoAction = async (photoId: string, isBatch?: boolean) =>
|
||||
} = await generateAiImageQueries(
|
||||
imageResizedBase64,
|
||||
photo.syncStatus.missingAiTextFields,
|
||||
undefined,
|
||||
isBatch,
|
||||
);
|
||||
|
||||
@ -483,12 +485,13 @@ export const clearCacheAction = async () =>
|
||||
export const streamAiImageQueryAction = async (
|
||||
imageBase64: string,
|
||||
query: AiImageQuery,
|
||||
existingTitle?: string,
|
||||
) =>
|
||||
runAuthenticatedAdminServerAction(async () => {
|
||||
const existingTags = await getUniqueTags();
|
||||
return streamOpenAiImageQuery(
|
||||
imageBase64,
|
||||
getAiImageQuery(query, existingTags),
|
||||
getAiImageQuery(query, existingTags, existingTitle),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import { getUniqueTags } from '../db/query';
|
||||
export const generateAiImageQueries = async (
|
||||
imageBase64?: string,
|
||||
textFieldsToGenerate: AiAutoGeneratedField[] = [],
|
||||
existingTitle?: string,
|
||||
isBatch?: boolean,
|
||||
): Promise<{
|
||||
title?: string
|
||||
@ -43,7 +44,7 @@ export const generateAiImageQueries = async (
|
||||
if (textFieldsToGenerate.includes('title')) {
|
||||
title = await generateOpenAiImageQuery(
|
||||
imageBase64,
|
||||
getAiImageQuery('title'),
|
||||
getAiImageQuery('title', undefined, existingTitle),
|
||||
isBatch,
|
||||
);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import { AiImageQuery } from '.';
|
||||
export default function useAiImageQuery(
|
||||
imageBase64: string | undefined,
|
||||
query: AiImageQuery,
|
||||
existingTitle?: string,
|
||||
) {
|
||||
const [text, setText] = useState('');
|
||||
const [error, setError] = useState<any>();
|
||||
@ -19,6 +20,7 @@ export default function useAiImageQuery(
|
||||
const textStream = await streamAiImageQueryAction(
|
||||
imageBase64,
|
||||
query,
|
||||
existingTitle,
|
||||
);
|
||||
for await (const text of readStreamableValue(textStream)) {
|
||||
setText(current => `${current}${text ?? ''}`);
|
||||
@ -29,7 +31,7 @@ export default function useAiImageQuery(
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
}, [imageBase64, query]);
|
||||
}, [imageBase64, query, existingTitle]);
|
||||
|
||||
const reset = useCallback(() => {
|
||||
setText('');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user