Polymorphic
Use trait objects and interfaces to abstract over providers
Swap LLM providers at runtime without touching your application logic — nxusKit’s polymorphic patterns keep your code provider-agnostic from day one.
Edition
Section titled “Edition”Community — runs on the OSS / Community SDK edition.
What this demonstrates
Section titled “What this demonstrates”Difficulty: Starter 🟢 · LLM
- Summary: Polymorphic provider patterns with trait objects
- Scenario: Use trait objects and interfaces to abstract over providers
tech_tagsin manifest:LLM— example idpolymorphicinconformance/examples_manifest.json.
Prerequisites
Section titled “Prerequisites”- SDK: Use an installed SDK tree (
NXUSKIT_SDK_DIR,NXUSKIT_LIB_PATHas needed);test-examples.shresolves Go/Rust/Python deps from that tree only — see README.md,scripts/setup-sdk.sh, andscripts/test-examples.sh. - Languages in this example: go, rust (paths under this directory; Python may live under a sibling
python/or shared reference per Language Implementations). - Models: Set cloud provider API keys and/or run Ollama locally when you execute the Run steps (interactive flags like
--help/--verboseare documented below).
Real-World Application
Section titled “Real-World Application”Plugin architecture, provider-agnostic application layer
Technologies
Section titled “Technologies”LLM
Language Implementations
Section titled “Language Implementations”| Language | Path | Status |
|---|---|---|
| Rust | rust/ | Available |
| Go | go/ | Available |
Attach an installed SDK (NXUSKIT_SDK_DIR). See the repository README.md and scripts/test-examples.sh.
# From `/examples/patterns/polymorphic`:cd rust && cargo buildcd go && make buildcd rustcargo runcd gomake build && bin/polymorphic