use referenced message as additional context

pull/3/head
Michael Yang 2023-09-20 19:45:51 -07:00
parent ece0269e4b
commit 924017de97
1 changed files with 14 additions and 1 deletions

View File

@ -93,7 +93,20 @@ async def on_message(message):
async with message.channel.typing(): async with message.channel.typing():
await message.add_reaction('🤔') await message.add_reaction('🤔')
async for buffer, chunk in buffered_generate_response(raw_content, **load_session(message.reference)): context = []
if reference := message.reference:
if session := load_session(message.reference):
context = session.get('context', [])
reference_message = await message.channel.fetch_message(reference.message_id)
reference_content = reference_message.content
raw_content = '\n'.join([
raw_content,
'Use it to answer the prompt:',
reference_content,
])
async for buffer, chunk in buffered_generate_response(raw_content, context=context):
response_content += buffer response_content += buffer
if chunk['done']: if chunk['done']:
save_session(response, chunk) save_session(response, chunk)