Expand description
Prompts templating and management
Prompts are first class citizens in Swiftide and use tera under the hood. tera uses jinja style templates which allows for a lot of flexibility.
Conceptually, a Prompt is something you send to i.e.
SimplePrompt
. A prompt can have
added context for substitution and other templating features.
Transformers in Swiftide come with default prompts, and they can be customized or replaced as needed.
Template
can be added with Template::try_compiled_from_str
. Prompts can also be
created on the fly from anything that implements Into<String>
. Compiled prompts are stored in
an internal repository.
Additionally, Template::String
and Template::Static
can be used to create
templates on the fly as well.
It’s recommended to precompile your templates.
§Example
#[tokio::main]
let template = Template::try_compiled_from_str("hello {{world}}").await.unwrap();
let prompt = template.to_prompt().with_context_value("world", "swiftide");
assert_eq!(prompt.render().await.unwrap(), "hello swiftide");
Structs§
- Prompt
- A Prompt can be used with large language models to prompt.
Type Aliases§
- Prompt
Template Deprecated