FEAT allow flexiblity to support future aider flags
This commit is contained in:
parent
ebfdcf821e
commit
e507fd87bd
15
README.md
15
README.md
|
|
@ -279,9 +279,7 @@ export OPENROUTER_API_KEY=your_api_key_here
|
|||
export OPENAI_API_BASE=your_api_base_url
|
||||
```
|
||||
|
||||
Note: The expert tool defaults to OpenAI's o1-preview model with the OpenAI provider, but this can be configured using the --expert-provider flag along with the corresponding EXPERT_*_KEY environment variables.
|
||||
|
||||
#### Custom Model Examples
|
||||
### Custom Model Examples
|
||||
|
||||
1. **Using Anthropic (Default)**
|
||||
```bash
|
||||
|
|
@ -320,6 +318,17 @@ Note: The expert tool defaults to OpenAI's o1-preview model with the OpenAI prov
|
|||
ra-aid -m "Your task" --expert-provider openai --expert-model o1-preview
|
||||
```
|
||||
|
||||
Aider specific Environment Variables you can add:
|
||||
|
||||
- `AIDER_FLAGS`: Optional comma-separated list of flags to pass to the underlying aider tool (e.g., "yes-always,dark-mode")
|
||||
|
||||
```bash
|
||||
# Optional: Configure aider behavior
|
||||
export AIDER_FLAGS="yes-always,dark-mode,no-auto-commits"
|
||||
```
|
||||
|
||||
Note: For `AIDER_FLAGS`, you can specify flags with or without the leading `--`. Multiple flags should be comma-separated, and spaces around flags are automatically handled. For example, both `"yes-always,dark-mode"` and `"--yes-always, --dark-mode"` are valid.
|
||||
|
||||
**Important Notes:**
|
||||
- Performance varies between models. The default Claude 3 Sonnet model currently provides the best and most reliable results.
|
||||
- Model configuration is done via command line arguments: `--provider` and `--model`
|
||||
|
|
|
|||
|
|
@ -44,9 +44,19 @@ Returns: { "output": stdout+stderr, "return_code": 0 if success, "success": True
|
|||
"--no-auto-commits",
|
||||
"--dark-mode",
|
||||
"--no-suggest-shell-commands",
|
||||
"-m"
|
||||
]
|
||||
|
||||
# if environment variable AIDER_FLAGS exists then parse
|
||||
if 'AIDER_FLAGS' in os.environ:
|
||||
# wrap in try catch in case of any error and log the error
|
||||
try:
|
||||
command.extend(parse_aider_flags(os.environ['AIDER_FLAGS']))
|
||||
except Exception as e:
|
||||
print(f"Error parsing AIDER_FLAGS: {e}")
|
||||
|
||||
# ensure message aider argument is always present
|
||||
command.append("-m")
|
||||
|
||||
command.append(input.instructions)
|
||||
|
||||
if input.files:
|
||||
|
|
@ -93,5 +103,32 @@ Returns: { "output": stdout+stderr, "return_code": 0 if success, "success": True
|
|||
"success": False
|
||||
}
|
||||
|
||||
def parse_aider_flags(aider_flags: str) -> List[str]:
|
||||
"""Parse a string of aider flags into a list of flags.
|
||||
|
||||
Args:
|
||||
aider_flags: A string containing comma-separated flags, with or without leading dashes.
|
||||
Can contain spaces around flags and commas.
|
||||
|
||||
Returns:
|
||||
A list of flags with proper '--' prefix.
|
||||
|
||||
Examples:
|
||||
>>> parse_aider_flags("yes-always,dark-mode")
|
||||
['--yes-always', '--dark-mode']
|
||||
>>> parse_aider_flags("--yes-always, --dark-mode")
|
||||
['--yes-always', '--dark-mode']
|
||||
>>> parse_aider_flags("")
|
||||
[]
|
||||
"""
|
||||
if not aider_flags.strip():
|
||||
return []
|
||||
|
||||
# Split by comma and strip whitespace
|
||||
flags = [flag.strip() for flag in aider_flags.split(",")]
|
||||
|
||||
# Add '--' prefix if not present and filter out empty flags
|
||||
return [f"--{flag.lstrip('-')}" for flag in flags if flag.strip()]
|
||||
|
||||
# Export the functions
|
||||
__all__ = ['run_programming_task']
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
import pytest
|
||||
from ra_aid.tools.programmer import parse_aider_flags
|
||||
|
||||
# Test cases for parse_aider_flags function
|
||||
test_cases = [
|
||||
# Test case format: (input_string, expected_output, test_description)
|
||||
(
|
||||
"yes-always,dark-mode",
|
||||
["--yes-always", "--dark-mode"],
|
||||
"basic comma separated flags without dashes"
|
||||
),
|
||||
(
|
||||
"--yes-always,--dark-mode",
|
||||
["--yes-always", "--dark-mode"],
|
||||
"comma separated flags with dashes"
|
||||
),
|
||||
(
|
||||
"yes-always, dark-mode",
|
||||
["--yes-always", "--dark-mode"],
|
||||
"comma separated flags with space"
|
||||
),
|
||||
(
|
||||
"--yes-always, --dark-mode",
|
||||
["--yes-always", "--dark-mode"],
|
||||
"comma separated flags with dashes and space"
|
||||
),
|
||||
(
|
||||
"",
|
||||
[],
|
||||
"empty string"
|
||||
),
|
||||
(
|
||||
" yes-always , dark-mode ",
|
||||
["--yes-always", "--dark-mode"],
|
||||
"flags with extra whitespace"
|
||||
),
|
||||
(
|
||||
"--yes-always",
|
||||
["--yes-always"],
|
||||
"single flag with dashes"
|
||||
),
|
||||
(
|
||||
"yes-always",
|
||||
["--yes-always"],
|
||||
"single flag without dashes"
|
||||
)
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("input_flags,expected,description", test_cases)
|
||||
def test_parse_aider_flags(input_flags, expected, description):
|
||||
"""Table-driven test for parse_aider_flags function."""
|
||||
result = parse_aider_flags(input_flags)
|
||||
assert result == expected, f"Failed test case: {description}"
|
||||
Loading…
Reference in New Issue