mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-27 15:05:00 +00:00
Merge branch 'main' of github.com:Aider-AI/aider
This commit is contained in:
commit
ef2986a231
2 changed files with 33 additions and 10 deletions
|
@ -8,6 +8,7 @@ import platform
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from dataclasses import dataclass, fields
|
from dataclasses import dataclass, fields
|
||||||
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
|
@ -874,6 +875,24 @@ class Model(ModelSettings):
|
||||||
def is_ollama(self):
|
def is_ollama(self):
|
||||||
return self.name.startswith("ollama/") or self.name.startswith("ollama_chat/")
|
return self.name.startswith("ollama/") or self.name.startswith("ollama_chat/")
|
||||||
|
|
||||||
|
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'
|
||||||
|
|
||||||
|
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())
|
||||||
|
):
|
||||||
|
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',
|
||||||
|
}
|
||||||
|
res = requests.get("https://api.github.com/copilot_internal/v2/token", headers=headers)
|
||||||
|
os.environ[openai_api_key] = res.json()['token']
|
||||||
|
|
||||||
def send_completion(self, messages, functions, stream, temperature=None):
|
def send_completion(self, messages, functions, stream, temperature=None):
|
||||||
if os.environ.get("AIDER_SANITY_CHECK_TURNS"):
|
if os.environ.get("AIDER_SANITY_CHECK_TURNS"):
|
||||||
sanity_check_messages(messages)
|
sanity_check_messages(messages)
|
||||||
|
@ -915,6 +934,10 @@ class Model(ModelSettings):
|
||||||
dump(kwargs)
|
dump(kwargs)
|
||||||
kwargs["messages"] = messages
|
kwargs["messages"] = messages
|
||||||
|
|
||||||
|
# Are we using github copilot?
|
||||||
|
if 'GITHUB_COPILOT_TOKEN' in os.environ:
|
||||||
|
self.github_copilot_token_to_open_ai_key()
|
||||||
|
|
||||||
res = litellm.completion(**kwargs)
|
res = litellm.completion(**kwargs)
|
||||||
return hash_object, res
|
return hash_object, res
|
||||||
|
|
||||||
|
|
|
@ -1621,7 +1621,7 @@
|
||||||
extra_params:
|
extra_params:
|
||||||
extra_headers:
|
extra_headers:
|
||||||
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
||||||
max_tokens: 64000
|
max_tokens: 32000
|
||||||
cache_control: true
|
cache_control: true
|
||||||
editor_model_name: claude-sonnet-4-20250514
|
editor_model_name: claude-sonnet-4-20250514
|
||||||
editor_edit_format: editor-diff
|
editor_edit_format: editor-diff
|
||||||
|
@ -1635,7 +1635,7 @@
|
||||||
extra_params:
|
extra_params:
|
||||||
extra_headers:
|
extra_headers:
|
||||||
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
||||||
max_tokens: 64000
|
max_tokens: 32000
|
||||||
cache_control: true
|
cache_control: true
|
||||||
editor_model_name: anthropic/claude-sonnet-4-20250514
|
editor_model_name: anthropic/claude-sonnet-4-20250514
|
||||||
editor_edit_format: editor-diff
|
editor_edit_format: editor-diff
|
||||||
|
@ -1649,7 +1649,7 @@
|
||||||
extra_params:
|
extra_params:
|
||||||
extra_headers:
|
extra_headers:
|
||||||
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
||||||
max_tokens: 64000
|
max_tokens: 32000
|
||||||
cache_control: true
|
cache_control: true
|
||||||
editor_model_name: anthropic.claude-sonnet-4-20250514-v1:0
|
editor_model_name: anthropic.claude-sonnet-4-20250514-v1:0
|
||||||
editor_edit_format: editor-diff
|
editor_edit_format: editor-diff
|
||||||
|
@ -1663,7 +1663,7 @@
|
||||||
extra_params:
|
extra_params:
|
||||||
extra_headers:
|
extra_headers:
|
||||||
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
||||||
max_tokens: 64000
|
max_tokens: 32000
|
||||||
cache_control: true
|
cache_control: true
|
||||||
editor_model_name: bedrock_converse/anthropic.claude-sonnet-4-20250514-v1:0
|
editor_model_name: bedrock_converse/anthropic.claude-sonnet-4-20250514-v1:0
|
||||||
editor_edit_format: editor-diff
|
editor_edit_format: editor-diff
|
||||||
|
@ -1677,7 +1677,7 @@
|
||||||
extra_params:
|
extra_params:
|
||||||
extra_headers:
|
extra_headers:
|
||||||
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
||||||
max_tokens: 64000
|
max_tokens: 32000
|
||||||
cache_control: true
|
cache_control: true
|
||||||
editor_model_name: bedrock_converse/us.anthropic.claude-sonnet-4-20250514-v1:0
|
editor_model_name: bedrock_converse/us.anthropic.claude-sonnet-4-20250514-v1:0
|
||||||
editor_edit_format: editor-diff
|
editor_edit_format: editor-diff
|
||||||
|
@ -1691,7 +1691,7 @@
|
||||||
extra_params:
|
extra_params:
|
||||||
extra_headers:
|
extra_headers:
|
||||||
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
||||||
max_tokens: 64000
|
max_tokens: 32000
|
||||||
cache_control: true
|
cache_control: true
|
||||||
editor_model_name: bedrock_converse/eu.anthropic.claude-sonnet-4-20250514-v1:0
|
editor_model_name: bedrock_converse/eu.anthropic.claude-sonnet-4-20250514-v1:0
|
||||||
editor_edit_format: editor-diff
|
editor_edit_format: editor-diff
|
||||||
|
@ -1705,7 +1705,7 @@
|
||||||
extra_params:
|
extra_params:
|
||||||
extra_headers:
|
extra_headers:
|
||||||
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
||||||
max_tokens: 64000
|
max_tokens: 32000
|
||||||
cache_control: true
|
cache_control: true
|
||||||
editor_model_name: eu.anthropic.claude-sonnet-4-20250514-v1:0
|
editor_model_name: eu.anthropic.claude-sonnet-4-20250514-v1:0
|
||||||
editor_edit_format: editor-diff
|
editor_edit_format: editor-diff
|
||||||
|
@ -1719,7 +1719,7 @@
|
||||||
extra_params:
|
extra_params:
|
||||||
extra_headers:
|
extra_headers:
|
||||||
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
|
||||||
max_tokens: 64000
|
max_tokens: 32000
|
||||||
cache_control: true
|
cache_control: true
|
||||||
editor_model_name: us.anthropic.claude-sonnet-4-20250514-v1:0
|
editor_model_name: us.anthropic.claude-sonnet-4-20250514-v1:0
|
||||||
editor_edit_format: editor-diff
|
editor_edit_format: editor-diff
|
||||||
|
@ -1731,7 +1731,7 @@
|
||||||
use_repo_map: true
|
use_repo_map: true
|
||||||
examples_as_sys_msg: false
|
examples_as_sys_msg: false
|
||||||
extra_params:
|
extra_params:
|
||||||
max_tokens: 64000
|
max_tokens: 32000
|
||||||
editor_model_name: vertex_ai/claude-sonnet-4@20250514
|
editor_model_name: vertex_ai/claude-sonnet-4@20250514
|
||||||
editor_edit_format: editor-diff
|
editor_edit_format: editor-diff
|
||||||
accepts_settings: ["thinking_tokens"]
|
accepts_settings: ["thinking_tokens"]
|
||||||
|
@ -1742,7 +1742,7 @@
|
||||||
use_repo_map: true
|
use_repo_map: true
|
||||||
examples_as_sys_msg: false
|
examples_as_sys_msg: false
|
||||||
extra_params:
|
extra_params:
|
||||||
max_tokens: 64000
|
max_tokens: 32000
|
||||||
editor_model_name: vertex_ai-anthropic_models/vertex_ai/claude-sonnet-4@20250514
|
editor_model_name: vertex_ai-anthropic_models/vertex_ai/claude-sonnet-4@20250514
|
||||||
editor_edit_format: editor-diff
|
editor_edit_format: editor-diff
|
||||||
accepts_settings: ["thinking_tokens"]
|
accepts_settings: ["thinking_tokens"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue