bamboo_engine/runtime/runner/
image_fallback.rs1use std::sync::Arc;
4
5use crate::runtime::config::ImageFallbackConfig;
6use bamboo_agent_core::storage::AttachmentReader;
7use bamboo_agent_core::{AgentError, Message};
8use bamboo_infrastructure::LLMProvider;
9
10mod attachment_urls;
11#[cfg(windows)]
12mod ocr;
13mod placeholder;
14mod rewrite;
15
16#[cfg(windows)]
17pub async fn ensure_session_image_ocr_cached(
18 session: &mut bamboo_agent_core::Session,
19 attachment_reader: Option<&dyn AttachmentReader>,
20) -> bool {
21 ocr::ensure_session_image_ocr_cached(session, attachment_reader).await
22}
23
24pub async fn resolve_bamboo_attachments_for_llm(
25 messages: &mut [Message],
26 reader: &dyn AttachmentReader,
27) -> std::result::Result<(), AgentError> {
28 attachment_urls::resolve_bamboo_attachments_for_llm(messages, reader).await
29}
30
31#[cfg(any(test, windows))]
32pub fn persistable_image_urls(parts: &[bamboo_domain::MessagePart]) -> Vec<String> {
33 placeholder::persistable_image_urls(parts)
34}
35
36pub async fn apply_image_fallback_to_llm_messages(
37 messages: &mut [Message],
38 fallback: ImageFallbackConfig,
39 attachment_reader: Option<&dyn AttachmentReader>,
40 llm: Option<&Arc<dyn LLMProvider>>,
41) -> std::result::Result<(), AgentError> {
42 rewrite::apply_image_fallback_to_llm_messages(messages, fallback, attachment_reader, llm).await
43}
44
45#[cfg(test)]
46mod tests;