42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
use shared_kernel::{
|
|
build_prefixed_seed_id, normalize_optional_string as normalize_shared_optional_string,
|
|
normalize_string_list as normalize_shared_string_list,
|
|
};
|
|
|
|
use super::types::AiTaskStageKind;
|
|
|
|
pub const AI_TASK_ID_PREFIX: &str = "aitask_";
|
|
pub const AI_TASK_STAGE_ID_PREFIX: &str = "aistage_";
|
|
pub const AI_RESULT_REF_ID_PREFIX: &str = "aires_";
|
|
pub const AI_TEXT_CHUNK_ID_PREFIX: &str = "aichunk_";
|
|
pub const INITIAL_AI_TASK_VERSION: u32 = 1;
|
|
|
|
pub fn generate_ai_task_id(seed_micros: i64) -> String {
|
|
build_prefixed_seed_id(AI_TASK_ID_PREFIX, seed_micros)
|
|
}
|
|
|
|
pub fn generate_ai_task_stage_id(task_id: &str, stage_kind: AiTaskStageKind) -> String {
|
|
format!(
|
|
"{}{}_{}",
|
|
AI_TASK_STAGE_ID_PREFIX,
|
|
task_id.trim(),
|
|
stage_kind.as_str()
|
|
)
|
|
}
|
|
|
|
pub fn generate_ai_result_ref_id(seed_micros: i64) -> String {
|
|
build_prefixed_seed_id(AI_RESULT_REF_ID_PREFIX, seed_micros)
|
|
}
|
|
|
|
pub fn generate_ai_text_chunk_id(seed_micros: i64, sequence: u32) -> String {
|
|
format!("{}{seed_micros:x}_{sequence:x}", AI_TEXT_CHUNK_ID_PREFIX)
|
|
}
|
|
|
|
pub fn normalize_optional_text(value: Option<String>) -> Option<String> {
|
|
normalize_shared_optional_string(value)
|
|
}
|
|
|
|
pub fn normalize_string_list(values: Vec<String>) -> Vec<String> {
|
|
normalize_shared_string_list(values)
|
|
}
|