paul-gauthier / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
16.42k stars 1.54k forks source link

Openrouter not working with new upgrade #853

Closed oloho closed 1 month ago

oloho commented 1 month ago

Issue

I upgrade to the latest aider and Openrouter just don't respond anymore and in my openrouter dashboard there no API activity I have this message in the terminal

`Aider v0.43.4
Model: openrouter/deepseek/deepseek-coder with diff edit format
Git repo: .git with 0 files
Repo-map: using 1024 tokens
Unexpected error: cannot access local variable 'message' where it is not associated with a value
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\litellm\llms\openai.py", line 856, in completion
    raise e
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\litellm\llms\openai.py", line 775, in completion
    return self.streaming(
           ^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\litellm\llms\openai.py", line 955, in streaming
    response = openai_client.chat.completions.create(**data, timeout=timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_utils\_utils.py", line 277, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\resources\chat\completions.py", line 643, in create
    return self._post(
           ^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_base_client.py", line 1261, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_base_client.py", line 942, in request
    return self._request(
           ^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_base_client.py", line 1041, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {'error': {'message': 'No endpoints found for the request. Check your provider filtering parameters and privacy settings: https://openrouter.ai/settings/privacy', 'code': 404}, 'user_id': 'user_2j0EYVLfjynNli0H87ix5WBI5xL'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\litellm\main.py", line 1829, in completion
    response = openai_chat_completions.completion(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\litellm\llms\openai.py", line 862, in completion
    raise OpenAIError(status_code=e.status_code, message=str(e))
litellm.llms.openai.OpenAIError: Error code: 404 - {'error': {'message': 'No endpoints found for the request. Check your provider filtering parameters and privacy settings: https://openrouter.ai/settings/privacy', 'code': 404}, 'user_id': 'user_2j0EYVLfjynNli0H87ix5WBI5xL'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\aider\coders\base_coder.py", line 860, in send_new_user_message
    yield from self.send(messages, functions=self.functions)
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\aider\coders\base_coder.py", line 1110, in send
    hash_object, completion = send_with_retries(
                              ^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\aider\sendchat.py", line 53, in wrapper
    return decorated_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\backoff\_sync.py", line 105, in retry
    ret = target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\aider\sendchat.py", line 81, in send_with_retries
    res = litellm.completion(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\litellm\utils.py", line 1001, in wrapper
    raise e
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\litellm\utils.py", line 881, in wrapper
    result = original_function(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\litellm\main.py", line 2605, in completion
    raise exception_type(
          ^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\litellm\utils.py", line 7650, in exception_type
    raise e
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\litellm\utils.py", line 7527, in exception_type
    message=f"NotFoundError: {exception_provider} - {message}",
                                                     ^^^^^^^`

Version and model info

Aider v0.43.4 model openrouter/deepseek/deepseek-coder

bauersimon commented 1 month ago

Same for me... went through older versions:

What was the last version that worked for you?

I just exported my openrouter API key and selected the model via --model openrouter/deepseek/deepseek-coder.

bauersimon commented 1 month ago

Just tried using the generic endpoint instead of the openrouter one. But that did not work as well. Then I tried changing the model to i.e. Sonnet 3.5 and that worked! So it seems this is a problem with deepseek-coder and not the openrouter integraiton itself.

bauersimon commented 1 month ago

If you open a chat window in the openrouter web UI with deepseek-chat and input something, then the 404 error we are encountering is thrown in the web UI as well. So this is an openrouter issue.

bauersimon commented 1 month ago

In my case I now went to the openrouter privacy settings and enabled "providers that may train on inputs". Now it is working 🎊.

paul-gauthier commented 1 month ago

Thanks for trying aider and filing this issue. @oloho did @bauersimon's comments solve your problem?

oloho commented 1 month ago

It's working but there no privacy anymore. It's quite annoying

paul-gauthier commented 1 month ago

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