mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
refac
This commit is contained in:
parent
1c53bff5ca
commit
1f8ce95dfa
2 changed files with 36 additions and 26 deletions
|
@ -513,11 +513,6 @@ class Coder:
|
||||||
self.partial_response_function_call[k] += v
|
self.partial_response_function_call[k] += v
|
||||||
else:
|
else:
|
||||||
self.partial_response_function_call[k] = v
|
self.partial_response_function_call[k] = v
|
||||||
# dump(self.partial_response_function_call)
|
|
||||||
args = self.partial_response_function_call.get("arguments")
|
|
||||||
args = parse_partial_args(args)
|
|
||||||
dump(args)
|
|
||||||
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -533,6 +528,7 @@ class Coder:
|
||||||
|
|
||||||
if self.pretty:
|
if self.pretty:
|
||||||
show_resp = self.modify_incremental_response()
|
show_resp = self.modify_incremental_response()
|
||||||
|
if show_resp:
|
||||||
md = Markdown(
|
md = Markdown(
|
||||||
show_resp, style=self.assistant_output_color, code_theme="default"
|
show_resp, style=self.assistant_output_color, code_theme="default"
|
||||||
)
|
)
|
||||||
|
@ -732,14 +728,12 @@ class Coder:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return None, err
|
return None, err
|
||||||
|
|
||||||
|
def parse_partial_args(self):
|
||||||
|
# dump(self.partial_response_function_call)
|
||||||
|
data = self.partial_response_function_call.get("arguments")
|
||||||
|
if not data:
|
||||||
|
return
|
||||||
|
|
||||||
def check_model_availability(main_model):
|
|
||||||
available_models = openai.Model.list()
|
|
||||||
model_ids = [model.id for model in available_models["data"]]
|
|
||||||
return main_model.name in model_ids
|
|
||||||
|
|
||||||
|
|
||||||
def parse_partial_args(data):
|
|
||||||
try:
|
try:
|
||||||
return json.loads(data)
|
return json.loads(data)
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
|
@ -754,3 +748,9 @@ def parse_partial_args(data):
|
||||||
return json.loads(data + '"}')
|
return json.loads(data + '"}')
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def check_model_availability(main_model):
|
||||||
|
available_models = openai.Model.list()
|
||||||
|
model_ids = [model.id for model in available_models["data"]]
|
||||||
|
return main_model.name in model_ids
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -48,6 +49,15 @@ class FunctionCoder(Coder):
|
||||||
self.cur_messages += [dict(role="assistant", content=content)]
|
self.cur_messages += [dict(role="assistant", content=content)]
|
||||||
|
|
||||||
def modify_incremental_response(self):
|
def modify_incremental_response(self):
|
||||||
|
args = self.parse_partial_args()
|
||||||
|
if not args:
|
||||||
|
return
|
||||||
|
args = json.dumps(args, indent=4)
|
||||||
|
return f"""
|
||||||
|
```js
|
||||||
|
{args}
|
||||||
|
```
|
||||||
|
"""
|
||||||
resp = self.partial_response_content
|
resp = self.partial_response_content
|
||||||
return self.update_files(resp, mode="diff")
|
return self.update_files(resp, mode="diff")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue