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
4use std::collections::HashMap;
5
6use serde_json::Value;
7
8#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
9pub enum ToolType {
10    #[serde(rename = "function")]
11    Function,
12}
13
14#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
15pub enum ToolChoice {
16    #[serde(rename = "none")]
17    /// Disallow selection of tools.
18    None,
19    #[serde(rename = "auto")]
20    /// Allow automatic selection of any given tool, or none.
21    Auto,
22    #[serde(untagged)]
23    /// Force selection of a given tool.
24    Tool(Tool),
25}
26
27#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
28pub struct Function {
29    pub description: Option<String>,
30    pub name: String,
31    pub parameters: Option<HashMap<String, Value>>,
32}
33
34#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
35pub struct Tool {
36    #[serde(rename = "type")]
37    pub tp: ToolType,
38    pub function: Function,
39}