use std::collections::HashMap;
use lc_chains::BaseChain;
use lc_chains::LLMChain;
use lc_testkit::ReplayProvider;
#[tokio::test]
async fn chain_replay_answers_offline() {
let llm = ReplayProvider::from_file("fixtures/llm_chain_f01.jsonl")
.expect("fixture 存在: fixtures/llm_chain_f01.jsonl");
let chain = LLMChain::new(llm, "用一句话回答:{question}");
let mut inputs = HashMap::new();
inputs.insert(
"question".to_string(),
serde_json::Value::String("什么是 Rust?".to_string()),
);
let result = chain.invoke(inputs).await.expect("回放链调用失败");
let answer = result
.values()
.next()
.and_then(|v| v.as_str())
.unwrap_or_default()
.to_string();
assert!(!answer.trim().is_empty(), "回放回答不能为空");
println!("[chain_replay] 回放回答: {:?}", answer);
}