From 7a2948fbca403cfd459ddfa0db208eb8193c3063 Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Fri, 16 Jun 2023 06:22:34 +0000 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=B8=A2=E5=A4=B1=E7=9A=84?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- utils/config.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 utils/config.py diff --git a/.gitignore b/.gitignore index 6ef38dd..9389032 100644 --- a/.gitignore +++ b/.gitignore @@ -141,4 +141,4 @@ dmypy.json # Cython debug symbols cython_debug/ -config.py \ No newline at end of file +/config.py \ No newline at end of file diff --git a/utils/config.py b/utils/config.py new file mode 100644 index 0000000..b26b835 --- /dev/null +++ b/utils/config.py @@ -0,0 +1,17 @@ +import config + +def get_prompt(name: str, type: str, params: dict = {}): + sys_params = { + "bot_name": config.CHATCOMPLETE_BOT_NAME + } + if name in config.PROMPTS and type in config.PROMPTS[name]: + prompt = config.PROMPTS[name][type] + + for key in sys_params: + prompt = prompt.replace("{" + key + "}", sys_params[key]) + for key in params: + prompt = prompt.replace("{" + key + "}", params[key]) + + return prompt + else: + return None \ No newline at end of file