mirror of
https://github.com/katanemo/plano.git
synced 2026-05-21 13:55:15 +02:00
fix mcp_filter demo: add missing List import, fix README typo
Made-with: Cursor
This commit is contained in:
parent
014c4578a5
commit
15c6ce7d64
19 changed files with 974 additions and 2325 deletions
|
|
@ -520,6 +520,9 @@ async fn llm_chat_inner(
|
|||
propagator.inject_context(&cx, &mut HeaderInjector(&mut request_headers));
|
||||
});
|
||||
|
||||
// Output filters run for any API shape that reaches this handler (e.g. /v1/chat/completions,
|
||||
// /v1/messages, /v1/responses). Brightstaff does inbound translation and llm_gateway does
|
||||
// outbound translation; filters receive raw response bytes and request path.
|
||||
let output_filters_configured = output_filters
|
||||
.as_ref()
|
||||
.as_ref()
|
||||
|
|
@ -527,19 +530,6 @@ async fn llm_chat_inner(
|
|||
.unwrap_or(false);
|
||||
let has_output_filter = output_filters_configured;
|
||||
|
||||
// Extract the upstream API path (e.g. "/v1/messages" from "https://api.anthropic.com/v1/messages").
|
||||
// Output filters are called at <agent.url><upstream_api_path> so they know the exact byte format.
|
||||
let upstream_api_path = {
|
||||
let after_scheme = full_qualified_llm_provider_url
|
||||
.find("://")
|
||||
.map(|i| &full_qualified_llm_provider_url[i + 3..])
|
||||
.unwrap_or(&full_qualified_llm_provider_url);
|
||||
after_scheme
|
||||
.find('/')
|
||||
.map(|i| after_scheme[i..].to_string())
|
||||
.unwrap_or_else(|| "/".to_string())
|
||||
};
|
||||
|
||||
// Save request headers for output filters (before they're consumed by upstream request)
|
||||
let output_filter_request_headers = if has_output_filter {
|
||||
Some(request_headers.clone())
|
||||
|
|
@ -623,7 +613,7 @@ async fn llm_chat_inner(
|
|||
ofc,
|
||||
ofa,
|
||||
output_filter_request_headers.unwrap(),
|
||||
upstream_api_path.clone(),
|
||||
request_path.clone(),
|
||||
)
|
||||
} else {
|
||||
create_streaming_response(byte_stream, state_processor, 16)
|
||||
|
|
@ -638,7 +628,7 @@ async fn llm_chat_inner(
|
|||
ofc,
|
||||
ofa,
|
||||
output_filter_request_headers.unwrap(),
|
||||
upstream_api_path,
|
||||
request_path.clone(),
|
||||
)
|
||||
} else {
|
||||
// Use base processor without state management
|
||||
|
|
|
|||
|
|
@ -282,8 +282,8 @@ where
|
|||
}
|
||||
|
||||
/// Creates a streaming response that processes each raw chunk through output filters.
|
||||
/// Filters receive the raw LLM response bytes and return (possibly modified) bytes.
|
||||
/// On filter error mid-stream the original chunk is passed through (headers already sent).
|
||||
/// Filters receive the raw LLM response bytes and request path (any API shape; not limited to
|
||||
/// chat completions). On filter error mid-stream the original chunk is passed through (headers already sent).
|
||||
pub fn create_streaming_response_with_output_filter<S, P>(
|
||||
mut byte_stream: S,
|
||||
mut inner_processor: P,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue