From 8304029b92e5c20850467ed22c503921d4738796 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 26 May 2025 16:29:28 -0700 Subject: [PATCH] lint --- aider/models.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/aider/models.py b/aider/models.py index 6289babca..8c4a0c3ea 100644 --- a/aider/models.py +++ b/aider/models.py @@ -878,20 +878,24 @@ class Model(ModelSettings): def github_copilot_token_to_open_ai_key(self): # check to see if there's an openai api key # If so, check to see if it's expire - openai_api_key = 'OPENAI_API_KEY' + openai_api_key = "OPENAI_API_KEY" if openai_api_key not in os.environ or ( - int(dict(x.split("=") for x in os.environ[openai_api_key].split(";"))['exp']) < int(datetime.now().timestamp()) + int(dict(x.split("=") for x in os.environ[openai_api_key].split(";"))["exp"]) + < int(datetime.now().timestamp()) ): import requests + headers = { - 'Authorization': f"Bearer {os.environ['GITHUB_COPILOT_TOKEN']}", - 'Editor-Version': self.extra_params['extra_headers']['Editor-Version'], - 'Copilot-Integration-Id': self.extra_params['extra_headers']['Copilot-Integration-Id'], - 'Content-Type': 'application/json', + "Authorization": f"Bearer {os.environ['GITHUB_COPILOT_TOKEN']}", + "Editor-Version": self.extra_params["extra_headers"]["Editor-Version"], + "Copilot-Integration-Id": self.extra_params["extra_headers"][ + "Copilot-Integration-Id" + ], + "Content-Type": "application/json", } res = requests.get("https://api.github.com/copilot_internal/v2/token", headers=headers) - os.environ[openai_api_key] = res.json()['token'] + os.environ[openai_api_key] = res.json()["token"] def send_completion(self, messages, functions, stream, temperature=None): if os.environ.get("AIDER_SANITY_CHECK_TURNS"): @@ -935,7 +939,7 @@ class Model(ModelSettings): kwargs["messages"] = messages # Are we using github copilot? - if 'GITHUB_COPILOT_TOKEN' in os.environ: + if "GITHUB_COPILOT_TOKEN" in os.environ: self.github_copilot_token_to_open_ai_key() res = litellm.completion(**kwargs)