Skip to content

Commit

Permalink
Merge pull request #249 from kyle-mccarthy/feat/object-safe-executor
Browse files Browse the repository at this point in the history
feat: make Executor trait object safe
  • Loading branch information
williamhogman authored Jan 10, 2024
2 parents b7b769c + 305daa1 commit 6c274b1
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 6c274b1

Please sign in to comment.