asimov_patterns/programs/
prompter.rs

1// This is free and unencumbered software released into the public domain.
2
3use crate::Execute;
4use alloc::{string::String, vec::Vec};
5use bon::Builder;
6
7/// LLM inference provider. Consumes prompt input, produces response output.
8///
9/// See: https://asimov-specs.github.io/program-patterns/#prompter
10pub trait Prompter<T, E>: Execute<T, E> {}
11
12/// Configuration options for [`Prompter`].
13///
14/// # Examples
15///
16/// ```rust
17/// use asimov_patterns::PrompterOptions;
18///
19/// let options = PrompterOptions::builder()
20///     .input("text")
21///     .output("text")
22///     .model("gemma3:1b")
23///     .build();
24///
25/// ```
26#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Builder)]
27#[builder(derive(Debug), on(String, into))]
28pub struct PrompterOptions {
29    /// Extended nonstandard prompter options.
30    #[builder(field)]
31    pub other: Vec<String>,
32
33    /// The input format.
34    pub input: Option<String>,
35
36    /// The inference model.
37    pub model: Option<String>,
38
39    /// The output format.
40    pub output: Option<String>,
41}
42
43impl<S: prompter_options_builder::State> PrompterOptionsBuilder<S> {
44    pub fn other(mut self, flag: impl Into<String>) -> Self {
45        self.other.push(flag.into());
46        self
47    }
48
49    pub fn maybe_other(mut self, flag: Option<impl Into<String>>) -> Self {
50        if let Some(flag) = flag {
51            self.other.push(flag.into());
52        }
53        self
54    }
55}