Fix formatting in ask-code.py and commit.py
This commit is contained in:
parent
d67c3d26a1
commit
14dc3b2b52
@ -48,7 +48,7 @@ def query(question, lsp_brige_port):
|
||||
spent_money += (price[0] * token_usage.prompt_tokens) / 1000 + (
|
||||
price[1] * token_usage.completion_tokens
|
||||
) / 1000
|
||||
spent_money = spent_money/0.7
|
||||
spent_money = spent_money / 0.7
|
||||
print(f"***/ask-code has costed approximately ${spent_money:.4f} USD for this question.***")
|
||||
|
||||
|
||||
|
@ -47,16 +47,18 @@ def assert_value(value, message):
|
||||
print(message, file=sys.stderr, flush=True)
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
def decode_path(encoded_path):
|
||||
octal_pattern = re.compile(r'\\[0-7]{3}')
|
||||
octal_pattern = re.compile(r"\\[0-7]{3}")
|
||||
|
||||
if octal_pattern.search(encoded_path):
|
||||
bytes_path = encoded_path.encode('utf-8').decode('unicode_escape').encode('latin1')
|
||||
decoded_path = bytes_path.decode('utf-8')
|
||||
bytes_path = encoded_path.encode("utf-8").decode("unicode_escape").encode("latin1")
|
||||
decoded_path = bytes_path.decode("utf-8")
|
||||
return decoded_path
|
||||
else:
|
||||
return encoded_path
|
||||
|
||||
|
||||
def get_modified_files():
|
||||
"""
|
||||
获取当前修改文件列表以及已经staged的文件列表
|
||||
@ -68,7 +70,7 @@ def get_modified_files():
|
||||
tuple: 包含两个list的元组,第一个list包含当前修改过的文件,第二个list包含已经staged的文件
|
||||
"""
|
||||
""" 获取当前修改文件列表以及已经staged的文件列表"""
|
||||
output = subprocess.check_output(["git", "status", "-s", "-u"], text=True, encoding="utf-8")
|
||||
output = subprocess.check_output(["git", "status", "-s", "-u"], text=True, encoding="utf-8")
|
||||
lines = output.split("\n")
|
||||
modified_files = []
|
||||
staged_files = []
|
||||
@ -355,8 +357,13 @@ def generate_commit_message_base_diff(user_input, diff):
|
||||
"{__USER_INPUT__}", f"{user_input + language_prompt}"
|
||||
)
|
||||
if len(str(prompt)) > 10000:
|
||||
print("Due to the large size of the diff data, generating a commit message through AI would be very costly, therefore, it is not recommended to use AI for generating the description. Please manually edit the commit message before submitting.")
|
||||
return {"content":""}
|
||||
print(
|
||||
"Due to the large size of the diff data, "
|
||||
"generating a commit message through AI would be very costly, therefore, "
|
||||
"it is not recommended to use AI for generating the description. "
|
||||
"Please manually edit the commit message before submitting."
|
||||
)
|
||||
return {"content": ""}
|
||||
|
||||
messages = [{"role": "user", "content": prompt}]
|
||||
response = chat_completion_no_stream(
|
||||
|
Loading…
x
Reference in New Issue
Block a user