switchyard-protocol
Provider-neutral request, response, streaming, routing, and metadata types shared by Switchyard algorithms, clients, and translation codecs. This crate defines contracts; it does not route, translate, or perform network calls.
Setup
[]
= { = "https://github.com/NVIDIA-NeMo/Switchyard.git" }
= "1"
Main types
| Area | Types |
|---|---|
| Conversation | [LlmRequest], [Message], [InstructionBlock], [ContentBlock] |
| Tools | [ToolDefinition], [ToolChoice], [ToolCall], [ToolResult] |
| Response | [AggLlmResponse], [ResponseOutput], [Usage], [StopReason] |
| Streaming | [LlmResponse], [LlmResponseStream], [LlmResponseStreamEvent], [LlmResponseChunk], [ProviderStreamEvent] |
| Envelope | [Context], [Request], [Response], [Metadata] |
| Routing I/O | [Decision], [RoutedLlmClient], [LlmClientError] |
| Wire identity | [WireFormat], [FormatId] |
Simple request
use ;
let request = LlmRequest ;
assert_eq!;
assert_eq!;
Detailed request
Construct the normalized [Request] directly when routing needs instructions,
tools, generation controls, and correlation metadata:
use json;
use ;
let request = Request ;
assert_eq!;
Response forms
[LlmResponse] contains either a completed [AggLlmResponse] or a
single-consumption [LlmResponseStream] of [LlmResponseStreamEvent] values.
Each event carries provider-neutral [LlmResponseChunk] values and may retain
one opaque [ProviderStreamEvent] for same-format parsed-JSON-value replay. See
[LlmResponse::into_agg] for aggregation and [PreservationMetadata],
[Usage], and [Metadata] for the data retained around a response.
License
Licensed under the Apache License, Version 2.0.