Aider-AI / aider

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

Aider fails to start with error message `KeyError: 'get'` when using openrouter model #421

Closed azazar closed 10 months ago

azazar commented 10 months ago

Aider fails to start with error message KeyError: 'get' when using openrouter model.

$ aider --openai-api-base https://openrouter.ai/api/v1 --openai-api-key sk-or-v1-**** --model mistralai/mixtral-8x7b-instruct
Aider v0.19.1
Traceback (most recent call last):
  File "/home/me/.local/lib/python3.10/site-packages/pydantic/main.py", line 753, in __getattr__
    return pydantic_extra[item]
KeyError: 'get'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/me/.local/bin/aider", line 8, in <module>
    sys.exit(main())
  File "/home/me/.local/lib/python3.10/site-packages/aider/main.py", line 527, in main
    main_model = models.Model.create(args.model, client)
  File "/home/me/.local/lib/python3.10/site-packages/aider/models/model.py", line 24, in create
    return OpenRouterModel(client, name)
  File "/home/me/.local/lib/python3.10/site-packages/aider/models/openrouter.py", line 23, in __init__
    found = next(
  File "/home/me/.local/lib/python3.10/site-packages/aider/models/openrouter.py", line 24, in <genexpr>
    (details for details in cached_model_details if details.get("id") == name), None
  File "/home/me/.local/lib/python3.10/site-packages/pydantic/main.py", line 755, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}') from exc
AttributeError: 'Model' object has no attribute 'get'
alberto071968 commented 10 months ago

I am getting the same error as well.

paul-gauthier commented 10 months ago

@joshuavial made some recent changes to the openrouter connectivity in PR #379 which just merged to main. I'll let him comment if those changes might help this issue?

But if you want to try, the change is available in the main branch. You can get it by installing the latest version from github:

python -m pip install --upgrade git+https://github.com/paul-gauthier/aider.git

If you have a chance to try it, let me know if it works better for you.

joshuavial commented 10 months ago

yes, I would expect those changes to fix this issue

paul-gauthier commented 10 months 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.

alberto071968 commented 10 months ago

I confirm that the issue os now solved. Thank you so much for your support and for your amazing project.