huggingface / discord-bots

48 stars 4 forks source link

For chat models, retrieve conversation from thread rather than storing in a dictionary #20

Open osanseviero opened 1 year ago

lunarflu commented 1 year ago

BTW for Falcon 180B, since we're using Freddy's as the template, would we need to adjust to a different Gradio interface to manually handle chathistory then?

osanseviero commented 1 year ago

I think we are updating https://github.com/huggingface/discord-bots/blob/main/falcon.py with the new code from https://huggingface.co/spaces/freddyaboulton/falcon-180b-demo-gradio-discord-bot/blob/main/app.py#L2 . In this demo, we create a new client (see get_client) for each thread, which allows to have similar behaviour.

So we should

Thanks to this, we would remove the need to store any information about the conversations in the bot code and keep things minimal

lunarflu commented 1 year ago

To touch back on this, do you think it still makes sense to explore? (not seeing a lot of usage from #codellama channel imo) image

osanseviero commented 1 year ago

SG to not do this right now, let's explore in a follow-up if we see issues with this later on.

not-lain commented 11 months ago

to retrieve the history from a thread you can use this :

history = await message.channel.history(limit=10).flatten()
# remove the first message which is the prompt
prompt = history.pop(0)
print("prompt :",prompt.content)
# print the history
print("history is ")
for h in history:
      print(f"{h.author} : {h.content}")
not-lain commented 9 months ago

new update for retrieving messages from history when using discord.py https://discordpy.readthedocs.io/en/latest/migrating.html#moving-away-from-custom-asynciterator