aider icon indicating copy to clipboard operation
aider copied to clipboard

Bug report

Open Yona544 opened this issue 1 year ago • 4 comments

Aider version: 0.56.0 Python version: 3.12.6 Platform: Windows-10-10.0.19045-SP0 Python implementation: CPython Virtual environment: Yes OS: Windows 10 (64bit) Git version: git version 2.36.1.windows.1

Aider v0.56.0 Main model: openrouter/anthropic/claude-3.5-sonnet with diff edit format, prompt cache, infinite output Weak model: openrouter/anthropic/claude-3-haiku-20240307 Git repo: \192.168.0.35\YonaVmDataShare\Projects\SCO.git with 80 files Repo-map: using 1024 tokens, files refresh Added uMain.fmx to the chat. Added uMain.pas to the chat.

uMain.fmx uMain.pas

/ask want to se on teh screen my live camera connected to teh computer, there is sfunction calleed testCamera

Unexpected error: 'APIError' object has no attribute 'response' Traceback (most recent call last): File "C:\Users\Administrator\pipx\venvs\aider-chat\Lib\site-packages\litellm\utils.py", line 10495, in next chunk = next(self.completion_stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\pipx\venvs\aider-chat\Lib\site-packages\openai_streaming.py", line 43, in next return self._iterator.next() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\pipx\venvs\aider-chat\Lib\site-packages\openai_streaming.py", line 72, in stream raise APIError( openai.APIError: {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 210286 tokens > 204698 maximum"}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Administrator\pipx\venvs\aider-chat\Lib\site-packages\aider\coders\base_coder.py", line 1124, in send_message yield from self.send(messages, functions=self.functions) File "C:\Users\Administrator\pipx\venvs\aider-chat\Lib\site-packages\aider\coders\base_coder.py", line 1408, in send yield from self.show_send_output_stream(completion) File "C:\Users\Administrator\pipx\venvs\aider-chat\Lib\site-packages\aider\coders\base_coder.py", line 1482, in show_send_output_stream for chunk in completion: ^^^^^^^^^^ File "C:\Users\Administrator\pipx\venvs\aider-chat\Lib\site-packages\litellm\utils.py", line 10582, in next raise exception_type( ^^^^^^^^^^^^^^^ File "C:\Users\Administrator\pipx\venvs\aider-chat\Lib\site-packages\litellm\utils.py", line 8438, in exception_type raise e File "C:\Users\Administrator\pipx\venvs\aider-chat\Lib\site-packages\litellm\utils.py", line 6723, in exception_type response=original_exception.response, ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'APIError' object has no attribute 'response'

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── uMain.fmx uMain.pas

/report

Attempting to open the issue URL in your default web browser... Browser window should be opened. ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── uMain.fmx uMain.pas

Yona544 avatar Sep 11 '24 21:09 Yona544

You included too many or too big files in your context:

openai.APIError: {"type":"error","error":{"type":"invalid_request_error",
"message":"prompt is too long: 210286 tokens > 204698 maximum"}}

Use /tokens to check from inside aider, also have a look here -> https://aider.chat/docs/faq.html

fry69 avatar Sep 12 '24 00:09 fry69

As you can see I did not use OPENAI my model is: Main model: openrouter/anthropic/claude-3.5-sonnet with diff edit format, prompt cache, infinite output Weak model: openrouter/anthropic/claude-3-haiku-20240307

the file that was included uMain.pas has 3200 lines

Yona544 avatar Sep 12 '24 02:09 Yona544

As you can see I did not use OPENAI

The log refers to the API used, not the model. Many provider use OpenAI compatible APIs with a different API base URL. So if the log says something about OpenAI this does not necessarily imply that you are connecting to openai.com or use any of their models.

The error which I quoted from your issue tells you that the API rejected your request because it was too large.

fry69 avatar Sep 12 '24 03:09 fry69

Got it.

My question is, while I understand that a file should ideally be around 800 lines for optimal performance with Aider, would a file with around 3,000 lines be too large and likely to crash? Also, would it be more manageable to work with many smaller files that total well over 3,000 lines?

Yona544 avatar Sep 12 '24 03:09 Yona544

Models like gpt-4o and sonnet tend to get confused when you send more then 20-30k tokens. Use /tokens to see what you're going to send.

I'm going to close this issue for now, but feel free to add a comment here and I will re-open. Or feel free to file a new issue any time.

paul-gauthier avatar Sep 20 '24 19:09 paul-gauthier