Skip to main content

bitrouter_core/models/language/
tool.rs

1use crate::models::shared::{
2    provider::ProviderOptions,
3    types::{JsonSchema, JsonValue, Record},
4};
5
6/// The definition of tools that can be used by language models during generation.
7#[derive(Debug, Clone)]
8pub enum LanguageModelTool {
9    /// type: "function"
10    Function {
11        name: String,
12        description: Option<String>,
13        input_schema: JsonSchema,
14        input_examples: Vec<LanguageModelFunctionToolInputExample>,
15        strict: Option<bool>,
16        /// Provider-specific metadata
17        provider_options: Option<ProviderOptions>,
18    },
19    /// type: "provider"
20    Provider {
21        id: ProviderToolId,
22        name: String,
23        args: Record<String, JsonValue>,
24        /// Provider-specific metadata
25        provider_options: Option<ProviderOptions>,
26    },
27}
28
29/// Represents an example input for a function tool.
30#[derive(Debug, Clone)]
31pub struct LanguageModelFunctionToolInputExample {
32    pub input: JsonValue,
33}
34
35/// Represents the unique identifier for a provider tool, consisting of the provider name and tool ID.
36#[derive(Debug, Clone)]
37pub struct ProviderToolId {
38    pub provider_name: String,
39    pub tool_id: String,
40}