diff --git a/README.md b/README.md index 93cd1196..38a10462 100644 --- a/README.md +++ b/README.md @@ -77,11 +77,11 @@ _⚠️ READ BEFORE PROCEEDING_ 3. Configure auto-generated fields (optional) - Set which text fields auto-generate when uploading a photo by storing a comma-separated list, e.g., `AI_TEXT_AUTO_GENERATED_FIELDS = title, semantic` - Accepted values: - - `all` (default) - - `title` + - `all` + - `title` (default) - `caption` - - `tags` - - `semantic` + - `tags` (default) + - `semantic` (default) - `none` ### Web Analytics diff --git a/src/photo/ai/AiButton.tsx b/src/photo/ai/AiButton.tsx index 34cef97d..60b5efb6 100644 --- a/src/photo/ai/AiButton.tsx +++ b/src/photo/ai/AiButton.tsx @@ -1,12 +1,12 @@ import { AiContent } from './useAiImageQueries'; import { HiSparkles } from 'react-icons/hi'; -import { ALL_AI_AUTO_GENERATED_FIELDS, AiAutoGeneratedField } from '.'; +import { AI_AUTO_GENERATED_FIELDS_ALL, AiAutoGeneratedField } from '.'; import { useMemo } from 'react'; import LoaderButton from '@/components/primitives/LoaderButton'; export default function AiButton({ aiContent, - requestFields = ALL_AI_AUTO_GENERATED_FIELDS, + requestFields = AI_AUTO_GENERATED_FIELDS_ALL, shouldConfirm, className, }: { diff --git a/src/photo/ai/index.ts b/src/photo/ai/index.ts index 28ac0045..3d0ec9f9 100644 --- a/src/photo/ai/index.ts +++ b/src/photo/ai/index.ts @@ -8,27 +8,33 @@ export type AiAutoGeneratedField = 'tags' | 'semantic' -export const ALL_AI_AUTO_GENERATED_FIELDS: AiAutoGeneratedField[] = [ +export const AI_AUTO_GENERATED_FIELDS_ALL: AiAutoGeneratedField[] = [ 'title', 'caption', 'tags', 'semantic', ]; +export const AI_AUTO_GENERATED_FIELDS_DEFAULT: AiAutoGeneratedField[] = [ + 'title', + 'tags', + 'semantic', +]; + export const parseAiAutoGeneratedFieldsText = ( - text = 'all', + text = AI_AUTO_GENERATED_FIELDS_DEFAULT.join(','), ): AiAutoGeneratedField[] => { const textFormatted = text.trim().toLocaleLowerCase(); if (textFormatted === 'none') { return []; } else if (textFormatted === 'all') { - return ALL_AI_AUTO_GENERATED_FIELDS; + return AI_AUTO_GENERATED_FIELDS_ALL; } else { const fields = textFormatted .toLocaleLowerCase() .split(',') .map(field => field.trim()) - .filter(field => ALL_AI_AUTO_GENERATED_FIELDS + .filter(field => AI_AUTO_GENERATED_FIELDS_ALL .includes(field as AiAutoGeneratedField)); return fields as AiAutoGeneratedField[]; } @@ -53,7 +59,7 @@ export const getAiImageQuery = ( case 'caption': return 'Write a pithy caption for this image in 6 words or less and no punctuation'; case 'title-and-caption': return 'Write a compelling title and pithy caption of 8 words or less for this image, using the format Title: "title" Caption: "caption"'; case 'tags': - const tagQuery = 'Describe this image three or less comma-separated keywords with no adjective or adverbs'; + const tagQuery = 'Describe this image in three or less comma-separated unique keywords, with no adjective or adverbs, that are specific to this image'; const tags = existingTags.map(({ tag }) => tag).join(', '); return tags ? `${tagQuery}. Consider using some of these existing tags, but only if they are relevant: ${tags}.` diff --git a/src/photo/ai/useAiImageQueries.ts b/src/photo/ai/useAiImageQueries.ts index 63fb0363..c59711cc 100644 --- a/src/photo/ai/useAiImageQueries.ts +++ b/src/photo/ai/useAiImageQueries.ts @@ -1,7 +1,7 @@ import { useCallback, useEffect, useRef } from 'react'; import useAiImageQuery from './useAiImageQuery'; import useTitleCaptionAiImageQuery from './useTitleCaptionAiImageQuery'; -import { ALL_AI_AUTO_GENERATED_FIELDS, AiAutoGeneratedField } from '.'; +import { AI_AUTO_GENERATED_FIELDS_ALL, AiAutoGeneratedField } from '.'; export type AiContent = ReturnType; @@ -59,7 +59,7 @@ export default function useAiImageQueries( const hasRunAllQueriesOnce = useRef(false); const request = useCallback(async ( - fields = ALL_AI_AUTO_GENERATED_FIELDS, + fields = AI_AUTO_GENERATED_FIELDS_ALL, ) => { if (process.env.NODE_ENV !== 'production') { console.log('RUNNING AI QUERIES', fields); diff --git a/src/site/SiteChecklistClient.tsx b/src/site/SiteChecklistClient.tsx index 1ab614e3..3aa5c4d8 100644 --- a/src/site/SiteChecklistClient.tsx +++ b/src/site/SiteChecklistClient.tsx @@ -424,7 +424,9 @@ export default function SiteChecklistClient({ > Comma-separated fields to auto-generate when uploading photos. Accepted values: title, caption, - tags, description, all, or none (default is {'"all"'}): + tags, description, all, or none + {' '} + (default: {'"title, tags, semantic"'}): {renderEnvVars(['AI_TEXT_AUTO_GENERATED_FIELDS'])}