export const GEMINI_IMAGE_MODEL = 'imagen-3.0-generate-002'; export const GEMINI_TEXT_MODEL = 'gemini-2.5-flash-preview-04-17'; // For text co-iteration & internal prompt refinement // Note: Placeholders like {subjectDescription}, {figureAndLabelContextBlock}, {primaryFigureIdentifierIfAny}, // {currentIteration}, {maxIterations}, {lastUsedImagePrompt} will be replaced dynamically. export const PROMPT_STYLES = { ITERATIVE_INITIAL_BASE: `Generate a black and white technical line drawing, strictly adhering to patent specification style. The drawing must clearly illustrate: "{subjectDescription}". Context for Figures & Labels (AI must interpret carefully): {figureAndLabelContextBlock} Key requirements for this drawing: - Lines: Crisp, clean, black lines ONLY. No exceptions. - Background: Pure white, 100% solid. Absolutely NO negative images (white on black). - Shading/Color/Gradients: Absolutely NO shading, gradients, colors, or halftones are permitted. - Output Type: The output MUST be a single, static, non-animated, non-video image file. - Perspective: Default to isometric view unless the subject description implies a specific view. - Detail: Illustrate all essential components with utmost clarity for patent documentation. - Text Rendering Rules (EXTREMELY IMPORTANT): - ONLY a designated Figure Number (e.g., "Figure 1", ideally '{primaryFigureIdentifierIfAny}') and specific component labels (e.g., "H1", "10a") explicitly requested and clearly identifiable from the '{figureAndLabelContextBlock}' and the main '{subjectDescription}' should be rendered. - DO NOT render any other numbers, text, codes, or annotations (e.g., paragraph numbers, measurements, scientific values not intended as labels). - If text ambiguity for a label/figure number exists, DO NOT RENDER IT. Prioritize a clean drawing. - All rendered labels must be legible, correctly associated, and not obscure drawing lines. - If '{figureAndLabelContextBlock}' indicates no specific labels/figure numbers, NO text whatsoever should appear. - Composition: Subject well-centered and appropriately scaled. Output: A single, professional, patent-quality line drawing. No explanatory text with the image.`, ITERATIVE_AUTO_REFINE_BASE: `This is an automated image refinement step (Image Generation Iteration {currentIteration} of {maxIterations}). Current Guiding Invention Description: "{subjectDescription}". Context for Figures & Labels (AI must interpret carefully): {figureAndLabelContextBlock} Critically evaluate the conceptual "previous drawing attempt" for the invention described above. Your task is to produce a significantly improved black and white patent specification line drawing. This new drawing must: 1. More Strictly Adhere to Patent Standards: Exclusively black lines on a PURE WHITE background (NO negative images). No color, shading, gradients. Crisp, clean lines. Single, static, non-animated, non-video image file. 2. More Accurately Reflect Guiding Description: All elements from "{subjectDescription}" MUST be present and accurately depicted. 3. Perfect Figure/Label Compliance & Text Rendering (CRITICAL REVIEW): - Meticulously review against '{subjectDescription}' and '{figureAndLabelContextBlock}'. - STRICTLY Adhere to Text Rendering Rules: - ONLY designated Figure Number (ideally '{primaryFigureIdentifierIfAny}') and explicit component labels from context. - DO NOT render other numbers/text (paragraph numbers, measurements, etc.). - If text ambiguity for label/figure number exists, DO NOT RENDER IT. - Correct ALL label/figure errors from conceptual prior attempt. Ensure rendered labels are present, exact, legible, correctly associated, and do not obscure lines. - If no specific labels/figure numbers in context, ensure NO text on the drawing. 4. Enhance Clarity and Precision: Improve line quality, component definition, spatial relationships. 5. Maintain Completeness & Compliance: Remove extraneous elements. Clean, professional, representative. 6. Consistent Perspective: Maintain established perspective (typically isometric). Output: A single, significantly improved, patent-quality line drawing. ONLY the drawing. No commentary or text other than specifically requested figure numbers/labels.`, TEXT_COITERATION_REFINE_PROMPT: `You are an expert patent editor. Your task is to refine an invention description to make it ideal for an AI to generate a precise patent line drawing AND to identify ONLY CRITICAL ambiguities that prevent such generation. Current Description (Version {textIteration}): "{currentTextDescription}" Reference Context for Figures/Labels (extracted from original user input): "{figureAndLabelContextBlock}" Your output MUST be a VALID JSON object with: { "refinedDescription": "...", "clarificationRequests": ["..."] } Instructions: 1. "refinedDescription": * Rewrite "{currentTextDescription}" to be extremely clear, precise, and UNAMBIGUOUS for the *next* patent drawing. * Prioritize autonomous resolution of minor ambiguities. Describe shapes, connections, components with technical accuracy. * Integrate labeling instructions (like those in '{figureAndLabelContextBlock}') naturally and UNAMBIGUOUSLY. For example, "an ergonomic handle (to be labeled H1)". Ensure labels are distinct. * Language must lead to patent-compliant drawings (black lines, white background, no shading/color, single static image). * Be concise yet complete for the drawing's needs. Remove conversational text. If the description seems adequate and clear, you can return it as is or with minimal changes. 2. "clarificationRequests": * Array of strings. * ONLY list a clarification request if an ambiguity in the "{currentTextDescription}" or '{figureAndLabelContextBlock}' is SO SEVERE that it PREVENTS you from creating a sufficiently clear "refinedDescription" OR would almost certainly lead to a FUNDAMENTAL error in the drawing (e.g., incorrect core component, completely wrong figure number). * DO NOT list minor points or easily inferable details. The user wants minimal, high-impact requests. * Example of a CRITICAL request: "The description is critically unclear whether 'Figure 1' or 'Figure 5' is the primary subject of this drawing. This must be clarified." OR "Component 'actuator X' is central but its connection to 'lever Y' is completely undefined, making depiction impossible." * If no such critical ambiguities exist, this array MUST be empty: []. Output ONLY the JSON object. Do NOT include preamble or commentary.`, INTERNAL_PROMPT_CRITIQUE_AND_REFINE: `You are an AI patent drawing assistant, tasked with refining the INSTRUCTIONS used to generate patent drawings. Original User Invention Description (for overall context): "{originalUserDescription}" Figure/Label Context Extracted from User Input (for overall context): "{figureAndLabelContextBlock}" Last Image Generation Prompt Used by AI (this is what you will critique and refine): "{lastUsedImagePrompt}" A conceptual image was just generated using the "{lastUsedImagePrompt}". Your goal is to improve THIS "{lastUsedImagePrompt}" to make the *next* image generation attempt even more accurate and compliant with patent drawing standards. Your output MUST be a VALID JSON object with: { "refinedImagePrompt": "...", "clarificationRequestsOrWarnings": ["..."] } Instructions: 1. "refinedImagePrompt": * Critically analyze "{lastUsedImagePrompt}". Rewrite it to be an even better set of instructions for the image generation AI. * Focus on: - Strict adherence to patent standards (black lines, PURE WHITE background, NO negative images, NO shading/color, single static image). - Accurate depiction of all elements from "{originalUserDescription}". - PERFECT rendering of specified figure numbers (like '{primaryFigureIdentifierIfAny}') and ALL labels explicitly listed in the \`{figureAndLabelContextBlock}\`. If specific labels/figures from this context were conceptually missing or poorly rendered in the "previous attempt", the refined prompt MUST make a stronger, more targeted effort to include/correct them. Ensure these are clear and correctly placed. - Elimination of ANY extraneous text, numbers, or artifacts NOT explicitly requested as a figure/label. - Enhanced clarity, precision, and removal of ambiguity *within the prompt itself*. * You MUST autonomously attempt to resolve ambiguities or improve clarity in the prompt. For example, if the last prompt was vague about label placement, make the refined prompt more specific. * Ensure the refined prompt strongly guides the image AI towards producing a single, static, non-video image. 2. "clarificationRequestsOrWarnings": * Array of strings. * ONLY list a request/warning if, after your best effort to refine the "{lastUsedImagePrompt}", there remains: a) A CRITICAL ambiguity or instruction in the *image generation strategy* that you believe will likely cause a significant error in the next drawing AND you cannot autonomously resolve it within the "refinedImagePrompt". b) A high probability that specific, explicitly requested labels/figures from \`{figureAndLabelContextBlock}\` will *still* be missed or rendered incorrectly, despite your prompt refinement efforts. List which specific labels/figures are at risk. c) Evidence that the \`{figureAndLabelContextBlock}\` itself (parsed from original user input) might be incomplete or missing obvious figure/label intentions clearly present in the \`{originalUserDescription}\`, leading to downstream rendering issues. (This is a warning about potential input parsing limitations for the user to be aware of). * DO NOT list minor issues or points about the user's original description (that's for text co-iteration). Focus SOLELY on making the *image generation prompt* better. * Example of a CRITICAL warning: "Warning: The current image prompt structure might still lead to ambiguity in rendering label 'X123' if the image AI is overly sensitive to general numeric text. Consider adding more explicit negative constraints in the prompt if this persists." OR "The prompt attempts to describe too many complex intersecting parts; suggest simplifying the prompt's description for one specific view or element if clarity doesn't improve." * If the refined prompt seems robust, this array MUST be empty: []. The user wants minimal, high-impact feedback. Output ONLY the JSON object. Do NOT include preamble or commentary.`, };