mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 02:34:59 +00:00
feat: Simplify default model selection and improve OpenRouter OAuth key saving
This commit is contained in:
parent
51825663b9
commit
928b78d9f6
1 changed files with 7 additions and 8 deletions
|
@ -36,9 +36,7 @@ def try_to_select_default_model():
|
||||||
selected_model = None
|
selected_model = None
|
||||||
for env_key, model_name in model_key_pairs:
|
for env_key, model_name in model_key_pairs:
|
||||||
api_key_value = os.environ.get(env_key)
|
api_key_value = os.environ.get(env_key)
|
||||||
# Special check for Vertex AI project which isn't a key but acts like one for selection
|
if api_key_value:
|
||||||
is_vertex = env_key == "VERTEXAI_PROJECT" and api_key_value
|
|
||||||
if api_key_value and (not is_vertex or os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")):
|
|
||||||
selected_model = model_name
|
selected_model = model_name
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -111,7 +109,7 @@ def select_default_model(args, io, analytics):
|
||||||
|
|
||||||
model = try_to_select_default_model()
|
model = try_to_select_default_model()
|
||||||
if model:
|
if model:
|
||||||
io.tool_warning(f"Using {model} model with detected API key.")
|
io.tool_warning(f"Using {model} model with API key from environment.")
|
||||||
analytics.event("auto_model_selection", model=model)
|
analytics.event("auto_model_selection", model=model)
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
@ -340,6 +338,7 @@ def start_openrouter_oauth_flow(io, analytics):
|
||||||
config_dir = os.path.expanduser("~/.aider")
|
config_dir = os.path.expanduser("~/.aider")
|
||||||
os.makedirs(config_dir, exist_ok=True)
|
os.makedirs(config_dir, exist_ok=True)
|
||||||
key_file = os.path.join(config_dir, "oauth-keys.env")
|
key_file = os.path.join(config_dir, "oauth-keys.env")
|
||||||
|
# append ai!
|
||||||
with open(key_file, "w", encoding="utf-8") as f:
|
with open(key_file, "w", encoding="utf-8") as f:
|
||||||
f.write(f'OPENROUTER_API_KEY="{api_key}"\n')
|
f.write(f'OPENROUTER_API_KEY="{api_key}"\n')
|
||||||
io.tool_output(f"Successfully obtained OpenRouter API key and saved it to {key_file}")
|
io.tool_output(f"Successfully obtained OpenRouter API key and saved it to {key_file}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue