"examples/pooling/embed/embed_matryoshka_fy_offline.py" did not exist on "e92d7085bfb25200c540391d0be06cb3b7c29ea4"
mod.rs 1.08 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

pub mod base_json_parser;
pub mod deepseek_parser;

pub use super::{config, response};
pub use base_json_parser::try_tool_call_parse_basic_json;
pub use deepseek_parser::parse_tool_calls_deepseek_v3_1;

pub use super::config::JsonParserConfig;
pub use super::response::ToolCallResponse;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub enum JsonParserType {
    // Basic is generic json parser which can handle most of the cases
    Basic,
    // Model Specific JSON Parsers
    DeepseekV31,
}

impl Default for JsonParserType {
    fn default() -> Self {
        Self::Basic
    }
}

pub fn try_tool_call_parse_json(
    message: &str,
    config: &JsonParserConfig,
) -> anyhow::Result<(Vec<ToolCallResponse>, Option<String>)> {
    match config.parser_type {
        JsonParserType::Basic => try_tool_call_parse_basic_json(message, config),
        JsonParserType::DeepseekV31 => parse_tool_calls_deepseek_v3_1(message, config),
    }
}