Skip to content

Commit 1c73a17

Browse files
committed
feat: proxy demo
Signed-off-by: Greg Clark <grclark@nvidia.com>
1 parent 0eb3d16 commit 1c73a17

9 files changed

Lines changed: 327 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ members = [
1212
"crates/switchyard-py",
1313
"crates/switchyard-server",
1414
"crates/switchyard-translation",
15+
"demo/libsy-proxy",
1516
]
1617

1718
[workspace.package]

crates/libsy/examples/research_agent.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ impl LlmClient for StubClient {
4242
format!("answer from {model}")
4343
};
4444
Ok(OrchestratorResponse {
45-
llm_response: LlmResponse { completion },
45+
llm_response: LlmResponse {
46+
completion,
47+
raw_response: None,
48+
},
4649
metadata: None,
4750
})
4851
}

crates/libsy/examples/research_agent_core.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ async fn call_model(request: &OrchestratorRequest) -> OrchestratorResponse {
3434
format!("answer from {model}")
3535
};
3636
OrchestratorResponse {
37-
llm_response: LlmResponse { completion },
37+
llm_response: LlmResponse {
38+
completion,
39+
raw_response: None,
40+
},
3841
metadata: None,
3942
}
4043
}

crates/libsy/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ pub struct AgentSysSignals {}
5050
#[derive(Clone)]
5151
pub struct LlmResponse {
5252
pub completion: String,
53+
/// Optional raw provider response body, so a host (e.g. a proxy) can forward
54+
/// the upstream response losslessly instead of rebuilding it from `completion`.
55+
pub raw_response: Option<serde_json::Value>,
5356
}
5457

5558
#[derive(Clone)]
@@ -452,6 +455,7 @@ mod tests {
452455
Ok(OrchestratorResponse {
453456
llm_response: LlmResponse {
454457
completion: model_name.unwrap_or_default(),
458+
raw_response: None,
455459
},
456460
metadata: None,
457461
})
@@ -582,6 +586,7 @@ mod tests {
582586
.set_response(Ok(OrchestratorResponse {
583587
llm_response: LlmResponse {
584588
completion: "fulfilled".to_string(),
589+
raw_response: None,
585590
},
586591
metadata: None,
587592
}))
@@ -695,6 +700,7 @@ mod tests {
695700
Ok(OrchestratorResponse {
696701
llm_response: LlmResponse {
697702
completion: model_name.unwrap_or_default(),
703+
raw_response: None,
698704
},
699705
metadata: None,
700706
})

crates/libsy/src/llm_class.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ mod tests {
226226
};
227227
self.seen.lock().map_err(|_| "lock poisoned")?.push(request);
228228
Ok(OrchestratorResponse {
229-
llm_response: LlmResponse { completion },
229+
llm_response: LlmResponse {
230+
completion,
231+
raw_response: None,
232+
},
230233
metadata: None,
231234
})
232235
}

crates/libsy/src/rand.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ mod tests {
128128
Ok(OrchestratorResponse {
129129
llm_response: LlmResponse {
130130
completion: model_name.unwrap_or_default(),
131+
raw_response: None,
131132
},
132133
metadata: None,
133134
})

demo/libsy-proxy/Cargo.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
[package]
5+
name = "libsy-proxy"
6+
version = "0.1.0"
7+
description = "Demo LLM proxy: switchyard HTTP + API translation, libsy classifier routing"
8+
authors.workspace = true
9+
edition.workspace = true
10+
license.workspace = true
11+
repository.workspace = true
12+
rust-version.workspace = true
13+
14+
[dependencies]
15+
libsy = { path = "../../crates/libsy" }
16+
switchyard-core = { path = "../../crates/switchyard-core" }
17+
switchyard-components = { path = "../../crates/switchyard-components" }
18+
switchyard-components-v2 = { path = "../../crates/switchyard-components-v2" }
19+
switchyard-server = { path = "../../crates/switchyard-server" }
20+
21+
async-trait = "0.1"
22+
serde_json = "1"
23+
tokio = { version = "1", features = ["macros", "rt-multi-thread", "net", "signal"] }

0 commit comments

Comments
 (0)