Add a per-room/global `sender_context_mode` setting that optionally
prefixes conversation messages with sender metadata before sending them
to the model provider.
This helps models distinguish between participants in multi-user rooms.
Three modes are supported:
- `disabled` (default, no change)
- `matrix_user_id` (prefixes with `[sender=@user:server]`)
- `matrix_user_id_and_timestamp` (adds `send_at`; Example: `[sender=@user:server sent_at=<ISO 8601>]`)
Sender context is applied to user and assistant text messages only,
skipping system prompts and non-text content.
Mixed-sender merged turns (something we intentionally do for Anthropic)
have their `sender_id` cleared to avoid misattribution.
29 lines
1.4 KiB
Rust
29 lines
1.4 KiB
Rust
use super::{SpeechToTextFlowType, SpeechToTextMessageTypeForNonThreadedOnlyTranscribedMessages};
|
|
use super::{
|
|
TextGenerationAutoUsage, TextGenerationPrefixRequirementType, TextGenerationSenderContextMode,
|
|
};
|
|
use super::{TextToSpeechBotMessagesFlowType, TextToSpeechUserMessagesFlowType};
|
|
|
|
pub const TEXT_GENERATION_PREFIX_REQUIREMENT_TYPE: TextGenerationPrefixRequirementType =
|
|
TextGenerationPrefixRequirementType::No;
|
|
|
|
pub const TEXT_GENERATION_AUTO_USAGE: TextGenerationAutoUsage = TextGenerationAutoUsage::Always;
|
|
|
|
pub const TEXT_GENERATION_SENDER_CONTEXT_MODE: TextGenerationSenderContextMode =
|
|
TextGenerationSenderContextMode::Disabled;
|
|
|
|
pub const TEXT_TO_SPEECH_BOT_MESSAGES_FLOW_TYPE: TextToSpeechBotMessagesFlowType =
|
|
TextToSpeechBotMessagesFlowType::OnDemandForVoice;
|
|
|
|
pub const TEXT_TO_SPEECH_USER_MESSAGES_FLOW_TYPE: TextToSpeechUserMessagesFlowType =
|
|
TextToSpeechUserMessagesFlowType::OnDemand;
|
|
|
|
pub const SPEECH_TO_TEXT_FLOW_TYPE: SpeechToTextFlowType =
|
|
SpeechToTextFlowType::TranscribeAndGenerateText;
|
|
|
|
// While notice messages may be less desirable with other bots in the room,
|
|
// it's probably a better default for most people who enable "transcribe-only" mode.
|
|
pub const SPEECH_TO_TEXT_ONLY_TRANSCRIBE_NON_THREADED_MESSAGE_TYPE:
|
|
SpeechToTextMessageTypeForNonThreadedOnlyTranscribedMessages =
|
|
SpeechToTextMessageTypeForNonThreadedOnlyTranscribedMessages::Text;
|