Skip to main content

LlmGenerateAdapter

Trait LlmGenerateAdapter 

pub trait LlmGenerateAdapter: Send + Sync {
    // Required method
    fn generate(
        &self,
        system: Option<&str>,
        prompt: &str,
    ) -> Result<String, String>;

    // Provided method
    fn generate_typed(
        &self,
        system: Option<&str>,
        prompt: &str,
    ) -> Result<String, Error> { ... }
}
Expand description

Injected seam that performs the actual model call. Synchronous because SopCapability::execute is sync; implementations bridge to their async provider themselves (see ProviderLlmAdapter).

Required Methods§

Source

fn generate(&self, system: Option<&str>, prompt: &str) -> Result<String, String>

Run one bounded generation.

This is the original public adapter seam. Implementations added by downstream users can continue returning their stable string error.

Provided Methods§

Source

fn generate_typed( &self, system: Option<&str>, prompt: &str, ) -> Result<String, Error>

Run one bounded generation while retaining an internal typed failure.

The default preserves compatibility with pre-existing adapters. The provider-backed implementation overrides it so the runtime can classify terminal-completion failures before SOP serializes them for the user.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§