Skip to content

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.

Community — runs on the OSS / Community SDK edition.

Difficulty: Starter 🟢 · LLM

  • Summary: Polymorphic provider patterns with trait objects
  • Scenario: Use trait objects and interfaces to abstract over providers
  • tech_tags in manifest: LLM — example id polymorphic in conformance/examples_manifest.json.
  • SDK: Use an installed SDK tree (NXUSKIT_SDK_DIR, NXUSKIT_LIB_PATH as needed); test-examples.sh resolves Go/Rust/Python deps from that tree only — see README.md, scripts/setup-sdk.sh, and scripts/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 / --verbose are documented below).

Plugin architecture, provider-agnostic application layer

LLM

LanguagePathStatus
Rustrust/Available
Gogo/Available

Attach an installed SDK (NXUSKIT_SDK_DIR). See the repository README.md and scripts/test-examples.sh.

Terminal window
# From `/examples/patterns/polymorphic`:
cd rust && cargo build
cd go && make build
Terminal window
cd rust
cargo run
Terminal window
cd go
make build && bin/polymorphic