Skip to content

Commit

Permalink
feat: make Executor trait object safe
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-mccarthy committed Dec 18, 2023
1 parent e6e02fb commit 305daa1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/llm-chain/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,22 @@ pub enum ExecutorError {
#[async_trait]
/// The `Executor` trait represents an executor that performs a single step in a chain. It takes a
/// step, executes it, and returns the output.
pub trait Executor: Sized {
pub trait Executor {
type StepTokenizer<'a>: Tokenizer
where
Self: 'a;

/// Create a new executor with the given options. If you don't need to set any options, you can use the `new` method instead.
/// # Parameters
/// * `options`: The options to set.
fn new_with_options(options: Options) -> Result<Self, ExecutorCreationError>;
fn new_with_options(options: Options) -> Result<Self, ExecutorCreationError>
where
Self: Sized;

fn new() -> Result<Self, ExecutorCreationError> {
fn new() -> Result<Self, ExecutorCreationError>
where
Self: Sized,
{
Self::new_with_options(Options::empty().clone())
}

Expand Down

0 comments on commit 305daa1

Please sign in to comment.