Skip to content

v2.43.0

Choose a tag to compare

@j-mendez j-mendez released this 01 Feb 21:40
· 773 commits to main since this release

What's New

Token Usage Tracking for RemoteMultimodalEngine

The remote multimodal automation engine now tracks and returns token usage conforming to the OpenAI API format:

  • AutomationUsage struct with prompt_tokens, completion_tokens, total_tokens
  • Usage is accumulated across all inference rounds
  • Stored on Page.remote_multimodal_usage

Extraction Support

New extraction capabilities for RemoteMultimodalEngine, similar to the OpenAI integration:

  • extra_ai_data - Enable extraction mode
  • extraction_prompt - Custom extraction instructions
  • screenshot - Capture final screenshot

Extracted data is automatically stored on Page.extra_remote_multimodal_data as AutomationResults.

Example Usage

use spider::features::automation::RemoteMultimodalConfigs;

let mm = RemoteMultimodalConfigs::new(
    "http://localhost:11434/v1/chat/completions",
    "qwen2.5-vl",
)
.with_extra_ai_data(true)
.with_extraction_prompt(Some("Extract all product names and prices"))
.with_screenshot(true);

website.configuration.remote_multimodal = Some(Box::new(mm));

// After crawling, access on page:
for page in website.get_pages().await {
    if let Some(usage) = &page.remote_multimodal_usage {
        println!("Tokens: {:?}", usage);
    }
    if let Some(data) = &page.extra_remote_multimodal_data {
        for result in data {
            println!("Extracted: {:?}", result.content_output);
        }
    }
}

Full Changelog: v2.42.0...v2.43.0