Skip to main content

bitrouter_core/models/language/
content.rs

1use crate::models::shared::{provider::ProviderMetadata, types::JsonValue};
2
3/// The content generated by a language model.
4#[derive(Debug, Clone)]
5pub enum LanguageModelContent {
6    /// type: "text"
7    Text {
8        /// The text content
9        text: String,
10        /// Provider-specific metadata
11        provider_metadata: Option<ProviderMetadata>,
12    },
13    /// type: "reasoning"
14    Reasoning {
15        /// The reasoning content as text
16        text: String,
17        /// Provider-specific metadata
18        provider_metadata: Option<ProviderMetadata>,
19    },
20    /// type: "file"
21    File {
22        /// The file data as bytes
23        data: Vec<u8>,
24        /// The IANA media type
25        media_type: String,
26        /// Provider-specific metadata
27        provider_metadata: Option<ProviderMetadata>,
28    },
29    /// type: "tool-approval-request"
30    ToolApprovalRequest {
31        /// The approval ID
32        approval_id: String,
33        /// The tool call ID
34        tool_call_id: String,
35        /// Provider-specific metadata
36        provider_metadata: Option<ProviderMetadata>,
37    },
38    /// type: "url-source"
39    UrlSource {
40        /// The URL source ID
41        id: String,
42        /// The URL
43        url: String,
44        /// The title of the URL content, if available
45        title: Option<String>,
46        /// Provider-specific metadata
47        provider_metadata: Option<ProviderMetadata>,
48    },
49    /// type: "document-source"
50    DocumentSource {
51        /// The document source ID
52        id: String,
53        /// The IANA media type
54        media_type: String,
55        /// The title of the document
56        title: String,
57        /// The filename of the document, if available
58        filename: Option<String>,
59        /// Provider-specific metadata
60        provider_metadata: Option<ProviderMetadata>,
61    },
62    /// type: "tool-call"
63    ToolCall {
64        /// The tool call ID
65        tool_call_id: String,
66        /// The tool name
67        tool_name: String,
68        /// The stringified tool input
69        tool_input: String,
70        /// Whether the tool call was executed by the provider
71        provider_executed: Option<bool>,
72        /// Whether the tool call is defined at runtime
73        dynamic: Option<bool>,
74        /// Provider-specific metadata
75        provider_metadata: Option<ProviderMetadata>,
76    },
77    /// type: "tool-result"
78    ToolResult {
79        /// The tool call ID
80        tool_call_id: String,
81        /// The tool name
82        tool_name: String,
83        /// The tool result content
84        result: JsonValue,
85        /// Optional flag if the result is an error
86        is_error: Option<bool>,
87        /// Preliminary tool results replace each other, e.g. image previews.
88        /// There always has to be a final, non-preliminary tool result.
89        preliminary: Option<bool>,
90        /// Whether the tool call is defined at runtime
91        dynamic: Option<bool>,
92        /// Provider-specific metadata
93        provider_metadata: Option<ProviderMetadata>,
94    },
95}