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 + (
|
spent_money += (price[0] * token_usage.prompt_tokens) / 1000 + (
|
||||||
price[1] * token_usage.completion_tokens
|
price[1] * token_usage.completion_tokens
|
||||||
) / 1000
|
) / 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.***")
|
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)
|
print(message, file=sys.stderr, flush=True)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
|
||||||
def decode_path(encoded_path):
|
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):
|
if octal_pattern.search(encoded_path):
|
||||||
bytes_path = encoded_path.encode('utf-8').decode('unicode_escape').encode('latin1')
|
bytes_path = encoded_path.encode("utf-8").decode("unicode_escape").encode("latin1")
|
||||||
decoded_path = bytes_path.decode('utf-8')
|
decoded_path = bytes_path.decode("utf-8")
|
||||||
return decoded_path
|
return decoded_path
|
||||||
else:
|
else:
|
||||||
return encoded_path
|
return encoded_path
|
||||||
|
|
||||||
|
|
||||||
def get_modified_files():
|
def get_modified_files():
|
||||||
"""
|
"""
|
||||||
获取当前修改文件列表以及已经staged的文件列表
|
获取当前修改文件列表以及已经staged的文件列表
|
||||||
@ -68,7 +70,7 @@ def get_modified_files():
|
|||||||
tuple: 包含两个list的元组,第一个list包含当前修改过的文件,第二个list包含已经staged的文件
|
tuple: 包含两个list的元组,第一个list包含当前修改过的文件,第二个list包含已经staged的文件
|
||||||
"""
|
"""
|
||||||
""" 获取当前修改文件列表以及已经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")
|
lines = output.split("\n")
|
||||||
modified_files = []
|
modified_files = []
|
||||||
staged_files = []
|
staged_files = []
|
||||||
@ -355,8 +357,13 @@ def generate_commit_message_base_diff(user_input, diff):
|
|||||||
"{__USER_INPUT__}", f"{user_input + language_prompt}"
|
"{__USER_INPUT__}", f"{user_input + language_prompt}"
|
||||||
)
|
)
|
||||||
if len(str(prompt)) > 10000:
|
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.")
|
print(
|
||||||
return {"content":""}
|
"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}]
|
messages = [{"role": "user", "content": prompt}]
|
||||||
response = chat_completion_no_stream(
|
response = chat_completion_no_stream(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user