mirror of
https://github.com/katanemo/plano.git
synced 2026-05-21 13:55:15 +02:00
refactor filter pipeline: introduce ResolvedFilterChain and FilterPipeline types
- Replace 4 separate filter params with single Arc<FilterPipeline> in llm_chat - Add ResolvedFilterChain (filter_ids + agents) and FilterPipeline (input + output) - Rename utils.rs to streaming.rs, extract STREAM_BUFFER_SIZE constant - Deduplicate output filter logic via Box<dyn StreamProcessor> - Rename upstream_path param to request_path for consistency Made-with: Cursor
This commit is contained in:
parent
15c6ce7d64
commit
1605d2caa6
7 changed files with 119 additions and 126 deletions
|
|
@ -30,6 +30,46 @@ pub struct AgentFilterChain {
|
|||
pub input_filters: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
/// A filter chain with its agent references resolved to concrete Agent objects.
|
||||
/// Bundles the ordered filter IDs with the agent lookup map so they stay in sync.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ResolvedFilterChain {
|
||||
pub filter_ids: Vec<String>,
|
||||
pub agents: HashMap<String, Agent>,
|
||||
}
|
||||
|
||||
impl ResolvedFilterChain {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.filter_ids.is_empty()
|
||||
}
|
||||
|
||||
pub fn to_agent_filter_chain(&self, id: &str) -> AgentFilterChain {
|
||||
AgentFilterChain {
|
||||
id: id.to_string(),
|
||||
default: None,
|
||||
description: None,
|
||||
input_filters: Some(self.filter_ids.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Holds resolved input and output filter chains for a model listener.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct FilterPipeline {
|
||||
pub input: Option<ResolvedFilterChain>,
|
||||
pub output: Option<ResolvedFilterChain>,
|
||||
}
|
||||
|
||||
impl FilterPipeline {
|
||||
pub fn has_input_filters(&self) -> bool {
|
||||
self.input.as_ref().is_some_and(|c| !c.is_empty())
|
||||
}
|
||||
|
||||
pub fn has_output_filters(&self) -> bool {
|
||||
self.output.as_ref().is_some_and(|c| !c.is_empty())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ListenerType {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue