mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 06:44:59 +00:00
refac
This commit is contained in:
parent
2fbf57e22c
commit
9d7643bacb
1 changed files with 22 additions and 10 deletions
28
coder.py
28
coder.py
|
@ -237,10 +237,28 @@ MAKE ANY CHANGES BASED OFF THESE FILES!
|
||||||
temperature=0,
|
temperature=0,
|
||||||
stream = True,
|
stream = True,
|
||||||
)
|
)
|
||||||
resp = []
|
|
||||||
|
|
||||||
if show_progress:
|
if show_progress:
|
||||||
|
return self.show_send_progress(completion)
|
||||||
|
else:
|
||||||
|
return self.show_send_output(completion)
|
||||||
|
|
||||||
|
def show_send_progress(self, completion):
|
||||||
|
resp = []
|
||||||
pbar = tqdm(total = show_progress)
|
pbar = tqdm(total = show_progress)
|
||||||
|
for chunk in completion:
|
||||||
|
try:
|
||||||
|
text = chunk.choices[0].delta.content
|
||||||
|
resp.append(text)
|
||||||
|
except AttributeError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
pbar.update(len(text))
|
||||||
|
resp = ''.join(resp)
|
||||||
|
return resp
|
||||||
|
|
||||||
|
def show_send_output(self, completion):
|
||||||
|
resp = []
|
||||||
|
|
||||||
for chunk in completion:
|
for chunk in completion:
|
||||||
try:
|
try:
|
||||||
|
@ -248,16 +266,10 @@ MAKE ANY CHANGES BASED OFF THESE FILES!
|
||||||
resp.append(text)
|
resp.append(text)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
if show_progress:
|
|
||||||
pbar.update(len(text))
|
|
||||||
else:
|
|
||||||
sys.stdout.write(text)
|
sys.stdout.write(text)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
if show_progress:
|
|
||||||
pbar.update(show_progress)
|
|
||||||
pbar.close()
|
|
||||||
|
|
||||||
resp = ''.join(resp)
|
resp = ''.join(resp)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue