This is a huge patch which does some major refactoring like: - renaming "Image Generation" to "Image Creation" in most places, to better match its new command (`!bai image create`) - relocating image creation command (`!bai image` -> `!bai image create`), so it wouldn't conflict with the new image editing command (`!bai image edit`) - introducing a new image editing command (`!bai image edit`), which is meant to work only with the OpenAI provider, but doesn't fully work yet due to https://github.com/64bit/async-openai/issues/364, though a next patch will fix it - adding support for reading images off of Matrix conversations and forwarding them to text conversations. Works for OpenAI, but not for Anthropic yet (requires custom patches) and not for OpenAI-Compat (no support for images there) - relocating some utils around (base64, mime)
30 lines
774 B
Rust
30 lines
774 B
Rust
use mxlink::MessageResponseType;
|
|
|
|
use crate::{
|
|
Bot,
|
|
entity::{MessageContext, MessagePayload},
|
|
};
|
|
|
|
pub mod agent;
|
|
pub mod text_to_speech;
|
|
|
|
pub async fn get_text_body_or_complain<'a>(
|
|
bot: &Bot,
|
|
message_context: &'a MessageContext,
|
|
) -> Option<&'a str> {
|
|
match &message_context.payload() {
|
|
MessagePayload::Text(text_message_content) => Some(&text_message_content.body),
|
|
_ => {
|
|
bot.messaging()
|
|
.send_text_markdown_no_fail(
|
|
message_context.room(),
|
|
"This command only works with text messages.".to_owned(),
|
|
MessageResponseType::InThread(message_context.thread_info().clone()),
|
|
)
|
|
.await;
|
|
|
|
None
|
|
}
|
|
}
|
|
}
|