Last active
February 5, 2025 08:28
-
-
Save Joeao/e00ec996ace6aae70a63cfac14625ee0 to your computer and use it in GitHub Desktop.
Aider OpenRouter Model & Key Select
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias aide='~/aide.sh' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get the directory where the script is located | |
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
# Source the configuration file | |
CONFIG_FILE="$SCRIPT_DIR/aide_config.sh" | |
if [[ ! -f "$CONFIG_FILE" ]]; then | |
echo "Error: Configuration file '$CONFIG_FILE' not found!" | |
exit 1 | |
fi | |
source "$CONFIG_FILE" | |
# Function to parse arrays and display menu | |
display_menu() { | |
local entries=("$@") | |
local labels=() | |
local values=() | |
# Parse the entries into separate labels and values | |
for entry in "${entries[@]}"; do | |
label="${entry%%|*}" # Get everything before the | | |
value="${entry##*|}" # Get everything after the | | |
labels+=("$label") | |
values+=("$value") | |
done | |
# Determine if this is for models or API keys | |
if [[ "${entries[0]}" == "${MODELS[0]}" ]]; then | |
prompt="Select a model" | |
else | |
prompt="Select an API key" | |
fi | |
echo "$prompt:" | |
echo "-------------" | |
# Create numbered menu | |
for i in "${!labels[@]}"; do | |
echo "$((i+1))) ${labels[i]}" | |
done | |
# Get user input | |
echo | |
read -p "Enter number (1-${#labels[@]}): " choice | |
# Validate input | |
if ! [[ "$choice" =~ ^[0-9]+$ ]] || [ "$choice" -lt 1 ] || [ "$choice" -gt "${#labels[@]}" ]; then | |
echo "Invalid selection. Please choose a number between 1 and ${#labels[@]}." | |
exit 1 | |
fi | |
# Calculate array index (subtract 1 from choice) | |
local idx=$((choice-1)) | |
# Set global variables for the selection | |
selected_label="${labels[idx]}" | |
selected_value="${values[idx]}" | |
} | |
# Select model | |
display_menu "${MODELS[@]}" | |
model_value=$selected_value | |
model_label=$selected_label | |
# Select API key | |
display_menu "${API_KEYS[@]}" | |
key_value=$selected_value | |
key_label=$selected_label | |
source ~/aider/venv/bin/activate | |
aider --model "openrouter/$model_value" --api-key "openrouter=$key_value" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Model configurations | |
# Format: label|value | |
MODELS=( | |
"Deepseek R1 Free|deepseek/deepseek-r1:free" | |
"Deepseek v3|deepseek/deepseek-chat" | |
"3.5 Haiku|anthropic/claude-3.5-haiku" | |
"o3 Mini|openai/o3-mini" | |
) | |
# API key configurations | |
# Format: label|value | |
API_KEYS=( | |
"Client A|sk_or_123456789abcdef123456789abcdef" | |
"Client B|sk_or_987654321fedcba987654321fedcba" | |
"Client C|sk_or_abcdef123456789abcdef123456789" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment