Closed Agent-E11 closed 3 months ago
I'd recommend making a class to contain the conversation history, and instantiating it for each context environment you want (I did per channel, but IIRC you wanted to do per Server).
https://github.com/joshbuker/discord-bot/blob/main/lib/discord_bot/llm/conversation.rb https://github.com/joshbuker/discord-bot/blob/main/lib/discord_bot/bot.rb#L197 https://github.com/joshbuker/discord-bot/blob/main/lib/discord_bot/bot.rb#L253
I'd also recommend abstracting the API calls into a class that can handle the implementation details: https://github.com/joshbuker/discord-bot/blob/main/lib/discord_bot/llm/api_request.rb
Usage example: https://github.com/joshbuker/discord-bot/blob/main/lib/discord_bot/llm/response.rb
It currently uses the
/api/generate
endpoint to generate one-off responses. The/api/chat
endpoint fits our use case better, and is better for integrating history/context