You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance prompt processing with existing file content support (#43)
### Overview
This PR improves the prompt-based file generation functionality by
allowing the OpenAI-assisted file generation process to consider and
modify existing file content when applicable.
### Changes
- **Added** support for passing existing file content to the OpenAI
prompt within `file_item.py`.
- **Updated** default OpenAI model to `gpt-4.1` from `gpt-3.5-turbo`.
- **Modified** `generate.py` to read existing file content and pass it
to the `process_prompt()` method.
- **Created** a new example configuration file `example/gpt.yaml`
demonstrating usage with user prompts.
### Justification
This change provides more intelligent and context-aware file generation
by allowing existing content to be passed into the prompt. It helps to
enhance productivity and avoid overwriting relevant content
unintentionally.
### Impact
- Improves integration with OpenAI by enabling content-aware generation.
- Prevents accidental data loss when regenerating files.
- Demonstrates usage with an example YAML file, aiding users in
understanding configuration.
# If existing_content is provided, append it to the user prompt
70
+
user_prompt=self.user_prompt
71
+
ifexisting_content:
72
+
user_prompt+=f"\n\nCurrent file content (if any):\n```\n{existing_content}\n```\n\nPlease modify existing content so that it meets the new requirements. Your output should be plain text, without any code blocks or formatting. Do not include any explanations or comments. Just provide the final content of the file."
73
+
74
+
self.logger.debug(f"Using system prompt: {system_prompt}")
75
+
self.logger.debug(f"Using user prompt: {user_prompt}")
76
+
71
77
ifdry_run:
72
78
self.logger.info("[DRY RUN] Would generate content using OpenAI API.")
73
79
self.content="[DRY RUN] Generating content using OpenAI"
0 commit comments