dynamo_llm/protocols/openai/
models.rs

1// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4use serde::{Deserialize, Serialize};
5
6#[derive(Serialize, Deserialize, Debug, Clone)]
7pub struct ModelInfo {
8    object: String, // "list"
9    data: Vec<ModelMetaData>,
10}
11
12#[derive(Serialize, Deserialize, Debug, Clone)]
13pub struct ModelMetaData {
14    /// Model's ID - must be unique
15    id: String,
16
17    /// Always "model"
18    object: String, // "model"
19
20    /// Unix timestamp of when the model was created
21    /// See <https://en.wikipedia.org/wiki/Unix_time>
22    created: u64,
23
24    /// Name of user or group that owns the model
25    /// Defaults to "skynet" if not provided
26    owned_by: String,
27
28    /// Per-Org permissions
29    #[serde(default, skip_serializing_if = "Option::is_none")]
30    permission: Option<Vec<Permission>>,
31
32    // TODO(#30): docstring needed
33    #[serde(default, skip_serializing_if = "Option::is_none")]
34    root: Option<String>,
35
36    // TODO(#30): docstring needed
37    #[serde(default, skip_serializing_if = "Option::is_none")]
38    parent: Option<String>,
39}
40
41#[derive(Serialize, Deserialize, Debug, Clone)]
42pub struct Permission {
43    /// Unique identifier for the permission
44    /// Example: modelperm-8ca99ea29964429ab51e968892b2b708"
45    id: String,
46
47    /// Always "model_permission"
48    object: String, // "model_permission"
49
50    /// Unix timestamp of when the permission was created
51    /// See <https://en.wikipedia.org/wiki/Unix_time>
52    created: u64,
53
54    /// Name of the organization for which the permission is applicable
55    organization: String,
56
57    /// The name of the group that this permission belongs to
58    #[serde(default, skip_serializing_if = "Option::is_none")]
59    group: Option<String>,
60
61    /// Whether the organization can create engines with this model
62    #[serde(default, skip_serializing_if = "Option::is_none")]
63    allow_create_engine: Option<bool>,
64
65    /// Whether the organization can perform sampling/inference with this model
66    #[serde(default, skip_serializing_if = "Option::is_none")]
67    allow_sampling: Option<bool>,
68
69    /// Whether the organization can request log probabilities for model outputs
70    #[serde(default, skip_serializing_if = "Option::is_none")]
71    allow_logprobs: Option<bool>,
72
73    /// Whether the organization can perform search operations with this model
74    #[serde(default, skip_serializing_if = "Option::is_none")]
75    allow_search_indices: Option<bool>,
76
77    /// Whether the organization can view this model
78    #[serde(default, skip_serializing_if = "Option::is_none")]
79    allow_view: Option<bool>,
80
81    /// Whether the organization can fine-tune this model
82    #[serde(default, skip_serializing_if = "Option::is_none")]
83    allow_fine_tuning: Option<bool>,
84
85    /// Whether this permission blocks access to the model
86    #[serde(default, skip_serializing_if = "Option::is_none")]
87    is_blocking: Option<bool>,
88}