mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
ExhaustedContextWindow
This commit is contained in:
parent
8820eb0399
commit
db47ac9f39
1 changed files with 10 additions and 3 deletions
|
@ -25,6 +25,10 @@ class MissingAPIKeyError(ValueError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ExhaustedContextWindow(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Coder:
|
class Coder:
|
||||||
abs_fnames = None
|
abs_fnames = None
|
||||||
repo = None
|
repo = None
|
||||||
|
@ -450,7 +454,7 @@ class Coder:
|
||||||
temperature=0,
|
temperature=0,
|
||||||
stream=True,
|
stream=True,
|
||||||
)
|
)
|
||||||
if self.functions:
|
if hasattr(self, "functions"):
|
||||||
kwargs["functions"] = self.functions
|
kwargs["functions"] = self.functions
|
||||||
|
|
||||||
res = openai.ChatCompletion.create(**kwargs)
|
res = openai.ChatCompletion.create(**kwargs)
|
||||||
|
@ -492,8 +496,11 @@ class Coder:
|
||||||
|
|
||||||
for chunk in completion:
|
for chunk in completion:
|
||||||
dump(chunk)
|
dump(chunk)
|
||||||
if chunk.choices[0].finish_reason not in (None, "stop", "function_call"):
|
if chunk.choices[0].finish_reason == "length":
|
||||||
assert False, "Exceeded context window!"
|
raise ExhaustedContextWindow(
|
||||||
|
"Exhausted context window. Try /clear to clear chat history, or /drop to"
|
||||||
|
" remove unneeded files from the chat session."
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
func = chunk.choices[0].delta.function_call
|
func = chunk.choices[0].delta.function_call
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue