Add support for on-demand involvement
Fixes https://github.com/etkecc/baibot/issues/15
This commit is contained in:
13
src/entity/interaction_context.rs
Normal file
13
src/entity/interaction_context.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use mxlink::ThreadInfo;
|
||||
|
||||
use super::MessagePayload;
|
||||
|
||||
pub struct InteractionContext {
|
||||
pub thread_info: ThreadInfo,
|
||||
pub trigger: InteractionTrigger,
|
||||
}
|
||||
|
||||
pub struct InteractionTrigger {
|
||||
pub is_mentioning_bot: bool,
|
||||
pub payload: MessagePayload,
|
||||
}
|
||||
@@ -6,10 +6,28 @@ use mxlink::matrix_sdk::ruma::{OwnedEventId, OwnedUserId};
|
||||
use mxlink::ThreadInfo;
|
||||
|
||||
/// MessagePayload is like matrix-sdk's MessageType, but represents only message types that the bot deals with and payloads are massaged a bit.
|
||||
///
|
||||
/// This also includes a few synthetic events.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum MessagePayload {
|
||||
Text(TextMessageEventContent),
|
||||
/// A synthetic message payload that indicates that the bot should produce a reply inside a thread.
|
||||
/// This does not represent an actual message event, it's just a way to trigger a chat completion.
|
||||
///
|
||||
/// When this is invoked, the ThreadInfo contains the full thread details (which represents our context).
|
||||
///
|
||||
/// See: https://github.com/etkecc/baibot/issues/15
|
||||
SynthethicChatCompletionTriggerInThread,
|
||||
|
||||
/// A synthetic message payload that indicates that the bot should produce a reply to a specific message.
|
||||
/// This does not represent an actual message event, it's just a way to trigger a chat completion.
|
||||
///
|
||||
/// When this is invoked, the ThreadInfo would refer to the reply-message that triggered us.
|
||||
/// We can follow the chain upward from it to get the full context.
|
||||
///
|
||||
/// See: https://github.com/etkecc/baibot/issues/15
|
||||
SynthethicChatCompletionTriggerForReply,
|
||||
|
||||
Text(TextMessageEventContent),
|
||||
Audio(AudioMessageEventContent),
|
||||
|
||||
Reaction {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
pub mod catch_up_marker;
|
||||
pub mod cfg;
|
||||
pub mod globalconfig;
|
||||
mod interaction_context;
|
||||
mod message_context;
|
||||
mod message_payload;
|
||||
mod room_config_context;
|
||||
pub mod roomconfig;
|
||||
mod thread_context;
|
||||
mod trigger_event_info;
|
||||
|
||||
pub use interaction_context::{InteractionContext, InteractionTrigger};
|
||||
pub use message_context::MessageContext;
|
||||
pub use message_payload::MessagePayload;
|
||||
pub use room_config_context::RoomConfigContext;
|
||||
pub use thread_context::{ThreadContext, ThreadContextFirstMessage};
|
||||
pub use trigger_event_info::TriggerEventInfo;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
use mxlink::ThreadInfo;
|
||||
|
||||
use super::MessagePayload;
|
||||
|
||||
pub struct ThreadContext {
|
||||
pub info: ThreadInfo,
|
||||
pub first_message: ThreadContextFirstMessage,
|
||||
}
|
||||
|
||||
pub struct ThreadContextFirstMessage {
|
||||
pub is_mentioning_bot: bool,
|
||||
pub payload: MessagePayload,
|
||||
}
|
||||
Reference in New Issue
Block a user