Format as XML tag for system prompt injection
(&self)
| 284 | |
| 285 | /// Format as XML tag for system prompt injection |
| 286 | pub fn to_xml(&self) -> String { |
| 287 | let source_attr = self |
| 288 | .source |
| 289 | .as_ref() |
| 290 | .map(|s| format!(" source=\"{}\"", s)) |
| 291 | .unwrap_or_default(); |
| 292 | let type_str = match self.context_type { |
| 293 | ContextType::Memory => "Memory", |
| 294 | ContextType::Resource => "Resource", |
| 295 | ContextType::Skill => "Skill", |
| 296 | }; |
| 297 | format!( |
| 298 | "<context{} type=\"{}\">\n{}\n</context>", |
| 299 | source_attr, type_str, self.content |
| 300 | ) |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | fn metadata_score(value: Option<&serde_json::Value>) -> f32 { |
no outgoing calls