#![allow(dead_code)]
use causa_kernel::{
BlockId, Context, ModelItem, ModelOutput, ModelResponse, ModelStopReason, TextPayload,
ToolCallDraft, TurnId,
};
use std::sync::atomic::{AtomicU64, Ordering};
static NEXT_BLOCK_ID: AtomicU64 = AtomicU64::new(1);
pub fn block_id() -> BlockId {
BlockId::new(uuid::Uuid::from_u128(
NEXT_BLOCK_ID.fetch_add(1, Ordering::Relaxed) as u128,
))
}
pub fn block_ids_for(response: &ModelResponse) -> Vec<BlockId> {
let count = response.block_count();
(0..count).map(|_| block_id()).collect()
}
pub fn turn_id(s: &str) -> TurnId {
TurnId::new(s)
}
pub fn ctx(_s: &str) -> Context {
Context::new()
}
pub fn endturn_output(text: &str) -> ModelOutput {
ModelOutput::new(
ModelResponse {
items: vec![ModelItem::text(text)],
},
ModelStopReason::EndTurn,
)
}
pub fn draft(tool_name: &str, args: serde_json::Value) -> ToolCallDraft {
ToolCallDraft::new(tool_name, args)
}
pub fn text_block(id: BlockId, text: TextPayload, source: &str) -> causa_kernel::ContextBlock {
parts_block(id, vec![causa_kernel::ContentPart::Text(text)], source)
}
pub fn parts_block(
id: BlockId,
parts: Vec<causa_kernel::ContentPart>,
source: &str,
) -> causa_kernel::ContextBlock {
causa_kernel::ContextBlock::new(
id,
causa_kernel::BlockContent::Parts(parts),
causa_kernel::BlockMeta::from_source(source.to_owned()),
)
}