dynamo_llm/discovery/
model_entry.rs

1// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4use dynamo_runtime::{protocols, slug::Slug};
5use serde::{Deserialize, Serialize};
6
7use crate::{
8    local_model::runtime_config::ModelRuntimeConfig,
9    model_type::{ModelInput, ModelType},
10};
11
12/// [ModelEntry] contains the information to discover models
13#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
14pub struct ModelEntry {
15    /// Public name of the model
16    /// Used to identify the model in the HTTP service from the value used in an OpenAI ChatRequest.
17    pub name: String,
18
19    /// How to address this on the network
20    #[serde(rename = "endpoint")]
21    pub endpoint_id: protocols::EndpointId,
22
23    /// Specifies whether the model is a chat, completions, etc model.
24    pub model_type: ModelType,
25
26    /// Runtime configuration specific to this model instance
27    #[serde(default, skip_serializing_if = "Option::is_none")]
28    pub runtime_config: Option<ModelRuntimeConfig>,
29
30    /// Specifies the model input type.
31    /// `Tokens` for engines that expect pre-processed input.
32    /// `Text` for engines that take care of pre-processing themselves.
33    pub model_input: ModelInput,
34}
35
36impl ModelEntry {
37    /// Slugified display name for use in network storage, or URL-safe environments
38    pub fn slug(&self) -> Slug {
39        Slug::from_string(&self.name)
40    }
41
42    pub fn requires_preprocessing(&self) -> bool {
43        matches!(self.model_input, ModelInput::Tokens)
44    }
45}