dynamo_llm/
types.rs

1// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16use crate::protocols;
17
18pub use protocols::{Annotated, TokenIdType};
19
20pub mod openai {
21    use super::*;
22    use dynamo_runtime::pipeline::{ServerStreamingEngine, UnaryEngine};
23
24    pub mod completions {
25        use super::*;
26
27        pub use protocols::openai::completions::{CompletionResponse, NvCreateCompletionRequest};
28
29        /// A [`UnaryEngine`] implementation for the OpenAI Completions API
30        pub type OpenAICompletionsUnaryEngine =
31            UnaryEngine<NvCreateCompletionRequest, CompletionResponse>;
32
33        /// A [`ServerStreamingEngine`] implementation for the OpenAI Completions API
34        pub type OpenAICompletionsStreamingEngine =
35            ServerStreamingEngine<NvCreateCompletionRequest, Annotated<CompletionResponse>>;
36    }
37
38    pub mod chat_completions {
39        use super::*;
40
41        pub use protocols::openai::chat_completions::{
42            NvCreateChatCompletionRequest, NvCreateChatCompletionResponse,
43            NvCreateChatCompletionStreamResponse,
44        };
45
46        /// A [`UnaryEngine`] implementation for the OpenAI Chat Completions API
47        pub type OpenAIChatCompletionsUnaryEngine =
48            UnaryEngine<NvCreateChatCompletionRequest, NvCreateChatCompletionResponse>;
49
50        /// A [`ServerStreamingEngine`] implementation for the OpenAI Chat Completions API
51        pub type OpenAIChatCompletionsStreamingEngine = ServerStreamingEngine<
52            NvCreateChatCompletionRequest,
53            Annotated<NvCreateChatCompletionStreamResponse>,
54        >;
55    }
56
57    pub mod embeddings {
58        use super::*;
59
60        pub use protocols::openai::embeddings::{
61            NvCreateEmbeddingRequest, NvCreateEmbeddingResponse,
62        };
63
64        /// A [`UnaryEngine`] implementation for the OpenAI Embeddings API
65        pub type OpenAIEmbeddingsUnaryEngine =
66            UnaryEngine<NvCreateEmbeddingRequest, NvCreateEmbeddingResponse>;
67
68        /// A [`ServerStreamingEngine`] implementation for the OpenAI Embeddings API
69        pub type OpenAIEmbeddingsStreamingEngine =
70            ServerStreamingEngine<NvCreateEmbeddingRequest, Annotated<NvCreateEmbeddingResponse>>;
71    }
72}