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