23 lines
738 B
Rust
23 lines
738 B
Rust
use rtx_llm_tools::templates::{PromptTemplate, TemplateContext};
|
|
use serde_json::Value;
|
|
|
|
#[tokio::test]
|
|
async fn test_basic_template() {
|
|
let template = PromptTemplate::from_str("Hello {name}!").unwrap();
|
|
let mut context = TemplateContext::new();
|
|
context.insert("name", Value::String("World".to_string()));
|
|
|
|
let result = template.render(&context).await;
|
|
assert!(result.is_ok());
|
|
assert_eq!(result.unwrap(), "Hello World!");
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_template_without_variables() {
|
|
let template = PromptTemplate::from_str("Hello static world!").unwrap();
|
|
let context = TemplateContext::new();
|
|
|
|
let result = template.render(&context).await.unwrap();
|
|
assert_eq!(result, "Hello static world!");
|
|
}
|