From b139e40f8a0212c922515806397224871a1a0215 Mon Sep 17 00:00:00 2001 From: Paillat Date: Tue, 15 Aug 2023 10:44:13 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(config.py):=20add=20missing?= =?UTF-8?q?=20newline=20at=20the=20end=20of=20the=20file=20=F0=9F=90=9B=20?= =?UTF-8?q?fix(makeprompt.py):=20remove=20unnecessary=20file=20close=20sta?= =?UTF-8?q?tement=20after=20reading=20prompt=20file=20=E2=9C=A8=20feat(con?= =?UTF-8?q?fig.py):=20add=20gpt=5F3=5F5=5Fturbo=5Fprompt=20variable=20to?= =?UTF-8?q?=20store=20the=20content=20of=20the=20prompt=20file=20=E2=9C=A8?= =?UTF-8?q?=20feat(makeprompt.py):=20use=20gpt=5F3=5F5=5Fturbo=5Fprompt=20?= =?UTF-8?q?variable=20instead=20of=20reading=20the=20prompt=20file=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.py | 3 +++ src/makeprompt.py | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/config.py b/src/config.py index 4c1c7c5..e586aae 100644 --- a/src/config.py +++ b/src/config.py @@ -100,3 +100,6 @@ curs_premium.execute( curs_premium.execute( """CREATE TABLE IF NOT EXISTS channels (guild_id text, channel0 text, channel1 text, channel2 text, channel3 text, channel4 text)""" ) + +with open(os.path.abspath(os.path.dirname(__file__), "./prompts/gpt-3.5-turbo.txt"), "r", encoding="utf-8") as file: + gpt_3_5_turbo_prompt = file.read() \ No newline at end of file diff --git a/src/makeprompt.py b/src/makeprompt.py index ed81046..ae38eea 100644 --- a/src/makeprompt.py +++ b/src/makeprompt.py @@ -1,10 +1,11 @@ import asyncio import os -from src.config import curs_data, max_uses, curs_premium import re import discord import datetime import json + +from src.config import curs_data, max_uses, curs_premium, gpt_3_5_turbo_prompt from src.utils.misc import moderate from src.utils.openaicaller import openai_caller from src.functionscalls import ( @@ -303,9 +304,7 @@ async def chat_process(self, message): prompt_path = os.path.abspath( os.path.join(os.path.dirname(__file__), f"./prompts/{model}.txt") ) - with open(prompt_path, "r") as f: - prompt = f.read() - f.close() + prompt = gpt_3_5_turbo_prompt[:] # copy the prompt but to dnot reference it prompt = ( prompt.replace("[prompt-prefix]", prompt_prefix)