mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-23 23:55:05 +01:00
allow content passed by system role to be customized on reset
This commit is contained in:
@@ -124,11 +124,13 @@ class OpenAIHelper:
|
||||
result = await openai.Audio.atranscribe("whisper-1", audio)
|
||||
return result.text
|
||||
|
||||
def reset_chat_history(self, chat_id):
|
||||
def reset_chat_history(self, chat_id, content):
|
||||
"""
|
||||
Resets the conversation history.
|
||||
"""
|
||||
self.conversations[chat_id] = [{"role": "system", "content": self.config['assistant_prompt']}]
|
||||
if content == '':
|
||||
content = self.config['assistant_prompt']
|
||||
self.conversations[chat_id] = [{"role": "system", "content": content}]
|
||||
|
||||
def __max_age_reached(self, chat_id) -> bool:
|
||||
"""
|
||||
|
||||
@@ -95,7 +95,8 @@ class ChatGPT3TelegramBot:
|
||||
logging.info(f'Resetting the conversation for user {update.message.from_user.name}...')
|
||||
|
||||
chat_id = update.effective_chat.id
|
||||
self.openai.reset_chat_history(chat_id=chat_id)
|
||||
reset_content = update.message.text.replace('/reset', '').strip()
|
||||
self.openai.reset_chat_history(chat_id=chat_id, content=reset_content)
|
||||
await context.bot.send_message(chat_id=chat_id, text='Done!')
|
||||
|
||||
async def image(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
|
||||
Reference in New Issue
Block a user