Skip to main content

OAIPromptFormatter

Trait OAIPromptFormatter 

Source
pub trait OAIPromptFormatter:
    Send
    + Sync
    + 'static {
    // Required methods
    fn supports_add_generation_prompt(&self) -> bool;
    fn render(&self, req: &dyn OAIChatLikeRequest) -> Result<String>;

    // Provided methods
    fn supports_native_tools(&self, _request: &dyn OAIChatLikeRequest) -> bool { ... }
    fn media_message_order(
        &self,
        _request: &dyn OAIChatLikeRequest,
    ) -> Option<Vec<usize>> { ... }
    fn render_prompt(
        &self,
        req: &dyn OAIChatLikeRequest,
    ) -> Result<RenderedPrompt> { ... }
    fn renders_continuation_natively(&self) -> bool { ... }
}

Required Methods§

Provided Methods§

Source

fn supports_native_tools(&self, _request: &dyn OAIChatLikeRequest) -> bool

Older/native formatters keep flattened tools unless they opt into this shape.

Source

fn media_message_order( &self, _request: &dyn OAIChatLikeRequest, ) -> Option<Vec<usize>>

Source message indices in rendered media order; None preserves arrival order. An explicit order must be a permutation of all source-message indices. Parts within each message retain their original order.

Source

fn render_prompt(&self, req: &dyn OAIChatLikeRequest) -> Result<RenderedPrompt>

Source

fn renders_continuation_natively(&self) -> bool

Whether this formatter leaves a final assistant turn open by itself when OAIChatLikeRequest::should_add_generation_prompt is false. Callers must then skip their marker-and-truncate emulation of continue_final_message.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§