fmt
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, entity::MessageContext, strings};
|
||||
|
||||
use super::AccessControllerType;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, entity::MessageContext, strings};
|
||||
|
||||
pub async fn handle(bot: &Bot, message_context: &MessageContext) -> anyhow::Result<()> {
|
||||
let mut message = String::new();
|
||||
|
||||
@@ -4,5 +4,5 @@ pub mod help;
|
||||
mod room_local_agent_managers;
|
||||
mod users;
|
||||
|
||||
pub use determination::{determine_controller, AccessControllerType};
|
||||
pub use determination::{AccessControllerType, determine_controller};
|
||||
pub use dispatching::dispatch_controller;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, entity::MessageContext, strings};
|
||||
|
||||
pub async fn handle_get(bot: &Bot, message_context: &MessageContext) -> anyhow::Result<()> {
|
||||
let message = match &message_context
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, entity::MessageContext, strings};
|
||||
|
||||
pub async fn handle_get(bot: &Bot, message_context: &MessageContext) -> anyhow::Result<()> {
|
||||
let message = match &message_context.global_config().access.user_patterns {
|
||||
|
||||
@@ -3,15 +3,15 @@ mod tests;
|
||||
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::agent::provider::{ControllerTrait, PingResult};
|
||||
use crate::agent::PublicIdentifier;
|
||||
use crate::agent::{create_from_provider_and_yaml_value_config, AgentDefinition};
|
||||
use crate::agent::provider::{ControllerTrait, PingResult};
|
||||
use crate::agent::{AgentDefinition, create_from_provider_and_yaml_value_config};
|
||||
use crate::agent::{AgentInstance, AgentProvider};
|
||||
use crate::controller::utils::get_text_body_or_complain;
|
||||
use crate::entity::globalconfig::GlobalConfigurationManager;
|
||||
use crate::entity::roomconfig::RoomConfigurationManager;
|
||||
use crate::strings;
|
||||
use crate::{entity::MessageContext, Bot};
|
||||
use crate::{Bot, entity::MessageContext};
|
||||
|
||||
struct ParsedAgentConfig {
|
||||
agent: AgentInstance,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::entity::{
|
||||
globalconfig::GlobalConfigurationManager, roomconfig::RoomConfigurationManager, MessageContext,
|
||||
MessageContext, globalconfig::GlobalConfigurationManager, roomconfig::RoomConfigurationManager,
|
||||
};
|
||||
use crate::{agent::PublicIdentifier, strings, Bot};
|
||||
use crate::{Bot, agent::PublicIdentifier, strings};
|
||||
|
||||
pub async fn handle(
|
||||
bot: &Bot,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{agent::PublicIdentifier, entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, agent::PublicIdentifier, entity::MessageContext, strings};
|
||||
|
||||
pub async fn handle(
|
||||
bot: &Bot,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, entity::MessageContext, strings};
|
||||
|
||||
pub async fn handle(bot: &Bot, message_context: &MessageContext) -> anyhow::Result<()> {
|
||||
// Anyone can access this help command, because certain subcommands ("list")
|
||||
|
||||
@@ -2,7 +2,7 @@ use mxlink::MessageResponseType;
|
||||
|
||||
use crate::agent::AgentPurpose;
|
||||
use crate::strings;
|
||||
use crate::{entity::MessageContext, Bot};
|
||||
use crate::{Bot, entity::MessageContext};
|
||||
|
||||
pub async fn handle(bot: &Bot, message_context: &MessageContext) -> anyhow::Result<()> {
|
||||
let agents = bot
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{entity::MessageContext, Bot};
|
||||
use crate::{Bot, entity::MessageContext};
|
||||
|
||||
pub mod create;
|
||||
pub mod delete;
|
||||
@@ -7,7 +7,7 @@ pub mod determination;
|
||||
pub mod help;
|
||||
pub mod list;
|
||||
|
||||
pub use determination::{determine_controller, AgentControllerType};
|
||||
pub use determination::{AgentControllerType, determine_controller};
|
||||
|
||||
pub async fn dispatch_controller(
|
||||
handler: &AgentControllerType,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, entity::MessageContext, strings};
|
||||
|
||||
pub async fn handle_get<T>(
|
||||
bot: &Bot,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::strings;
|
||||
use crate::{entity::MessageContext, Bot};
|
||||
use crate::{Bot, entity::MessageContext};
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use super::controller_type::{
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::entity::roomconfig::{
|
||||
RoomSettings, SpeechToTextFlowType,
|
||||
SpeechToTextMessageTypeForNonThreadedOnlyTranscribedMessages,
|
||||
};
|
||||
use crate::{entity::MessageContext, Bot};
|
||||
use crate::{Bot, entity::MessageContext};
|
||||
|
||||
use super::super::controller_type::{
|
||||
ConfigSpeechToTextSettingRelatedControllerType, SettingsStorageSource,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::entity::roomconfig::{
|
||||
RoomSettings, TextGenerationAutoUsage, TextGenerationPrefixRequirementType,
|
||||
};
|
||||
use crate::{entity::MessageContext, Bot};
|
||||
use crate::{Bot, entity::MessageContext};
|
||||
|
||||
use super::super::controller_type::{
|
||||
ConfigTextGenerationSettingRelatedControllerType, SettingsStorageSource,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::entity::roomconfig::{
|
||||
RoomSettings, TextToSpeechBotMessagesFlowType, TextToSpeechUserMessagesFlowType,
|
||||
};
|
||||
use crate::{entity::MessageContext, Bot};
|
||||
use crate::{Bot, entity::MessageContext};
|
||||
|
||||
use super::super::controller_type::{
|
||||
ConfigTextToSpeechSettingRelatedControllerType, SettingsStorageSource,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::entity::{roomconfig::RoomSettings, MessageContext};
|
||||
use crate::{strings, Bot};
|
||||
use crate::entity::{MessageContext, roomconfig::RoomSettings};
|
||||
use crate::{Bot, strings};
|
||||
|
||||
pub async fn handle_set<T>(
|
||||
bot: &Bot,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{
|
||||
Bot,
|
||||
agent::{AgentPurpose, PublicIdentifier},
|
||||
entity::{globalconfig::GlobalConfigurationManager, MessageContext},
|
||||
strings, Bot,
|
||||
entity::{MessageContext, globalconfig::GlobalConfigurationManager},
|
||||
strings,
|
||||
};
|
||||
|
||||
pub async fn handle_get(
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{
|
||||
Bot,
|
||||
entity::{
|
||||
MessageContext,
|
||||
roomconfig::{
|
||||
SpeechToTextFlowType, SpeechToTextMessageTypeForNonThreadedOnlyTranscribedMessages,
|
||||
TextGenerationAutoUsage, TextGenerationPrefixRequirementType,
|
||||
TextToSpeechBotMessagesFlowType, TextToSpeechUserMessagesFlowType,
|
||||
},
|
||||
MessageContext,
|
||||
},
|
||||
strings, Bot,
|
||||
strings,
|
||||
};
|
||||
|
||||
pub async fn handle(bot: &Bot, message_context: &MessageContext) -> anyhow::Result<()> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::entity::{roomconfig::RoomSettings, MessageContext};
|
||||
use crate::{strings, Bot};
|
||||
use crate::entity::{MessageContext, roomconfig::RoomSettings};
|
||||
use crate::{Bot, strings};
|
||||
|
||||
pub async fn handle_set<T>(
|
||||
bot: &Bot,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{
|
||||
Bot,
|
||||
agent::{AgentPurpose, PublicIdentifier},
|
||||
entity::MessageContext,
|
||||
strings, Bot,
|
||||
strings,
|
||||
};
|
||||
|
||||
use crate::entity::roomconfig::RoomConfigurationManager;
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{
|
||||
Bot,
|
||||
agent::{
|
||||
utils::get_effective_agent_for_purpose, AgentInstance, AgentPurpose, ControllerTrait,
|
||||
Manager as AgentManager, PublicIdentifier,
|
||||
AgentInstance, AgentPurpose, ControllerTrait, Manager as AgentManager, PublicIdentifier,
|
||||
utils::get_effective_agent_for_purpose,
|
||||
},
|
||||
entity::{
|
||||
roomconfig::{RoomConfig, RoomSettingsHandler},
|
||||
MessageContext, RoomConfigContext,
|
||||
roomconfig::{RoomConfig, RoomSettingsHandler},
|
||||
},
|
||||
strings, Bot,
|
||||
strings,
|
||||
};
|
||||
|
||||
pub async fn handle(bot: &Bot, message_context: &MessageContext) -> anyhow::Result<()> {
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
use mxlink::matrix_sdk::ruma::events::room::message::AudioMessageEventContent;
|
||||
use mxlink::matrix_sdk::ruma::OwnedEventId;
|
||||
use mxlink::matrix_sdk::ruma::events::room::message::AudioMessageEventContent;
|
||||
use mxlink::{MatrixLink, MessageResponseType};
|
||||
|
||||
use tracing::Instrument;
|
||||
|
||||
use crate::agent::provider::{
|
||||
SpeechToTextParams, TextGenerationParams, TextGenerationPromptVariables,
|
||||
};
|
||||
use crate::agent::AgentInstance;
|
||||
use crate::agent::AgentPurpose;
|
||||
use crate::agent::ControllerTrait;
|
||||
use crate::agent::provider::{
|
||||
SpeechToTextParams, TextGenerationParams, TextGenerationPromptVariables,
|
||||
};
|
||||
use crate::controller::utils::agent::get_effective_agent_for_purpose_or_complain;
|
||||
use crate::conversation::matrix::MatrixMessageProcessingParams;
|
||||
use crate::entity::MessagePayload;
|
||||
use crate::entity::roomconfig::{
|
||||
SpeechToTextFlowType, SpeechToTextMessageTypeForNonThreadedOnlyTranscribedMessages,
|
||||
TextToSpeechBotMessagesFlowType, TextToSpeechUserMessagesFlowType,
|
||||
};
|
||||
use crate::entity::MessagePayload;
|
||||
use crate::strings;
|
||||
use crate::utils::text_to_speech::create_transcribed_message_text;
|
||||
use crate::{
|
||||
Bot,
|
||||
conversation::{
|
||||
create_llm_conversation_for_matrix_reply_chain, create_llm_conversation_for_matrix_thread,
|
||||
matrix::create_list_of_bot_user_prefixes_to_strip,
|
||||
},
|
||||
entity::MessageContext,
|
||||
Bot,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
||||
@@ -4,8 +4,8 @@ mod tests;
|
||||
use super::chat_completion::ChatCompletionControllerType;
|
||||
use crate::{
|
||||
entity::{
|
||||
roomconfig::TextGenerationPrefixRequirementType, InteractionTrigger, MessageContext,
|
||||
MessagePayload,
|
||||
InteractionTrigger, MessageContext, MessagePayload,
|
||||
roomconfig::TextGenerationPrefixRequirementType,
|
||||
},
|
||||
strings,
|
||||
};
|
||||
|
||||
@@ -142,8 +142,7 @@ fn determine_text_controller() {
|
||||
// This test case is the same as the one above, just with a different prefix requirement setting.
|
||||
// We expect the same result.
|
||||
TestCase {
|
||||
name:
|
||||
"Regular message with bot mention triggers completion (command prefix requirement)",
|
||||
name: "Regular message with bot mention triggers completion (command prefix requirement)",
|
||||
input: "Regular text goes here",
|
||||
is_mentioning_bot: true,
|
||||
room_text_generation_prefix_requirement_type:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, entity::MessageContext, strings};
|
||||
|
||||
use super::ControllerType;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, entity::MessageContext, strings};
|
||||
|
||||
pub async fn handle(bot: &Bot, message_context: &MessageContext) -> anyhow::Result<()> {
|
||||
let sender_can_manage_global_config = message_context.sender_can_manage_global_config();
|
||||
|
||||
@@ -2,15 +2,15 @@ use mxlink::{MatrixLink, MessageResponseType};
|
||||
|
||||
use tracing::Instrument;
|
||||
|
||||
use crate::agent::provider::ImageGenerationParams;
|
||||
use crate::agent::AgentPurpose;
|
||||
use crate::agent::ControllerTrait;
|
||||
use crate::agent::provider::ImageGenerationParams;
|
||||
use crate::controller::utils::agent::get_effective_agent_for_purpose_or_complain;
|
||||
use crate::controller::utils::mime::get_file_extension;
|
||||
use crate::conversation::create_llm_conversation_for_matrix_thread;
|
||||
use crate::conversation::matrix::MatrixMessageProcessingParams;
|
||||
use crate::strings;
|
||||
use crate::{entity::MessageContext, Bot};
|
||||
use crate::{Bot, entity::MessageContext};
|
||||
|
||||
// We may make this configurable (per room, etc.) in the future, but for now it's hardcoded.
|
||||
const STICKER_SIZE: &str = "256x256";
|
||||
|
||||
@@ -68,46 +68,50 @@ mod tests {
|
||||
// Multiple complex user messages dispersed with assistant messages
|
||||
TestCase {
|
||||
original_prompt: "Generate a picture of an elephant",
|
||||
messages: vec![Message {
|
||||
author: Author::User,
|
||||
message_text: "Must be blue".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
Message {
|
||||
author: Author::Assistant,
|
||||
message_text: "Whatever".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
Message {
|
||||
author: Author::User,
|
||||
message_text: "Must be 3-legged.\nMust be flying.".to_owned(),
|
||||
timestamp,
|
||||
}],
|
||||
messages: vec![
|
||||
Message {
|
||||
author: Author::User,
|
||||
message_text: "Must be blue".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
Message {
|
||||
author: Author::Assistant,
|
||||
message_text: "Whatever".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
Message {
|
||||
author: Author::User,
|
||||
message_text: "Must be 3-legged.\nMust be flying.".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
],
|
||||
expected_prompt: "Generate a picture of an elephant\nOther criteria:\n- Must be blue\n- Must be 3-legged.. Must be flying.",
|
||||
},
|
||||
// "Again" is ignored.
|
||||
TestCase {
|
||||
original_prompt: "Generate a picture of a grizzly bear",
|
||||
messages: vec![Message {
|
||||
author: Author::User,
|
||||
message_text: "Must be blue".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
Message {
|
||||
author: Author::Assistant,
|
||||
message_text: "Whatever".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
Message {
|
||||
author: Author::User,
|
||||
message_text: "Again".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
Message {
|
||||
author: Author::User,
|
||||
message_text: "again".to_owned(),
|
||||
timestamp,
|
||||
}],
|
||||
messages: vec![
|
||||
Message {
|
||||
author: Author::User,
|
||||
message_text: "Must be blue".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
Message {
|
||||
author: Author::Assistant,
|
||||
message_text: "Whatever".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
Message {
|
||||
author: Author::User,
|
||||
message_text: "Again".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
Message {
|
||||
author: Author::User,
|
||||
message_text: "again".to_owned(),
|
||||
timestamp,
|
||||
},
|
||||
],
|
||||
expected_prompt: "Generate a picture of a grizzly bear\nOther criteria:\n- Must be blue",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::entity::RoomConfigContext;
|
||||
use crate::{strings, Bot};
|
||||
use crate::{Bot, strings};
|
||||
|
||||
pub async fn handle(
|
||||
bot: &Bot,
|
||||
@@ -9,7 +9,9 @@ pub async fn handle(
|
||||
room_config_context: &RoomConfigContext,
|
||||
) -> anyhow::Result<()> {
|
||||
if !bot.post_join_self_introduction_enabled() {
|
||||
tracing::debug!("Post-join self-introduction is disabled - not sending introduction message");
|
||||
tracing::debug!(
|
||||
"Post-join self-introduction is disabled - not sending introduction message"
|
||||
);
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{agent::AgentProvider, entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, agent::AgentProvider, entity::MessageContext, strings};
|
||||
|
||||
use super::ControllerType;
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ use std::ops::Deref;
|
||||
use mxlink::MatrixLink;
|
||||
|
||||
use crate::{
|
||||
Bot,
|
||||
agent::AgentPurpose,
|
||||
entity::{MessageContext, MessagePayload},
|
||||
Bot,
|
||||
};
|
||||
|
||||
mod text_to_speech;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use mxlink::{MatrixLink, MessageResponseType};
|
||||
|
||||
use mxlink::matrix_sdk::ruma::{
|
||||
events::room::message::TextMessageEventContent, OwnedEventId, OwnedUserId,
|
||||
OwnedEventId, OwnedUserId, events::room::message::TextMessageEventContent,
|
||||
};
|
||||
|
||||
use crate::entity::roomconfig::{
|
||||
@@ -9,8 +9,8 @@ use crate::entity::roomconfig::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
agent::AgentPurpose, controller::utils::agent::get_effective_agent_for_purpose_or_complain,
|
||||
entity::MessageContext, Bot,
|
||||
Bot, agent::AgentPurpose,
|
||||
controller::utils::agent::get_effective_agent_for_purpose_or_complain, entity::MessageContext,
|
||||
};
|
||||
|
||||
pub(super) async fn handle(
|
||||
@@ -34,7 +34,9 @@ pub(super) async fn handle(
|
||||
reacted_to_event_sender_id,
|
||||
matrix_link.user_id(),
|
||||
) {
|
||||
tracing::debug!("Ignoring request for on-demand text-to-speech (via reaction) due to room configuration");
|
||||
tracing::debug!(
|
||||
"Ignoring request for on-demand text-to-speech (via reaction) due to room configuration"
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{entity::MessageContext, strings, Bot};
|
||||
use crate::{Bot, entity::MessageContext, strings};
|
||||
|
||||
use super::ControllerType;
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{
|
||||
Bot,
|
||||
agent::{
|
||||
utils::{get_effective_agent_for_purpose, AgentForPurposeDeterminationError},
|
||||
AgentInstance, AgentPurpose,
|
||||
utils::{AgentForPurposeDeterminationError, get_effective_agent_for_purpose},
|
||||
},
|
||||
entity::MessageContext,
|
||||
strings, Bot,
|
||||
strings,
|
||||
};
|
||||
|
||||
pub async fn get_effective_agent_for_purpose_or_complain<'a>(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use mxlink::MessageResponseType;
|
||||
|
||||
use crate::{
|
||||
entity::{MessageContext, MessagePayload},
|
||||
Bot,
|
||||
entity::{MessageContext, MessagePayload},
|
||||
};
|
||||
|
||||
pub mod agent;
|
||||
|
||||
@@ -5,9 +5,10 @@ use tracing::Instrument;
|
||||
|
||||
use crate::controller::utils::mime::get_file_extension;
|
||||
use crate::{
|
||||
agent::{provider::TextToSpeechParams, AgentInstance, AgentPurpose, ControllerTrait},
|
||||
Bot,
|
||||
agent::{AgentInstance, AgentPurpose, ControllerTrait, provider::TextToSpeechParams},
|
||||
entity::MessageContext,
|
||||
strings, Bot,
|
||||
strings,
|
||||
};
|
||||
|
||||
pub async fn generate_and_send_tts_for_message(
|
||||
|
||||
Reference in New Issue
Block a user