移除分离提示词的破坏性清洗
保留描述、返工意见和 NodeId 原文,删除重复截断与字符改写。 返工意见仍由 validate_binding_response 统一执行 MAX_REWORK_NOTE_CHARS 校验。
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ impl SeparationNode {
|
||||
pub fn as_prompt(&self) -> String {
|
||||
format!(
|
||||
"node_id={} note: {}",
|
||||
super::sanitize_prompt_text(self.id.as_str()),
|
||||
self.id.as_str(),
|
||||
self.note.as_prompt()
|
||||
)
|
||||
}
|
||||
|
||||
+2
-18
@@ -1,22 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
pub(crate) fn sanitize_prompt_text(value: &str) -> String {
|
||||
value
|
||||
.chars()
|
||||
.map(|character| {
|
||||
if character == '`' {
|
||||
'\''
|
||||
} else if character.is_control() {
|
||||
' '
|
||||
} else {
|
||||
character
|
||||
}
|
||||
})
|
||||
.take(super::MAX_REWORK_NOTE_CHARS)
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize, TS)]
|
||||
#[ts(export, export_to = concat!(env!("CARGO_MANIFEST_DIR"), "/../src/features/ui-editor/types/"))]
|
||||
pub struct SeparationNote {
|
||||
@@ -26,12 +10,12 @@ pub struct SeparationNote {
|
||||
|
||||
impl SeparationNote {
|
||||
pub fn as_prompt(&self) -> String {
|
||||
let mut prompt = format!("desc: {}", sanitize_prompt_text(&self.description));
|
||||
let mut prompt = format!("desc: {}", self.description);
|
||||
if !self.rework_notes.is_empty() {
|
||||
prompt.push_str("\nprevious rework notes:");
|
||||
for note in &self.rework_notes {
|
||||
prompt.push_str("\n- ");
|
||||
prompt.push_str(&sanitize_prompt_text(note));
|
||||
prompt.push_str(note);
|
||||
}
|
||||
}
|
||||
prompt
|
||||
|
||||
+3
-10
@@ -1,6 +1,4 @@
|
||||
use crate::ui_editor::commands::separation::model::{
|
||||
sanitize_prompt_text, SeparationState, SeparationTree,
|
||||
};
|
||||
use crate::ui_editor::commands::separation::model::{SeparationState, SeparationTree};
|
||||
use crate::ui_editor::commands::separation::workflow::batch::terminal_node_ids;
|
||||
use crate::ui_editor::commands::separation::{SeparationNode, SeparationNodeKind};
|
||||
use crate::ui_editor::utils::NodeId;
|
||||
@@ -115,13 +113,8 @@ fn project_node(
|
||||
width: node.width_px,
|
||||
height: node.height_px,
|
||||
},
|
||||
description: sanitize_prompt_text(&node.note.description),
|
||||
rework_notes: node
|
||||
.note
|
||||
.rework_notes
|
||||
.iter()
|
||||
.map(|note| sanitize_prompt_text(note))
|
||||
.collect(),
|
||||
description: node.note.description.clone(),
|
||||
rework_notes: node.note.rework_notes.iter().cloned().collect(),
|
||||
children,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user