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::{CompletionRequest, CompletionResponse};
28
29 /// A [`UnaryEngine`] implementation for the OpenAI Completions API
30 pub type OpenAICompletionsUnaryEngine = UnaryEngine<CompletionRequest, CompletionResponse>;
31
32 /// A [`ServerStreamingEngine`] implementation for the OpenAI Completions API
33 pub type OpenAICompletionsStreamingEngine =
34 ServerStreamingEngine<CompletionRequest, Annotated<CompletionResponse>>;
35 }
36
37 pub mod chat_completions {
38 use super::*;
39
40 pub use protocols::openai::chat_completions::{
41 NvCreateChatCompletionRequest, NvCreateChatCompletionResponse,
42 NvCreateChatCompletionStreamResponse,
43 };
44
45 /// A [`UnaryEngine`] implementation for the OpenAI Chat Completions API
46 pub type OpenAIChatCompletionsUnaryEngine =
47 UnaryEngine<NvCreateChatCompletionRequest, NvCreateChatCompletionResponse>;
48
49 /// A [`ServerStreamingEngine`] implementation for the OpenAI Chat Completions API
50 pub type OpenAIChatCompletionsStreamingEngine = ServerStreamingEngine<
51 NvCreateChatCompletionRequest,
52 Annotated<NvCreateChatCompletionStreamResponse>,
53 >;
54 }
55}