From 82135d1590b5cecd75d6c501ddfc704ee27acf81 Mon Sep 17 00:00:00 2001 From: phixxy Date: Sat, 3 Feb 2024 04:39:33 -0800 Subject: [PATCH] changed blog generation --- extensions/phixxycom.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/extensions/phixxycom.py b/extensions/phixxycom.py index afca2b2..6e22a1c 100644 --- a/extensions/phixxycom.py +++ b/extensions/phixxycom.py @@ -222,8 +222,18 @@ class PhixxyCom(commands.Cog): f.writelines(message+'\n') await ctx.send("Saved suggestion!") + def get_last_5_messages(self): + with open(f"data/chatgpt/logs/346102473993355267.log", 'r') as f: + lines = f.readlines() + last_5_messages = "" + for i in range(5,1,-1): + last_5_messages += lines[-i] + last_5_messages += "\n" + print(last_5_messages) + return last_5_messages + async def generate_blog(self): - if self.upload_enabled.lower() == "true": + if True:#self.upload_enabled.lower() == "true": start_time = time.time() topic = '' filename = f"{self.data_dir}ai-blog/index.html" @@ -246,8 +256,10 @@ class PhixxyCom(commands.Cog): if topic != '': self.bot.logger.info("Writing blogpost") else: + messages = self.get_last_5_messages() + question = f"you have a blog and you are inspired based on this short text chat interaction:\n{messages}\nwhat will the topic of your next blog be? just tell me the topic and a one sentence description" self.bot.logger.info("No topic given for blogpost, generating one.") - topic = await self.answer_question("Give me one topic for an absurd blogpost.") + topic = await self.answer_question(question) post_div = '''