llm-chain 0.13.0

A library for running chains of LLMs (such as ChatGPT) in series to complete complex tasks, such as text summation.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::fs::File;
use std::io::Read;
use std::path::Path;

use super::StringTemplate;

/// Reads a prompt template from a file.
// XXX: Don't leak
pub fn read_prompt_template_file<P: AsRef<Path>>(
    path: P,
) -> Result<StringTemplate, std::io::Error> {
    let path = path.as_ref();
    let mut file = File::open(path)?;
    let mut contents = String::new();
    file.read_to_string(&mut contents)?;
    Ok(StringTemplate::tera(contents))
}