Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/utopia-extract/src/align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub fn parse_kind_word_response(
/// 先按常规取块(第一个 `{` 到最后一个 `}`);解不开才从第一个 `{` 取到结尾去修补。
/// 取块与修补的分工同 `open.rs`:紧凑回复里 `}` 只在结尾出现,截断的回复要么没有 `}`,
/// 要么最后一个 `}` 不是结尾
fn parse_value(raw: &str) -> anyhow::Result<Value> {
pub(crate) fn parse_value(raw: &str) -> anyhow::Result<Value> {
let block = json_block(raw)
.and_then(|b| serde_json::from_str::<Value>(&b).map_err(anyhow::Error::from));
match block {
Expand Down Expand Up @@ -212,7 +212,7 @@ fn parse_pair(v: &Value, by_id: &HashMap<i64, &KindWordItem<'_>>) -> Option<Kind
}

/// id 是 JSON 整数;模型偶尔把它写成字符串,照数字读
fn item_id(v: &Value) -> Option<i64> {
pub(crate) fn item_id(v: &Value) -> Option<i64> {
match v {
Value::Number(n) => n.as_i64(),
Value::String(s) => s.trim().parse().ok(),
Expand Down
1 change: 1 addition & 0 deletions crates/utopia-extract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use utopia_llm::ChatMessage;
pub mod align;
pub mod governor;
pub mod open;
pub mod phrase_align;
pub mod time;

/// Response-scoped reference to a persistent entity; database UUIDs must never enter prompts.
Expand Down
394 changes: 394 additions & 0 deletions crates/utopia-extract/src/phrase_align.rs

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions crates/utopia-server/src/api/ontology_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ pub async fn create_relation_type(
if let Some(q) = req.qualifiers.as_deref() {
utopia_store::ontology::set_relation_qualifiers(&state.pool, kb_id, id, q).await?;
}
// 多了一个属性:判成 none / undecided 的签名也许对得上了(0044 对齐第二片)
utopia_store::jobs::enqueue_unless_queued(
&state.pool,
"align_phrases",
serde_json::json!({ "kb_id": kb_id }),
)
.await?;
let _ = utopia_store::audit::record(
&state.pool,
Some(kb_id),
Expand Down Expand Up @@ -361,6 +368,13 @@ pub async fn update_relation_type(
if let Some(q) = req.qualifiers.as_deref() {
utopia_store::ontology::set_relation_qualifiers(&state.pool, kb_id, id, q).await?;
}
// 属性改了定义或域/值域:绑到它的签名过期,判成 none 的也许对得上了
utopia_store::jobs::enqueue_unless_queued(
&state.pool,
"align_phrases",
serde_json::json!({ "kb_id": kb_id }),
)
.await?;
let _ = utopia_store::audit::record(
&state.pool,
Some(kb_id),
Expand Down
11 changes: 11 additions & 0 deletions crates/utopia-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mod ontology_index;
mod ontology_packs;
mod owl_import;
mod pack_alignment;
mod phrase_alignment;
mod pipeline;
mod predicate_match;
mod query_engine;
Expand Down Expand Up @@ -506,6 +507,16 @@ async fn dispatch(st: &state::AppState, job: &utopia_store::jobs::Job) -> anyhow
.ok_or_else(|| anyhow::anyhow!("payload 缺少 kb_id"))?;
type_alignment::align_types(st, kb_id).await
}
// 关系短语按签名绑到属性(0044 对齐的第二片):类别词绑完排一个,属性改了再排
"align_phrases" => {
let kb_id: Uuid = job
.payload
.get("kb_id")
.and_then(|v| v.as_str())
.and_then(|s| s.parse().ok())
.ok_or_else(|| anyhow::anyhow!("payload 缺少 kb_id"))?;
phrase_alignment::align_phrases(st, kb_id).await
}
"resolve_time" => {
let id = payload_document_id(&job.payload)?;
time_resolution::resolve_document(st, id).await
Expand Down
Loading
Loading