| 4 | |
| 5 | @Injectable() |
| 6 | export class PromptToolService { |
| 7 | private readonly logger = new Logger(PromptToolService.name); |
| 8 | |
| 9 | async regenerateDescription(description: string): Promise<string> { |
| 10 | try { |
| 11 | const result = await generateText({ |
| 12 | model: openrouter(DEFAULT_MODEL), |
| 13 | // The prompt asks for 300-500 words; reserving the model's whole |
| 14 | // output window instead gets the request rejected on a small balance. |
| 15 | maxOutputTokens: 2048, |
| 16 | // ai@7 rejects role:'system' inside `messages` (allowSystemInMessages |
| 17 | // defaults to false) — it throws before any request is made. |
| 18 | instructions: `You help users transform brief project descriptions into comprehensive, well-structured requests that provide clear guidance for implementation. |
| 19 | |
| 20 | Format requirements: |
| 21 | 1. Begin with "Please create a..." or similar phrasing that clearly states the project goal |
| 22 | 2. Structure the response with clearly defined sections using double asterisks for bold headers (e.g., **Page Structure & Layout**, **Color & Theme**) |
| 23 | 3. Include 5-7 detailed sections that cover relevant aspects of the project |
| 24 | 4. For each section, provide 3-5 specific requirements or suggestions |
| 25 | 5. Use professional, detailed language while maintaining a conversational tone |
| 26 | 6. Ensure the entire description remains coherent and focused on the original project idea |
| 27 | 7. Include specific technical details where appropriate |
| 28 | 8. End with a clear call to action or summary statement |
| 29 | 9. Total length should be approximately 300-500 words |
| 30 | 10. Do NOT use markdown syntax, just plain text with double asterisks for section headers |
| 31 | 11. Return the text exactly as it should appear to the end user, with no additional formatting |
| 32 | |
| 33 | Example: |
| 34 | Input: "create a business card website" |
| 35 | Output: "**Please create a personal 'business card' style website** that showcases my professional identity and work portfolio effectively. The site should function as my digital presence with a clean, modern aesthetic. |
| 36 | |
| 37 | **Page Structure & Layout** |
| 38 | Feature a striking hero section with my name/logo prominently displayed, followed by a concise tagline that captures my professional essence. Implement a minimalist navigation system with smooth scrolling to different sections. Create distinct areas for my bio, skills/services, portfolio highlights, and contact information. |
| 39 | |
| 40 | **Color & Theme** |
| 41 | Utilize a professional color scheme with 2-3 primary colors that reflect my industry and personal brand. Incorporate subtle background textures or patterns that add visual interest without overwhelming the content. Maintain consistent styling elements throughout to create a cohesive experience. |
| 42 | |
| 43 | **Content Components** |
| 44 | Include a brief but compelling personal bio that highlights my expertise and unique value proposition. Feature 3-5 of my best work examples with brief descriptions. Add testimonials or endorsements if available. Present my skills or services using visually appealing icons or graphics. |
| 45 | |
| 46 | **Technical Requirements** |
| 47 | Ensure the site is fully responsive across all device sizes with optimized images and assets. Implement subtle animations or transitions that enhance the user experience without feeling excessive. Add SEO-friendly metadata and structure to improve discoverability. |
| 48 | |
| 49 | **Interactive Elements** |
| 50 | Include easy-to-find contact options with a simple form or direct email link. Add social media integration with recognizable icons. Consider implementing a downloadable resume/CV option or digital business card feature. |
| 51 | |
| 52 | Please compile this into a clean, professional website that effectively represents my personal brand while making it easy for potential clients or employers to understand my value and get in touch."`, |
| 53 | prompt: description, |
| 54 | }); |
| 55 | |
| 56 | this.logger.debug('Enhanced description generated'); |
| 57 | return result.text; |
| 58 | } catch (error) { |
| 59 | this.logger.error( |
| 60 | `Error generating enhanced description: ${error.message}`, |
| 61 | ); |
| 62 | throw new Error('Failed to enhance project description'); |
| 63 | } |
nothing calls this directly
no test coverage detected