dynamo_llm/preprocessor/tools/request.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 std::collections::HashMap;
17
18use serde_json::Value;
19
20#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
21pub enum ToolType {
22    #[serde(rename = "function")]
23    Function,
24}
25
26#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
27pub enum ToolChoice {
28    #[serde(rename = "none")]
29    /// Disallow selection of tools.
30    None,
31    #[serde(rename = "auto")]
32    /// Allow automatic selection of any given tool, or none.
33    Auto,
34    #[serde(untagged)]
35    /// Force selection of a given tool.
36    Tool(Tool),
37}
38
39#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
40pub struct Function {
41    pub description: Option<String>,
42    pub name: String,
43    pub parameters: Option<HashMap<String, Value>>,
44}
45
46#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
47pub struct Tool {
48    #[serde(rename = "type")]
49    pub tp: ToolType,
50    pub function: Function,
51}