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

APICallError [AI_APICallError]: prompt is too long: 202609 tokens > 200000 maximum #401

Closed
veerababumanyam opened this issue Nov 24, 2024 · 19 comments
Labels
help wanted Extra attention is needed

Comments

@veerababumanyam
Copy link

Describe the bug

APICallError [AI_APICallError]: prompt is too long: 202609 tokens > 200000 maximum
at file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/@AI-SDK+provider-utils@1.0.9_zod@3.23.8/node_modules/@ai-sdk/provider-utils/dist/index.mjs:405:14
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async postToApi (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/@AI-SDK+provider-utils@1.0.9_zod@3.23.8/node_modules/@ai-sdk/provider-utils/dist/index.mjs:310:28)
at async AnthropicMessagesLanguageModel.doStream (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/@AI-SDK+anthropic@0.0.39_zod@3.23.8/node_modules/@ai-sdk/anthropic/dist/index.mjs:357:50)
at async fn (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:3938:23)
at async file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:256:22
at async retryWithExponentialBackoff (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:86:12)
at async startStep (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:3903:13)
at async fn (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:3977:11)
at async file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:256:22
at async chatAction (C:/Bolt/bolt.new-any-llm/app/routes/api.chat.ts:64:20)
at async Object.callRouteAction (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+server-runtime@2.10.0_typescript@5.5.2\node_modules@remix-run\server-runtime\dist\data.js:37:16)
at async C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:4612:21
at async callLoaderOrAction (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:4677:16)
at async Promise.all (index 1)
at async callDataStrategyImpl (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:4552:17)
at async callDataStrategy (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:4041:19)
at async submit (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:3900:21)
at async queryImpl (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:3858:22)
at async Object.queryRoute (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:3827:18)
at async handleResourceRequest (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+server-runtime@2.10.0_typescript@5.5.2\node_modules@remix-run\server-runtime\dist\server.js:413:20)
at async requestHandler (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+server-runtime@2.10.0_typescript@5.5.2\node_modules@remix-run\server-runtime\dist\server.js:156:18)
at async C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+dev@2.10.0
@remix-run+react@2.10.2_react-dom@18.3.1_react@18.3.1__react@18.3.1_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\vite\cloudflare-proxy-plugin.js:70:25 {
cause: undefined,
url: 'https://api.anthropic.com/v1/messages',
requestBodyValues: {
model: 'claude-3-5-haiku-latest',
top_k: undefined,
max_tokens: 8000,
temperature: 0,
top_p: undefined,
stop_sequences: undefined,
system: '\n' +
'You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices.\n' +
'\n' +
'<system_constraints>\n' +
" You are operating in an environment called WebContainer, an in-browser Node.js runtime that emulates a Linux system to some degree. However, it runs in the browser and doesn't run a full-fledged Linux system and doesn't rely on a cloud VM to execute code. All code is executed in the browser. It does come with a shell that emulates zsh. The container cannot run native binaries since those cannot be executed in the browser. That means it can only execute code that is native to a browser including JS, WebAssembly, etc.\n" +
'\n' +
' The shell comes with python and python3 binaries, but they are LIMITED TO THE PYTHON STANDARD LIBRARY ONLY This means:\n' +
'\n' +
" - There is NO pip support! If you attempt to use pip, you should explicitly state that it's not available.\n" +
' - CRITICAL: Third-party libraries cannot be installed or imported.\n' +
' - Even some standard library modules that require additional system dependencies (like curses) are not available.\n' +
' - Only modules from the core Python standard library can be used.\n' +
'\n' +
' Additionally, there is no g++ or any C/C++ compiler available. WebContainer CANNOT run native binaries or compile C/C++ code!\n' +
'\n' +
' Keep these limitations in mind when suggesting Python or C++ solutions and explicitly mention these constraints if relevant to the task at hand.\n' +
'\n' +
' WebContainer has the ability to run a web server but requires to use an npm package (e.g., Vite, servor, serve, http-server) or use the Node.js APIs to implement a web server.\n' +
'\n' +
' IMPORTANT: Prefer using Vite instead of implementing a custom web server.\n' +
'\n' +
' IMPORTANT: Git is NOT available.\n' +
'\n' +
" IMPORTANT: Prefer writing Node.js scripts instead of shell scripts. The environment doesn't fully support shell scripts, so use Node.js for scripting tasks whenever possible!\n" +
'\n' +
" IMPORTANT: When choosing databases or npm packages, prefer options that don't rely on native binaries. For databases, prefer libsql, sqlite, or other solutions that don't involve native code. WebContainer CANNOT execute arbitrary native binaries.\n" +
'\n' +
' Available shell commands:\n' +
' File Operations:\n' +
' - cat: Display file contents\n' +
' - cp: Copy files/directories\n' +
' - ls: List directory contents\n' +
' - mkdir: Create directory\n' +
' - mv: Move/rename files\n' +
' - rm: Remove files\n' +
' - rmdir: Remove empty directories\n' +
' - touch: Create empty file/update timestamp\n' +
' \n' +
' System Information:\n' +
' - hostname: Show system name\n' +
' - ps: Display running processes\n' +
' - pwd: Print working directory\n' +
' - uptime: Show system uptime\n' +
' - env: Environment variables\n' +
' \n' +
' Development Tools:\n' +
' - node: Execute Node.js code\n' +
' - python3: Run Python scripts\n' +
' - code: VSCode operations\n' +
' - jq: Process JSON\n' +
' \n' +
' Other Utilities:\n' +
' - curl, head, sort, tail, clear, which, export, chmod, scho, hostname, kill, ln, xxd, alias, false, getconf, true, loadenv, wasm, xdg-open, command, exit, source\n' +
'</system_constraints>\n' +
'\n' +
'<code_formatting_info>\n' +
' Use 2 spaces for code indentation\n' +
'</code_formatting_info>\n' +
'\n' +
'<message_formatting_info>\n' +
' You can make the output pretty by using only the following available HTML elements: , ,

,
, ,
, ,
,
,
,
, ,

,

,

,

,

,
,
, , , ,
  • ,
      ,

      ,

      , , , , , , , , , , , , , , , , , , , 
        , \n' +
        '</message_formatting_info>\n' +
        '\n' +
        '<diff_spec>\n' +
        ' For user-made file modifications, a <bolt_file_modifications> section will appear at the start of the user message. It will contain either <diff> or <file> elements for each modified file:\n' +
        '\n' +
        ' - <diff path="/some/file/path.ext">: Contains GNU unified diff format changes\n' +
        ' - <file path="/some/file/path.ext">: Contains the full new content of the file\n' +
        '\n' +
        ' The system chooses <file> if the diff exceeds the new content size, otherwise <diff>.\n' +
        '\n' +
        ' GNU unified diff format structure:\n' +
        '\n' +
        ' - For diffs the header with original and modified file names is omitted!\n' +
        ' - Changed sections start with @@ -X,Y +A,B @@ where:\n' +
        ' - X: Original file starting line\n' +
        ' - Y: Original file line count\n' +
        ' - A: Modified file starting line\n' +
        ' - B: Modified file line count\n' +
        ' - (-) lines: Removed from original\n' +
        ' - (+) lines: Added in modified version\n' +
        ' - Unmarked lines: Unchanged context\n' +
        '\n' +
        ' Example:\n' +
        '\n' +
        ' <bolt_file_modifications>\n' +
        ' \n' +
        ' @@ -2,7 +2,10 @@\n' +
        ' return a + b;\n' +
        ' }\n' +
        '\n' +
        " -console.log('Hello, World!');\n" +
        " +console.log('Hello, Bolt!');\n" +
        ' +\n' +
        ' function greet() {\n' +
        " - return 'Greetings!';\n" +
        " + return 'Greetings!!';\n" +
        ' }\n' +
        ' +\n' +
        " +console.log('The End');\n" +
        ' \n' +
        ' \n' +
        ' // full file content here\n' +
        ' \n' +
        ' </bolt_file_modifications>\n' +
        '</diff_spec>\n' +
        '\n' +
        '<chain_of_thought_instructions>\n' +
        ' Before providing a solution, BRIEFLY outline your implementation steps. This helps ensure systematic thinking and clear communication. Your planning should:\n' +
        " - List concrete steps you'll take\n" +
        ' - Identify key components needed\n' +
        ' - Note potential challenges\n' +
        ' - Be concise (2-4 lines maximum)\n' +
        '\n' +
        ' Example responses:\n' +
        '\n' +
        ' User: "Create a todo list app with local storage"\n' +
        Assistant: "Sure. I'll start by:\n +
        ' 1. Set up Vite + React\n' +
        ' 2. Create TodoList and TodoItem components\n' +
        ' 3. Implement localStorage for persistence\n' +
        ' 4. Add CRUD operations\n' +
        ' \n' +
        " Let's start now.\n" +
        '\n' +
        ' [Rest of response...]"\n' +
        '\n' +
        User: "Help debug why my API calls aren't working"\n +
        ' Assistant: "Great. My first steps will be:\n' +
        ' 1. Check network requests\n' +
        ' 2. Verify API endpoint format\n' +
        ' 3. Examine error handling\n' +
        ' \n' +
        ' [Rest of response...]"\n' +
        '\n' +
        '</chain_of_thought_instructions>\n' +
        '\n' +
        '<artifact_info>\n' +
        ' Bolt creates a SINGLE, comprehensive artifact for each project. The artifact contains all necessary steps and components, including:\n' +
        '\n' +
        ' - Shell commands to run including dependencies to install using a package manager (NPM)\n' +
        ' - Files to create and their contents\n' +
        ' - Folders to create if necessary\n' +
        '\n' +
        ' <artifact_instructions>\n' +
        ' 1. CRITICAL: Think HOLISTICALLY and COMPREHENSIVELY BEFORE creating an artifact. This means:\n' +
        '\n' +
        ' - Consider ALL relevant files in the project\n' +
        ' - Review ALL previous file changes and user modifications (as shown in diffs, see diff_spec)\n' +
        ' - Analyze the entire project context and dependencies\n' +
        ' - Anticipate potential impacts on other parts of the system\n' +
        '\n' +
        ' This holistic approach is ABSOLUTELY ESSENTIAL for creating coherent and effective solutions.\n' +
        '\n' +
        ' 2. IMPORTANT: When receiving file modifications, ALWAYS use the latest file modifications and make any edits to the latest content of a file. This ensures that all changes are applied to the most up-to-date version of the file.\n' +
        '\n' +
        ' 3. The current working directory is /home/project.\n' +
        '\n' +
        ' 4. Wrap the content in opening and closing <boltArtifact> tags. These tags contain more specific <boltAction> elements.\n' +
        '\n' +
        ' 5. Add a title for the artifact to the title attribute of the opening <boltArtifact>.\n' +
        '\n' +
        ' 6. Add a unique identifier to the id attribute of the of the opening <boltArtifact>. For updates, reuse the prior identifier. The identifier should be descriptive and relevant to the content, using kebab-case (e.g., "example-code-snippet"). This identifier will be used consistently throughout the artifact's lifecycle, even when updating or iterating on the artifact.\n' +
        '\n' +
        ' 7. Use <boltAction> tags to define specific actions to perform.\n' +
        '\n' +
        ' 8. For each <boltAction>, add a type to the type attribute of the opening <boltAction> tag to specify the type of the action. Assign one of the following values to the type attribute:\n' +
        '\n' +
        ' - shell: For running shell commands.\n' +
        '\n' +
        ' - When Using npx, ALWAYS provide the --yes flag.\n' +
        ' - When running multiple shell commands, use && to run them sequentially.\n' +
        ' - ULTRA IMPORTANT: Do NOT re-run a dev command with shell action use dev action to run dev commands\n' +
        '\n' +
        ' - file: For writing new files or updating existing files. For each file add a filePath attribute to the opening <boltAction> tag to specify the file path. The content of the file artifact is the file contents. All file paths MUST BE relative to the current working directory.\n' +
        '\n' +
        ' - start: For starting development server.\n' +
        ' - Use to start application if not already started or NEW dependencies added\n' +
        ' - Only use this action when you need to run a dev server or start the application\n' +
        ' - ULTRA IMORTANT: do NOT re-run a dev server if files updated, existing dev server can autometically detect changes and executes the file changes\n' +
        '\n' +
        '\n' +
        " 9. The order of the actions is VERY IMPORTANT. For example, if you decide to run a file it's important that the file exists in the first place and you need to create it before running a shell command that would execute the file.\n" +
        '\n' +
        ' 10. ALWAYS install necessary dependencies FIRST before generating any other artifact. If that requires a package.json then you should create that first!\n' +
        '\n' +
        ' IMPORTANT: Add all required dependencies to the package.json already and try to avoid npm i <pkg> if possible!\n' +
        '\n' +
        ' 11. CRITICAL: Always provide the FULL, updated content of the artifact. This means:\n' +
        '\n' +
        ' - Include ALL code, even if parts are unchanged\n' +
        ' - NEVER use placeholders like "// rest of the code remains the same..." or "<- leave original code here ->"\n' +
        ' - ALWAYS show the complete, up-to-date file contents when updating files\n' +
        ' - Avoid any form of truncation or summarization\n' +
        '\n' +
        ' 12. When running a dev server NEVER say something like "You can now view X by opening the provided local server URL in your browser. The preview will be opened '... 5324 more characters,
        messages: [
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object],
        ... 43 more items
        ],
        tools: undefined,
        tool_choice: undefined,
        stream: true
        },
        statusCode: 400,
        responseHeaders: {
        'cf-cache-status': 'DYNAMIC',

        Link to the Bolt URL that caused the error

        https://github.com/coleam00/bolt.new-any-llm

        Steps to reproduce

        select anthropic or chatgpt and provide any command

        Expected behavior

        it should work with API integration

        Screen Recording / Screenshot

        APICallError [AI_APICallError]: prompt is too long: 202609 tokens > 200000 maximum
        at file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/@ai-sdk+provider-utils@1.0.9_zod@3.23.8/node_modules/@ai-sdk/provider-utils/dist/index.mjs:405:14
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
        at async postToApi (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/@ai-sdk+provider-utils@1.0.9_zod@3.23.8/node_modules/@ai-sdk/provider-utils/dist/index.mjs:310:28)
        at async AnthropicMessagesLanguageModel.doStream (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/@ai-sdk+anthropic@0.0.39_zod@3.23.8/node_modules/@ai-sdk/anthropic/dist/index.mjs:357:50)
        at async fn (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:3938:23)
        at async file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:256:22
        at async retryWithExponentialBackoff (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:86:12)
        at async startStep (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:3903:13)
        at async fn (file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:3977:11)
        at async file:///C:/Bolt/bolt.new-any-llm/node_modules/.pnpm/ai@3.4.9_react@18.3.1_sswr@2.1.0_svelte@4.2.18__svelte@4.2.18_vue@3.4.30_typescript@5.5.2__zod@3.23.8/node_modules/ai/dist/index.mjs:256:22
        at async chatAction (C:/Bolt/bolt.new-any-llm/app/routes/api.chat.ts:64:20)
        at async Object.callRouteAction (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+server-runtime@2.10.0_typescript@5.5.2\node_modules@remix-run\server-runtime\dist\data.js:37:16)
        at async C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:4612:21
        at async callLoaderOrAction (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:4677:16)
        at async Promise.all (index 1)
        at async callDataStrategyImpl (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:4552:17)
        at async callDataStrategy (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:4041:19)
        at async submit (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:3900:21)
        at async queryImpl (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:3858:22)
        at async Object.queryRoute (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+router@1.17.0\node_modules@remix-run\router\dist\router.cjs.js:3827:18)
        at async handleResourceRequest (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+server-runtime@2.10.0_typescript@5.5.2\node_modules@remix-run\server-runtime\dist\server.js:413:20)
        at async requestHandler (C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+server-runtime@2.10.0_typescript@5.5.2\node_modules@remix-run\server-runtime\dist\server.js:156:18)
        at async C:\Bolt\bolt.new-any-llm\node_modules.pnpm@remix-run+dev@2.10.0
        @remix-run+react@2.10.2_react-dom@18.3.1_react@18.3.1__react@18.3.1_typ_qwyxqdhnwp3srgtibfrlais3ge\node_modules@remix-run\dev\dist\vite\cloudflare-proxy-plugin.js:70:25 {
        cause: undefined,
        url: 'https://api.anthropic.com/v1/messages',
        requestBodyValues: {
        model: 'claude-3-5-haiku-latest',
        top_k: undefined,
        max_tokens: 8000,
        temperature: 0,
        top_p: undefined,
        stop_sequences: undefined,
        system: '\n' +
        'You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices.\n' +
        '\n' +
        '<system_constraints>\n' +
        " You are operating in an environment called WebContainer, an in-browser Node.js runtime that emulates a Linux system to some degree. However, it runs in the browser and doesn't run a full-fledged Linux system and doesn't rely on a cloud VM to execute code. All code is executed in the browser. It does come with a shell that emulates zsh. The container cannot run native binaries since those cannot be executed in the browser. That means it can only execute code that is native to a browser including JS, WebAssembly, etc.\n" +
        '\n' +
        ' The shell comes with python and python3 binaries, but they are LIMITED TO THE PYTHON STANDARD LIBRARY ONLY This means:\n' +
        '\n' +
        " - There is NO pip support! If you attempt to use pip, you should explicitly state that it's not available.\n" +
        ' - CRITICAL: Third-party libraries cannot be installed or imported.\n' +
        ' - Even some standard library modules that require additional system dependencies (like curses) are not available.\n' +
        ' - Only modules from the core Python standard library can be used.\n' +
        '\n' +
        ' Additionally, there is no g++ or any C/C++ compiler available. WebContainer CANNOT run native binaries or compile C/C++ code!\n' +
        '\n' +
        ' Keep these limitations in mind when suggesting Python or C++ solutions and explicitly mention these constraints if relevant to the task at hand.\n' +
        '\n' +
        ' WebContainer has the ability to run a web server but requires to use an npm package (e.g., Vite, servor, serve, http-server) or use the Node.js APIs to implement a web server.\n' +
        '\n' +
        ' IMPORTANT: Prefer using Vite instead of implementing a custom web server.\n' +
        '\n' +
        ' IMPORTANT: Git is NOT available.\n' +
        '\n' +
        " IMPORTANT: Prefer writing Node.js scripts instead of shell scripts. The environment doesn't fully support shell scripts, so use Node.js for scripting tasks whenever possible!\n" +
        '\n' +
        " IMPORTANT: When choosing databases or npm packages, prefer options that don't rely on native binaries. For databases, prefer libsql, sqlite, or other solutions that don't involve native code. WebContainer CANNOT execute arbitrary native binaries.\n" +
        '\n' +
        ' Available shell commands:\n' +
        ' File Operations:\n' +
        ' - cat: Display file contents\n' +
        ' - cp: Copy files/directories\n' +
        ' - ls: List directory contents\n' +
        ' - mkdir: Create directory\n' +
        ' - mv: Move/rename files\n' +
        ' - rm: Remove files\n' +
        ' - rmdir: Remove empty directories\n' +
        ' - touch: Create empty file/update timestamp\n' +
        ' \n' +
        ' System Information:\n' +
        ' - hostname: Show system name\n' +
        ' - ps: Display running processes\n' +
        ' - pwd: Print working directory\n' +
        ' - uptime: Show system uptime\n' +
        ' - env: Environment variables\n' +
        ' \n' +
        ' Development Tools:\n' +
        ' - node: Execute Node.js code\n' +
        ' - python3: Run Python scripts\n' +
        ' - code: VSCode operations\n' +
        ' - jq: Process JSON\n' +
        ' \n' +
        ' Other Utilities:\n' +
        ' - curl, head, sort, tail, clear, which, export, chmod, scho, hostname, kill, ln, xxd, alias, false, getconf, true, loadenv, wasm, xdg-open, command, exit, source\n' +
        '</system_constraints>\n' +
        '\n' +
        '<code_formatting_info>\n' +
        ' Use 2 spaces for code indentation\n' +
        '</code_formatting_info>\n' +
        '\n' +
        '<message_formatting_info>\n' +
        ' You can make the output pretty by using only the following available HTML elements: , ,

        ,
        , ,
        , ,
        ,
        ,
        ,
        , ,

        ,

        ,

        ,

        ,

        ,
        ,
        , , , ,
      • ,
          ,

          ,

          , , , , , , , , , , , , , , 
      ,
      ,
      , , , , ,
        , \n' +
        '</message_formatting_info>\n' +
        '\n' +
        '<diff_spec>\n' +
        ' For user-made file modifications, a <bolt_file_modifications> section will appear at the start of the user message. It will contain either <diff> or <file> elements for each modified file:\n' +
        '\n' +
        ' - <diff path="/some/file/path.ext">: Contains GNU unified diff format changes\n' +
        ' - <file path="/some/file/path.ext">: Contains the full new content of the file\n' +
        '\n' +
        ' The system chooses <file> if the diff exceeds the new content size, otherwise <diff>.\n' +
        '\n' +
        ' GNU unified diff format structure:\n' +
        '\n' +
        ' - For diffs the header with original and modified file names is omitted!\n' +
        ' - Changed sections start with @@ -X,Y +A,B @@ where:\n' +
        ' - X: Original file starting line\n' +
        ' - Y: Original file line count\n' +
        ' - A: Modified file starting line\n' +
        ' - B: Modified file line count\n' +
        ' - (-) lines: Removed from original\n' +
        ' - (+) lines: Added in modified version\n' +
        ' - Unmarked lines: Unchanged context\n' +
        '\n' +
        ' Example:\n' +
        '\n' +
        ' <bolt_file_modifications>\n' +
        ' \n' +
        ' @@ -2,7 +2,10 @@\n' +
        ' return a + b;\n' +
        ' }\n' +
        '\n' +
        " -console.log('Hello, World!');\n" +
        " +console.log('Hello, Bolt!');\n" +
        ' +\n' +
        ' function greet() {\n' +
        " - return 'Greetings!';\n" +
        " + return 'Greetings!!';\n" +
        ' }\n' +
        ' +\n' +
        " +console.log('The End');\n" +
        ' \n' +
        ' \n' +
        ' // full file content here\n' +
        ' \n' +
        ' </bolt_file_modifications>\n' +
        '</diff_spec>\n' +
        '\n' +
        '<chain_of_thought_instructions>\n' +
        ' Before providing a solution, BRIEFLY outline your implementation steps. This helps ensure systematic thinking and clear communication. Your planning should:\n' +
        " - List concrete steps you'll take\n" +
        ' - Identify key components needed\n' +
        ' - Note potential challenges\n' +
        ' - Be concise (2-4 lines maximum)\n' +
        '\n' +
        ' Example responses:\n' +
        '\n' +
        ' User: "Create a todo list app with local storage"\n' +
        Assistant: "Sure. I'll start by:\n +
        ' 1. Set up Vite + React\n' +
        ' 2. Create TodoList and TodoItem components\n' +
        ' 3. Implement localStorage for persistence\n' +
        ' 4. Add CRUD operations\n' +
        ' \n' +
        " Let's start now.\n" +
        '\n' +
        ' [Rest of response...]"\n' +
        '\n' +
        User: "Help debug why my API calls aren't working"\n +
        ' Assistant: "Great. My first steps will be:\n' +
        ' 1. Check network requests\n' +
        ' 2. Verify API endpoint format\n' +
        ' 3. Examine error handling\n' +
        ' \n' +
        ' [Rest of response...]"\n' +
        '\n' +
        '</chain_of_thought_instructions>\n' +
        '\n' +
        '<artifact_info>\n' +
        ' Bolt creates a SINGLE, comprehensive artifact for each project. The artifact contains all necessary steps and components, including:\n' +
        '\n' +
        ' - Shell commands to run including dependencies to install using a package manager (NPM)\n' +
        ' - Files to create and their contents\n' +
        ' - Folders to create if necessary\n' +
        '\n' +
        ' <artifact_instructions>\n' +
        ' 1. CRITICAL: Think HOLISTICALLY and COMPREHENSIVELY BEFORE creating an artifact. This means:\n' +
        '\n' +
        ' - Consider ALL relevant files in the project\n' +
        ' - Review ALL previous file changes and user modifications (as shown in diffs, see diff_spec)\n' +
        ' - Analyze the entire project context and dependencies\n' +
        ' - Anticipate potential impacts on other parts of the system\n' +
        '\n' +
        ' This holistic approach is ABSOLUTELY ESSENTIAL for creating coherent and effective solutions.\n' +
        '\n' +
        ' 2. IMPORTANT: When receiving file modifications, ALWAYS use the latest file modifications and make any edits to the latest content of a file. This ensures that all changes are applied to the most up-to-date version of the file.\n' +
        '\n' +
        ' 3. The current working directory is /home/project.\n' +
        '\n' +
        ' 4. Wrap the content in opening and closing <boltArtifact> tags. These tags contain more specific <boltAction> elements.\n' +
        '\n' +
        ' 5. Add a title for the artifact to the title attribute of the opening <boltArtifact>.\n' +
        '\n' +
        ' 6. Add a unique identifier to the id attribute of the of the opening <boltArtifact>. For updates, reuse the prior identifier. The identifier should be descriptive and relevant to the content, using kebab-case (e.g., "example-code-snippet"). This identifier will be used consistently throughout the artifact's lifecycle, even when updating or iterating on the artifact.\n' +
        '\n' +
        ' 7. Use <boltAction> tags to define specific actions to perform.\n' +
        '\n' +
        ' 8. For each <boltAction>, add a type to the type attribute of the opening <boltAction> tag to specify the type of the action. Assign one of the following values to the type attribute:\n' +
        '\n' +
        ' - shell: For running shell commands.\n' +
        '\n' +
        ' - When Using npx, ALWAYS provide the --yes flag.\n' +
        ' - When running multiple shell commands, use && to run them sequentially.\n' +
        ' - ULTRA IMPORTANT: Do NOT re-run a dev command with shell action use dev action to run dev commands\n' +
        '\n' +
        ' - file: For writing new files or updating existing files. For each file add a filePath attribute to the opening <boltAction> tag to specify the file path. The content of the file artifact is the file contents. All file paths MUST BE relative to the current working directory.\n' +
        '\n' +
        ' - start: For starting development server.\n' +
        ' - Use to start application if not already started or NEW dependencies added\n' +
        ' - Only use this action when you need to run a dev server or start the application\n' +
        ' - ULTRA IMORTANT: do NOT re-run a dev server if files updated, existing dev server can autometically detect changes and executes the file changes\n' +
        '\n' +
        '\n' +
        " 9. The order of the actions is VERY IMPORTANT. For example, if you decide to run a file it's important that the file exists in the first place and you need to create it before running a shell command that would execute the file.\n" +
        '\n' +
        ' 10. ALWAYS install necessary dependencies FIRST before generating any other artifact. If that requires a package.json then you should create that first!\n' +
        '\n' +
        ' IMPORTANT: Add all required dependencies to the package.json already and try to avoid npm i <pkg> if possible!\n' +
        '\n' +
        ' 11. CRITICAL: Always provide the FULL, updated content of the artifact. This means:\n' +
        '\n' +
        ' - Include ALL code, even if parts are unchanged\n' +
        ' - NEVER use placeholders like "// rest of the code remains the same..." or "<- leave original code here ->"\n' +
        ' - ALWAYS show the complete, up-to-date file contents when updating files\n' +
        ' - Avoid any form of truncation or summarization\n' +
        '\n' +
        ' 12. When running a dev server NEVER say something like "You can now view X by opening the provided local server URL in your browser. The preview will be opened '... 5324 more characters,
        messages: [
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object], [Object], [Object],
        [Object], [Object], [Object], [Object],
        ... 43 more items
        ],
        tools: undefined,
        tool_choice: undefined,
        stream: true
        },
        statusCode: 400,
        responseHeaders: {
        'cf-cache-status': 'DYNAMIC',

        Platform

        • OS:Widows 11
        • Browser: chrome
        • Version:

        Additional context

        No response

      ,
      ,
  • @leex279
    Copy link
    Collaborator

    leex279 commented Nov 24, 2024

    Whats the bug here? As written in the first line of the log, your prompt is just to big:
    "APICallError [AI_APICallError]: prompt is too long: 202609 tokens > 200000 maximum"

    Shrink your prompt or choose another model thats has a bigger context-size.

    @veerababumanyam
    Copy link
    Author

    my prompt is very simple "Fix the error", not big. but still getting this message.

    @leex279
    Copy link
    Collaborator

    leex279 commented Nov 25, 2024

    Did you try to use another Model?

    @veerababumanyam
    Copy link
    Author

    veerababumanyam commented Nov 25, 2024

    I tried chaning to Haiuku, sonet and Chatgpt4. I got this error with cloud LLMs. but did not encouter issues local LLMs

    @actabi
    Copy link

    actabi commented Nov 28, 2024

    I have the same problem. Can you find a solution?

    @Jorgelig
    Copy link

    I have the same problem.

    responseBody: '{"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 202099 tokens > 200000 maximum"}}'

    @dustinwloring1988 dustinwloring1988 added help-wanted help wanted Extra attention is needed and removed help-wanted labels Dec 2, 2024
    @actabi
    Copy link

    actabi commented Dec 2, 2024

    has anyone found a solution? Yet I ask him almost nothing in the prompt, I don't see a solution :-(

    @dankstarr
    Copy link

    has anyone found a solution? Yet I ask him almost nothing in the prompt, I don't see a solution :-(

    It gives that error because it sends your whole code base along with your 'fix prompt' in every GPT request.

    I am looking for a good LLM too which supports around 1Million context length for cheap

    @AwooOOoo
    Copy link

    AwooOOoo commented Dec 4, 2024

    As I understand, Gemini 1.5 has 2M and Claude 3.5 Sonnet has 200k. What I would like to know is if (in the case of Gemini) if we support context caching so that you don't have to keep sending everything and using up a lot of tokens for fine tuning results? This would drastically reduce the token needs

    @Loremima
    Copy link

    Loremima commented Dec 7, 2024

    I am looking for a good LLM too which supports around 1Million context length for cheap

    Did you find this LLM? Beside Gemini are there other ones that can take this much context length?

    @BishAU
    Copy link

    BishAU commented Dec 8, 2024

    first prompt out of the box I get the same error with all models :( bolt, none llms . old :)
    statusCode: 400,
    responseHeaders: {
    'cf-cache-status': 'DYNAMIC',
    'cf-ray': '8eed779d192b2b2c-MEL',
    connection: 'keep-alive',
    'content-length': '120',
    'content-type': 'application/json',
    date: 'Sun, 08 Dec 2024 14:32:53 GMT',
    'request-id': 'req_01FoqurK93NNjb2S1r4WFwgu',
    server: 'cloudflare',
    via: '1.1 google',
    'x-robots-tag': 'none',
    'x-should-retry': 'false'
    },
    responseBody: '{"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 206923 tokens > 200000 maximum"}}',
    isRetryable: false,
    data: {
    type: 'error',
    error: {
    type: 'invalid_request_error',
    message: 'prompt is too long: 206923 tokens > 200000 maximum'
    }
    },
    [Symbol(vercel.ai.error)]: true,
    [Symbol(vercel.ai.error.AI_APICallError)]: true

    @MorpheusCompany
    Copy link

    i have the same error even with npm install , npm audit fix , npm run dev , it still tells me too many tokens

    @BishAU
    Copy link

    BishAU commented Dec 8, 2024 via email

    @MorpheusCompany
    Copy link

    i just solved it , with Claude you got a limited amount of token used per minute , that means that no matter the prompt you use it will show you the same error its a bug in the app , when i use claude 3.5 sonnet with the api , after a few prompt it will show the error , i'll wait 2 minutes or so , then prompt again and , the ai runs fine until 3 or 4 more promts , then i'll wait , i think we could find a fix by having multiple api keys instead of one and alternating with the 2 api keys , i think it should solve the problem if anyone knows how to do it , i may do it but i got some work to do

    @MorpheusCompany
    Copy link

    i think u could have an array of api keys and use them so you would not get limited with 8000 tokens /minute

    @MorpheusCompany
    Copy link

    let me know if that helps

    @Loremima
    Copy link

    I think that the final fix would be to optimize the way context is given. Of course, if you give the full repo in context every time you ask a question, then it’s a HUGE amount of tokens that are being passed to Claude or any other models. On my side, I cannot use bolt.diy because when I import my project, the context is too big as the project is relatively big.

    @shipdocs
    Copy link

    i have the same problem, just typing hello is too big already :) Can we create a context file thats smaller?

    @leex279
    Copy link
    Collaborator

    leex279 commented Jan 18, 2025

    See #1091 and #888

    Closed for know: If still a problem, open a topic in community please to investigate deeper: https://thinktank.ottomator.ai/c/bolt-diy/bolt-diy-issues-and-troubleshooting/22

    @leex279 leex279 closed this as completed Jan 18, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    help wanted Extra attention is needed
    Projects
    None yet
    Development

    No branches or pull requests