(options = {}, filename = null)
| 281 | |
| 282 | // Build prompt based on options |
| 283 | function buildPrompt(options = {}, filename = null) { |
| 284 | const maxTags = options.maxTags || DEFAULT_OPTIONS.maxTags; |
| 285 | const useCategories = options.useCategories || false; |
| 286 | const useJsonResponse = options.useJsonResponse || false; |
| 287 | const detailLevel = options.detailLevel || 'medium'; |
| 288 | |
| 289 | let prompt = `You are helping organize 3D models in a library. Analyze this image of a 3D model thumbnail and generate ${maxTags} useful category tags that will help users find and organize this model. `; |
| 290 | |
| 291 | prompt += getFilenameContext(filename); |
| 292 | |
| 293 | prompt += `Focus ONLY on the 3D model itself - completely ignore any background, text, or UI elements. `; |
| 294 | prompt += `Do NOT use generic terms like "3D Model", "model", "object", "item", "tag", "tags", "thing", "stuff", or "piece". `; |
| 295 | |
| 296 | // Adjust prompt based on detail level |
| 297 | if (detailLevel === 'low') { |
| 298 | prompt += `Generate very simple, broad category tags. Use the most basic, high-level classification. `; |
| 299 | prompt += `Examples: "Toy", "Dragon", "Tool", "Mount", "Ball", "Car", "Part", "Container", "Figure", "Decorative", "Functional". `; |
| 300 | prompt += `Use single-word tags only. Focus on the most general category the model belongs to. `; |
| 301 | } else if (detailLevel === 'high') { |
| 302 | prompt += `Generate detailed, specific tags that capture distinguishing features and characteristics. `; |
| 303 | prompt += `Include descriptive details like style, complexity, articulation, or specific attributes. `; |
| 304 | prompt += `Examples: "Articulated Dragon", "Corner Bracket", "Storage Container", "Decorative Vase", "Racing Car", "Action Figure". `; |
| 305 | prompt += `Compound tags are acceptable when they add meaningful detail. `; |
| 306 | } else { |
| 307 | // Medium (default) |
| 308 | prompt += `Generate general category tags that classify the model at a moderate level of detail. `; |
| 309 | prompt += `Use simple, single-word tags when possible. Good examples: "Toy", "Dragon", "Tool", "Mount", "Ball", "Car", "Part", "Drawer", "Bracket", "Container", "Figure", "Vase", "Lamp", "Holder", "Organizer", "Decorative", "Functional", "Bracket", "Mount", "Holder", "Stand", "Base". `; |
| 310 | prompt += `Avoid overly specific tags like "corner-bracket" or "mounting-bracket" - use the general category "Bracket" or "Mount" instead. `; |
| 311 | prompt += `Avoid compound tags when a single general word works. For example, use "Toy" not "toy-car", use "Dragon" not "dragon-figure", use "Car" not "car-model". `; |
| 312 | } |
| 313 | |
| 314 | prompt += `Focus on the primary category, subject, or function of the model. `; |
| 315 | prompt += `Each tag should represent a distinct category or characteristic that helps organize the library. `; |
| 316 | prompt += `Tags should be practical and useful for finding models - think about what someone would search for. `; |
| 317 | |
| 318 | if (useCategories) { |
| 319 | prompt += `Organize tags into these categories: object type, style, complexity, material. `; |
| 320 | } |
| 321 | |
| 322 | // JSON response instructions are never part of the editable prompt; they are always appended in generateTagsForImage |
| 323 | return prompt; |
| 324 | } |
| 325 | |
| 326 | // Always appended to the prompt when calling the API (not included in editable/default prompt) |
| 327 | const JSON_RESPONSE_INSTRUCTIONS = `You MUST respond with ONLY a valid JSON object. The JSON must be complete and valid. Use this exact format: {"tags": ["tag1", "tag2", "tag3"]}. Do not include any explanatory text, markdown formatting, or code blocks - only the raw JSON object. If you cannot identify the model, return {"tags": []}. Ensure the JSON is properly closed with all brackets and quotes. `; |
no test coverage detected