diff --git a/pr-message/src/config/init_config.py b/pr-message/src/config/init_config.py index 71fefb6bd5c4bcc5f257cda7a34d13a40c0171ef..f3138dd3072e7561c4895bb1b08b2bca89f829af 100644 --- a/pr-message/src/config/init_config.py +++ b/pr-message/src/config/init_config.py @@ -1,4 +1,3 @@ -import os import yaml from gitee.gitee_api import GiteeApiCaller from gpt.gpt import Gpt @@ -16,7 +15,9 @@ def init_config(path): config["gpt"]["max_token_length"], config["gpt"]["encoding_name"], config["gpt"]["url"], - config["gpt"]["limit"] + config["gpt"]["limit"], + config["gpt"]["system_message"], + config["gpt"]["summary_message"] ) Diff_Prompt.init_config_attr() diff --git a/pr-message/src/gpt/chat_gpt.py b/pr-message/src/gpt/chat_gpt.py index 2fcc4af2eca11a7c582e03ee2b73881e2fdecbe0..c600f9faadbfb9523c06039dfe77e107bdead144 100644 --- a/pr-message/src/gpt/chat_gpt.py +++ b/pr-message/src/gpt/chat_gpt.py @@ -11,14 +11,7 @@ class ChatGpt(Gpt): "messages": [ { "role": "system", - "content": ( - "您将充当 git 中提交消息的作者。" - "您的任务是在传统git提交中创建清晰且全面的提交消息,详细清晰的解释更改内容。 我将向您发送“git diff --staged”命令的输出,然后您将以\"+\"和\"-\"开头的行内容转换为提交消息。" - "行长度不得超过 74 个字符。" - "用中文回答。" - "使用如下模板:" - "- 修改细节\n" - ), + "content": Gpt.system_message, }, { "role": "user", @@ -44,11 +37,7 @@ class ChatGpt(Gpt): "messages": [ { "role": "system", - "content": ("您的任务是高度概括总结我给您的输入内容。" - "不输出修改的文件列表" - "不超过10行,每行不得超过 74 个字符" - "用中文回答。" - ), + "content": Gpt.summary_message, }, { "role": "user", diff --git a/pr-message/src/gpt/gpt.py b/pr-message/src/gpt/gpt.py index ecb38554155af32b2875ed0b18d740c294482fa4..74ab872c5f4d0ced295cda96caa96bc55fdb8e33 100644 --- a/pr-message/src/gpt/gpt.py +++ b/pr-message/src/gpt/gpt.py @@ -7,13 +7,17 @@ class Gpt(metaclass=ABCMeta): encoding_name = "" url = "" limit = 5 + system_message = "" + summary_message = "" - def init_config_attr(use, max_token_length, encoding_name, url, limit): + def init_config_attr(use, max_token_length, encoding_name, url, limit, system_message, summary_message): Gpt.use = use Gpt.max_token_length = max_token_length Gpt.encoding_name = encoding_name Gpt.url = url Gpt.limit = limit + Gpt.system_message = system_message + Gpt.summary_message = summary_message @abstractmethod def get_answer(prompt):