# 프롬프트 생성기 개발 V7: 모델명 오류 수정 및 '코드 생성' 2단계 프롬프트 구현 > 2025년 12월 3일 ## 모델명 오류 수정 이전 테스트에서 `404 models/gemini-1.5-pro-latest is not found` 에러가 발생했다. - **원인:** `genai.GenerativeModel()`에 전달된 모델 이름이 유효하지 않거나 현재 API를 통해 접근 가능한 모델 목록에 없기 때문이다. 특히 `-latest` 접미사가 문제였을 가능성이 높다. 사용자께서 요청하신 `gemini-2.5-pro` 역시 공식적으로 발표된 모델명은 아니다. - **해결:** 현재 안정적으로 사용 가능한 고성능 모델인 `gemini-1.5-pro` (접미사 없음)로 모델 이름을 수정한다. ## '코드 생성' 2단계 프롬프트 구현 이전에 사용자가 입력했던 요청(`나는 google sheet id 를 받아서 여기에 dashboard를 추가하는 python script를 만들고 싶어...`)은 `[Code Generation]` 의도로 분류되는 것이 적합하다. 이제 이 의도에 맞춰 상세한 코드 생성 프롬프트를 만들 수 있도록 `generate_detailed_prompt` 함수를 확장한다. **특화 프롬프트 (코드 생성용):** ```text 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. ``` 이 프롬프트는 LLM에게 단순한 키워드 나열이 아닌, "다른 LLM에게 전달할 상세한 프롬프트"를 생성하도록 지시하여 더 풍부한 결과물을 얻을 수 있도록 한다. ## `main.py` 업데이트 `main.py`의 `setup_generative_ai` 함수에서 모델명을 `gemini-1.5-pro`로 변경하고, `generate_detailed_prompt` 함수에 `[Code Generation]` 의도에 대한 새로운 특화 프롬프트를 추가한다. ```python import os import sys import google.generativeai as genai from dotenv import load_dotenv def setup_generative_ai(api_key): """Configures the generative AI client and returns the model.""" try: genai.configure(api_key=api_key) # 모델명 수정: gemini-1.5-pro-latest -> gemini-1.5-pro return genai.GenerativeModel('gemini-1.5-pro') except Exception as e: print(f"Error configuring the AI client: {e}") sys.exit(1) # get_intent 함수는 변경 없음 # ... 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. """ # Other intents like [Text Summarization], [General Question] can be added here later. } 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() # main 함수는 변경 없음 # ... ``` ## 다음 단계 다음 단계(`V8`)에서는 `[Text Summarization]` 및 `[General Question]` 의도에 대한 2단계 프롬프트를 추가하고, 전체적인 코드의 안정성과 예외 처리를 강화할 것이다.