# 프롬프트 생성기 개발 V8: '텍스트 요약' 및 '일반 질문' 2단계 프롬프트 추가 및 안정성 강화 > 2025년 12월 3일 ## 개발 목표 이전 단계에서 `[Image Generation]`과 `[Code Generation]` 의도에 대한 2단계 프롬프트 생성을 성공적으로 구현했다. 이제 스크립트의 기능을 확장하고, 전반적인 안정성을 강화하기 위해 `[Text Summarization]` 및 `[General Question]` 의도를 처리하기 위한 특화 프롬프트를 `generate_detailed_prompt` 함수에 추가한다. ## 새로운 2단계 프롬프트 설계 ### 1. `[Text Summarization]` 의도용 특화 프롬프트 사용자가 제공하는 텍스트에 대해 상세한 요약 프롬프트를 생성한다. ```text You are an expert summarizer. The user wants a summary of the following text. Create a concise, easy-to-read paragraph that captures the main points of the text. Focus on key information and essential details, presenting them clearly and neutrally. User's text: "{{user_input}}" ``` ### 2. `[General Question]` 의도용 특화 프롬프트 사용자의 일반적인 질문이나 요청에 대해 LLM이 상세하고 구조화된 답변을 할 수 있도록 유도하는 프롬프트를 생성한다. ```text You are a helpful assistant. The user has a general question or request. Formulate a comprehensive and clear prompt for a large language model to answer this question or fulfill the request. The prompt should encourage the LLM to provide a detailed, well-structured, and informative response. User's request: "{{user_input}}" ``` ## `main.py` 업데이트 `main.py`의 `generate_detailed_prompt` 함수 내 `specialized_prompts` 딕셔너리에 위에 설계한 두 가지 새로운 프롬프트를 추가한다. ```python # ... (생략) def generate_detailed_prompt(model, user_input, intent): """Generates the final detailed prompt based on the intent.""" specialized_prompts = { "[Image Generation]": """You are a creative expert at writing prompts for AI image generators. Based on the user's simple description, create a single, detailed, rich paragraph for a prompt. This paragraph should include several descriptive sentences covering the subject, setting, lighting, mood, and artistic style. Do not just list keywords; weave them into a coherent paragraph. User's simple description: "{{user_input}}" """, "[Code Generation]": """You are an expert Python developer assistant. Based on the user's high-level request, generate a detailed prompt for a large language model (LLM) to create a Python script. The prompt should be comprehensive, including requirements for Google Sheets API, Gemini API, .env for API keys and email, and specifying the dashboard output to be in Japanese. User's request: "{{user_input}}" Return the detailed prompt as a paragraph ready for an LLM. """, "[Text Summarization]": """You are an expert summarizer. The user wants a summary of the following text. Create a concise, easy-to-read paragraph that captures the main points of the text. Focus on key information and essential details, presenting them clearly and neutrally. User's text: "{{user_input}}" """, "[General Question]": """You are a helpful assistant. The user has a general question or request. Formulate a comprehensive and clear prompt for a large language model to answer this question or fulfill the request. The prompt should encourage the LLM to provide a detailed, well-structured, and informative response. User's request: "{{user_input}}" """ } prompt_template = specialized_prompts.get(intent) if not prompt_template: return f"I can't generate a detailed prompt for the intent '{intent}' yet." prompt_for_api = prompt_template.replace("{{user_input}}", user_input) response = model.generate_content(prompt_for_api) return response.text.strip() # ... (생략) ``` ## 다음 단계 다음 단계(`V9`)에서는 CLI 애플리케이션으로서의 사용성을 향상시키기 위한 추가 기능(예: 재시도 로직, 더 나은 출력 서식)을 구현하고, 전체적인 코드 리팩토링을 통해 완성도를 높일 것이다.