# Aider chat conversation:
USER: add --openai-organization-id param that sets OpenAI(organization=...)
ASSISTANT: ```diff
--- aider/main.py
+++ aider/main.py
@@ ... @@
model_group.add_argument(
"--openai-api-deployment-id",
metavar="OPENAI_API_DEPLOYMENT_ID",
env_var="OPENAI_API_DEPLOYMENT_ID",
help="Specify the deployment_id",
)
+ model_group.add_argument(
+ "--openai-organization-id",
+ metavar="OPENAI_ORGANIZATION_ID",
+ env_var="OPENAI_ORGANIZATION_ID",
+ help="Specify the OpenAI organization ID",
+ )
model_group.add_argument(
"--openrouter",
dest="openai_api_base",
action="store_const",
@@ ... @@
if args.openai_api_type == "azure":
client = openai.AzureOpenAI(
api_key=args.openai_api_key,
azure_endpoint=args.openai_api_base,
api_version=args.openai_api_version,
azure_deployment=args.openai_api_deployment_id,
)
else:
kwargs = dict()
if args.openai_api_base:
kwargs["base_url"] = args.openai_api_base
if "openrouter.ai" in args.openai_api_base:
kwargs["default_headers"] = {
"HTTP-Referer": "http://aider.chat",
"X-Title": "Aider",
}
+ if args.openai_organization_id:
+ kwargs["organization"] = args.openai_organization_id
client = openai.OpenAI(api_key=args.openai_api_key, **kwargs)
@@ ... @@
if args.verbose:
show = scrub_sensitive_info(parser.format_values())
io.tool_output(show)
io.tool_output("Option settings:")
for arg, val in sorted(vars(args).items()):
io.tool_output(f" - {arg}: {scrub_sensitive_info(str(val))}")
+ if args.openai_organization_id:
+ io.tool_output(f" - openai_organization_id: {args.openai_organization_id}")
```
This diff adds a new command-line argument `--openai-organization-id` to the `aider/main.py` file, which allows the user to specify the OpenAI organization ID. It also ensures that if this argument is provided, it is passed to the `openai.OpenAI` client initialization as the `organization` parameter. Additionally, it outputs the organization ID if verbose mode is enabled.
Adds option to skip the check for an update, better supports tooling which wants to do it's own update mechanism and not have aider print it out unconditionally.
# Aider chat conversation:
USER: add --check-update to make aider check for update and return status in the exit code.
ASSISTANT: To implement the `--check-update` option, I will make the following changes:
1. Add the `--check-update` argument to the argument parser in `aider/main.py`.
2. Modify the `check_version` function in `aider/versioncheck.py` to return a boolean indicating whether an update is available.
3. Use the returned value from `check_version` in `aider/main.py` to set the exit status code when `--check-update` is used.
Here are the diffs for those changes:
```diff
--- aider/versioncheck.py
+++ aider/versioncheck.py
@@ ... @@
def check_version(print_cmd):
try:
response = requests.get("https://pypi.org/pypi/aider-chat/json")
data = response.json()
latest_version = data["info"]["version"]
current_version = aider.__version__
- if packaging.version.parse(latest_version) <= packaging.version.parse(current_version):
- return
+ is_update_available = packaging.version.parse(latest_version) > packaging.version.parse(current_version)
- print_cmd(f"Newer version v{latest_version} is available. To upgrade, run:")
- py = sys.executable
- print_cmd(f"{py} -m pip install --upgrade aider-chat")
+ if is_update_available:
+ print_cmd(f"Newer version v{latest_version} is available. To upgrade, run:")
+ py = sys.executable
+ print_cmd(f"{py} -m pip install --upgrade aider-chat")
+
+ return is_update_available
except Exception as err:
print_cmd(f"Error checking pypi for new version: {err}")
+ return False
--- aider/main.py
+++ aider/main.py
@@ ... @@
other_group.add_argument(
"--version",
action="version",
version=f"%(prog)s {__version__}",
help="Show the version number and exit",
)
+ other_group.add_argument(
+ "--check-update",
+ action="store_true",
+ help="Check for updates and return status in the exit code",
+ default=False,
+ )
other_group.add_argument(
"--apply",
metavar="FILE",
@@ ... @@
check_version(io.tool_error)
+ if args.check_update:
+ update_available = check_version(lambda msg: None)
+ sys.exit(0 if not update_available else 1)
+
if "VSCODE_GIT_IPC_HANDLE" in os.environ:
args.pretty = False
io.tool_output("VSCode terminal detected, pretty output has been disabled.")
```
These changes will add the `--check-update` option to the command-line interface and use the `check_version` function to determine if an update is available, exiting with status code `0` if no update is available and `1` if an update is available.
USER: UnifiedDiffNoMatch: hunk failed to apply!
aider/versioncheck.py does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in aider/versioncheck.py!
aider/versioncheck.py does not contain these 17 exact lines in a row:
```
def check_version(print_cmd):
try:
response = requests.get("https://pypi.org/pypi/aider-chat/json")
data = response.json()
latest_version = data["info"]["version"]
current_version = aider.__version__
if packaging.version.parse(latest_version) <= packaging.version.parse(current_version):
return
print_cmd(f"Newer version v{latest_version} is available. To upgrade, run:")
py = sys.executable
print_cmd(f"{py} -m pip install --upgrade aider-chat")
except Exception as err:
print_cmd(f"Error checking pypi for new version: {err}")
-- aider/main.py
```
UnifiedDiffNoMatch: hunk failed to apply!
aider/versioncheck.py does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in aider/versioncheck.py!
aider/versioncheck.py does not contain these 9 exact lines in a row:
```
other_group.add_argument(
"--version",
action="version",
version=f"%(prog)s {__version__}",
help="Show the version number and exit",
)
other_group.add_argument(
"--apply",
metavar="FILE",
```
UnifiedDiffNoMatch: hunk failed to apply!
aider/versioncheck.py does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in aider/versioncheck.py!
aider/versioncheck.py does not contain these 5 exact lines in a row:
```
check_version(io.tool_error)
if "VSCODE_GIT_IPC_HANDLE" in os.environ:
args.pretty = False
io.tool_output("VSCode terminal detected, pretty output has been disabled.")
```
ASSISTANT: I apologize for the confusion. Let's try again with the correct diffs.
Here are the diffs for the changes to `aider/versioncheck.py` and `aider/main.py`:
```diff
--- aider/versioncheck.py
+++ aider/versioncheck.py
@@ ... @@
import sys
import packaging.version
import requests
import aider
def check_version(print_cmd):
try:
response = requests.get("https://pypi.org/pypi/aider-chat/json")
data = response.json()
latest_version = data["info"]["version"]
current_version = aider.__version__
- if packaging.version.parse(latest_version) <= packaging.version.parse(current_version):
- return
+ is_update_available = packaging.version.parse(latest_version) > packaging.version.parse(current_version)
- print_cmd(f"Newer version v{latest_version} is available. To upgrade, run:")
- py = sys.executable
- print_cmd(f"{py} -m pip install --upgrade aider-chat")
+ if is_update_available:
+ print_cmd(f"Newer version v{latest_version} is available. To upgrade, run:")
+ py = sys.executable
+ print_cmd(f"{py} -m pip install --upgrade aider-chat")
+
+ return is_update_available
except Exception as err:
print_cmd(f"Error checking pypi for new version: {err}")
+ return False
```
```diff
--- aider/main.py
+++ aider/main.py
@@ ... @@
other_group.add_argument(
"--version",
action="version",
version=f"%(prog)s {__version__}",
help="Show the version number and exit",
)
+ other_group.add_argument(
+ "--check-update",
+ action="store_true",
+ help="Check for updates and return status in the exit code",
+ default=False,
+ )
other_group.add_argument(
"--apply",
metavar="FILE",
@@ ... @@
check_version(io.tool_error)
+ if args.check_update:
+ update_available = check_version(lambda msg: None)
+ sys.exit(0 if not update_available else 1)
+
if "VSCODE_GIT_IPC_HANDLE" in os.environ:
args.pretty = False
io.tool_output("VSCode terminal detected, pretty output has been disabled.")
```
These diffs should apply cleanly to the current contents of the files. The `check_version` function in `aider/versioncheck.py` now returns a boolean indicating whether an update is available, and `aider/main.py` has been updated to include the `--check-update` argument and to use the return value from `check_version` to set the exit status code.