Skip to content

Commit

Permalink
Release v1.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dialogflowchatbot committed Dec 13, 2024
1 parent fe498a0 commit 70245bc
Show file tree
Hide file tree
Showing 7 changed files with 457 additions and 437 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ itoa = "1.0"
# oasysdb = "0.7.3"
# once_cell = "1.20"
# ort = { version = "=2.0.0-rc.0", default-features = false }
paste = "1.0"
redb = "2.2"
# paste = "1.0"
redb = "2.3"
regex = "1.11"
reqwest = { version = "0.12", features = ["stream"] }
rkyv = {version = "0.8", features = ["aligned", "alloc", "bytecheck"]}
Expand Down
2 changes: 1 addition & 1 deletion src/flow/rt/convertor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ fn convert_node(main_flow_id: &str, node: &mut Node) -> Result<()> {
}
Node::KnowledgeBaseAnswerNode(n) => {
let node = KnowledgeBaseAnswerNode {
recall_thresholds: n.recall_thresholds as f64 / 100f64,
recall_distance: 1f64 - n.recall_thresholds as f64 / 100f64,
no_recall_then: n.no_answer_then.clone(),
next_node_id: n.branches[0].target_node_id.clone(),
};
Expand Down
52 changes: 33 additions & 19 deletions src/flow/rt/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,32 @@ pub(crate) enum KnowledgeBaseAnswerNoRecallThen {
#[derive(Archive, Clone, Deserialize, Serialize)]
#[rkyv(compare(PartialEq))]
pub(crate) struct KnowledgeBaseAnswerNode {
pub(super) recall_thresholds: f64,
pub(super) recall_distance: f64,
pub(super) no_recall_then: KnowledgeBaseAnswerNoRecallThen,
pub(super) next_node_id: String,
}

impl KnowledgeBaseAnswerNode {
fn fallback_answer(&self, ctx: &mut Context, response: &mut Response) -> bool {
match &self.no_recall_then {
KnowledgeBaseAnswerNoRecallThen::GotoAnotherNode => {
add_next_node(ctx, &self.next_node_id);
false
}
KnowledgeBaseAnswerNoRecallThen::ReturnAlternateAnswerInstead(s) => {
response.answers.push(AnswerData {
text: s.clone(),
answer_type: AnswerType::TextPlain,
});
let r = RuntimeNnodeEnum::KnowledgeBaseAnswerNode(self.clone());
let bytes = rkyv::to_bytes::<rkyv::rancor::Error>(&r).unwrap();
ctx.node = Some(bytes.into_vec());
true
}
}
}
}

impl RuntimeNode for KnowledgeBaseAnswerNode {
fn exec(&mut self, req: &Request, ctx: &mut Context, response: &mut Response) -> bool {
// log::info!("Into LlmChaKnowledgeBaseAnswerNodetNode");
Expand All @@ -565,33 +586,26 @@ impl RuntimeNode for KnowledgeBaseAnswerNode {
))
});
match result {
Ok((answer, thresholds)) => {
if answer.is_some() && thresholds >= self.recall_thresholds {
Ok((answer, distance)) => {
log::info!(
"distance {} recall_distance {}",
distance,
self.recall_distance
);
if answer.is_some() && distance <= self.recall_distance {
response.answers.push(AnswerData {
text: answer.unwrap().answer,
answer_type: AnswerType::TextPlain,
});
true
add_next_node(ctx, &self.next_node_id);
false
} else {
match &self.no_recall_then {
KnowledgeBaseAnswerNoRecallThen::GotoAnotherNode => {
add_next_node(ctx, &self.next_node_id);
false
}
KnowledgeBaseAnswerNoRecallThen::ReturnAlternateAnswerInstead(s) => {
response.answers.push(AnswerData {
text: s.clone(),
answer_type: AnswerType::TextPlain,
});
true
}
}
self.fallback_answer(ctx, response)
}
}
Err(e) => {
log::error!("KnowledgeBaseAnswerNode answer failed: {:?}", &e);
add_next_node(ctx, &self.next_node_id);
false
self.fallback_answer(ctx, response)
}
}
}
Expand Down
420 changes: 420 additions & 0 deletions src/resources/assets/assets/index-B171WFUU.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/resources/assets/assets/index-B4PwGmOZ.css

This file was deleted.

414 changes: 0 additions & 414 deletions src/resources/assets/assets/index-DaTxxXw1.js

This file was deleted.

1 change: 1 addition & 0 deletions src/resources/assets/assets/index-DqXuk36F.css

Large diffs are not rendered by default.

0 comments on commit 70245bc

Please sign in to comment.