mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
fixed benchmark
This commit is contained in:
parent
d92a93221c
commit
bf03f43b44
4 changed files with 18 additions and 11 deletions
|
@ -480,7 +480,6 @@ class Coder:
|
|||
except ExhaustedContextWindow:
|
||||
exhausted = True
|
||||
except openai.BadRequestError as err:
|
||||
dump(err)
|
||||
if "maximum context length" in str(err):
|
||||
exhausted = True
|
||||
else:
|
||||
|
@ -955,7 +954,6 @@ class Coder:
|
|||
|
||||
def check_model_availability(io, client, main_model):
|
||||
available_models = client.models.list()
|
||||
dump(available_models)
|
||||
model_ids = sorted(model.id for model in available_models)
|
||||
if main_model.name in model_ids:
|
||||
return True
|
||||
|
|
|
@ -177,7 +177,7 @@ def main(argv=None, input=None, output=None, force_git_root=None):
|
|||
model_group.add_argument(
|
||||
"--openai-api-base",
|
||||
metavar="OPENAI_API_BASE",
|
||||
help="Specify the api_base (default: https://api.openai.com/v1)",
|
||||
help="Specify the api base url",
|
||||
)
|
||||
model_group.add_argument(
|
||||
"--openai-api-type",
|
||||
|
@ -497,14 +497,15 @@ def main(argv=None, input=None, output=None, force_git_root=None):
|
|||
)
|
||||
else:
|
||||
kwargs = dict()
|
||||
if args.openai_api_base and "openrouter.ai" in args.openai_api_base:
|
||||
kwargs["default_headers"] = {"HTTP-Referer": "http://aider.chat", "X-Title": "Aider"}
|
||||
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",
|
||||
}
|
||||
|
||||
client = openai.OpenAI(
|
||||
api_key=args.openai_api_key,
|
||||
base_url=args.openai_api_base,
|
||||
**kwargs,
|
||||
)
|
||||
client = openai.OpenAI(api_key=args.openai_api_key, **kwargs)
|
||||
|
||||
main_model = models.Model.create(args.model, client)
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import git
|
|||
import lox
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import openai
|
||||
import pandas as pd
|
||||
import prompts
|
||||
import typer
|
||||
|
@ -630,10 +631,13 @@ def run_test(
|
|||
show_fnames = ",".join(map(str, fnames))
|
||||
print("fnames:", show_fnames)
|
||||
|
||||
client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
|
||||
|
||||
coder = Coder.create(
|
||||
main_model,
|
||||
edit_format,
|
||||
io,
|
||||
client=client,
|
||||
fnames=fnames,
|
||||
use_git=False,
|
||||
stream=False,
|
||||
|
|
|
@ -274,13 +274,17 @@ done
|
|||
You can also script aider from python:
|
||||
|
||||
```python
|
||||
import openai
|
||||
from aider.coders import Coder
|
||||
|
||||
# Make an openai client
|
||||
client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
|
||||
|
||||
# This is a list of files to add to the chat
|
||||
fnames = ["foo.py"]
|
||||
|
||||
# Create a coder object
|
||||
coder = Coder.create(fnames=fnames)
|
||||
coder = Coder.create(client=client, fnames=fnames)
|
||||
|
||||
# This will execute one instruction on those files and then return
|
||||
coder.run("make a script that prints hello world")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue