Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File created as folder, prevents AI from creating rest of project #10

Open
cgranier opened this issue Oct 1, 2024 · 2 comments
Open

Comments

@cgranier
Copy link

cgranier commented Oct 1, 2024

System: WINDOWS 11 / VS-Code / PowerShell Terminal

After the /planning state, I asked the AI to /create Generate the project as planned. It then asked me:

Do you want to execute these creation steps? (yes/no): yes

It then proceeded to create a bunch of files and folders until it stopped with an error and asked me if I wanted to try again. Said yes, but same error.

I eventually tracked the error to a file project/frontend/App.jsx that had been created as a folder, instead of a file and was apparently preventing the file creation process from completing.

NOTE: I also created some files by hand, cutting and pasting from the terminal. Attempting to create the files from the AI stopped with the error:

ERROR:root:An unexpected error occurred during creation: [WinError 183] Cannot create a file when that file already exists: 'Project/backend/.env'

At this point, asking the AI to try again returned an Open AI error and crashed:

Error while communicating with OpenAI: Error code: 400 - {'error': {'message': "This model's maximum context length has been exceeded. Please reduce the length of the messages.", 'type': 'invalid_request_error', 'param': 'messages', 'code': 'context_length_exceeded'}}

@kalebzaki4
Copy link

It seems you're facing two distinct issues when running the AI-powered project generation process:

1. File creation error:

The AI attempted to create a file (App.jsx), but instead created a folder with the same name, causing the process to fail. Additionally, it seems that when you tried to create files manually, the error [WinError 183] occurred due to a file (.env) already existing.

2. OpenAI context length exceeded:

This error happens when too much context is passed in a single request to OpenAI's API, exceeding the allowed token limit. The model can only handle a certain number of tokens (which includes your message and its own response), and if that limit is surpassed, it returns the error you're seeing.

Potential Solutions:

1. Fixing the file creation issue:

  • Remove incorrect folder: Navigate to the project/frontend directory and manually delete the App.jsx folder that was mistakenly created. In PowerShell, you can do this with:

    Remove-Item -Recurse -Force .\project\frontend\App.jsx
  • Ensure .env file exists properly: If you already created the .env file manually, confirm its presence and content. If the AI is trying to recreate it, you can avoid this by simply skipping the file creation or renaming the file. If you'd rather let the AI handle it, delete the .env file before running the process again:

    Remove-Item .\project\backend\.env

2. Handling OpenAI token limit issue:

  • Reduce context size: Before asking the AI to retry, clear any unnecessary conversation history. If the AI is working through a large sequence of actions and commands, too much context might be sent back and forth, which causes the token limit to be exceeded. A clean start might help avoid exceeding the context limit.

  • Break the process into smaller chunks: If the project creation process is extensive, try breaking it down into smaller steps rather than letting the AI handle everything in one go. For instance, ask the AI to generate files for one part of the project (e.g., frontend) first, then backend, etc.

3. Retry the process:

  • Restart the AI from a clean slate: After removing the problematic files and folders, you can restart the process. To avoid exceeding the token limit again, consider guiding the AI through a more concise series of steps.

  • Manual intervention: Since you mentioned manually creating files, you can continue with this approach. After identifying and fixing the error, manually copy the code for any incomplete or missing files into your project from the terminal or AI output.

4. Future prevention:

  • Avoid existing file conflicts: When creating a file that already exists, ensure either the file is overwritten or the process skips it to avoid errors. You might want to modify the AI's instructions to check if a file exists before attempting to create it.

Example steps to fix:

  1. Delete problematic folder:

    Remove-Item -Recurse -Force .\project\frontend\App.jsx
  2. Delete existing .env file if needed:

    Remove-Item .\project\backend\.env
  3. Restart the AI process: You could clear the context and ask it to start generating files one section at a time, to avoid overwhelming the token limit.

By breaking down the process into smaller steps and manually intervening when errors occur, you should be able to resolve these issues and proceed with your project generation.

@clemenspeters
Copy link

I'm running into maximum context length has been exceeded issues as well. Maybe Google Gemini with 1M or even 2M context window could be useful here? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants