Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T02:34:49.534Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

language_model.rs

643 lines · 23.8 KB · rust
1use crate::merge_from::MergeFrom;
2use collections::HashMap;
3use language_model_core::ReasoningEffort;
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use settings_macros::{MergeFrom, with_fallible_options};
7
8use std::sync::Arc;
9
10#[with_fallible_options]
11#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
12pub struct AllLanguageModelSettingsContent {
13    pub anthropic: Option<AnthropicSettingsContent>,
14    pub anthropic_compatible: Option<HashMap<Arc<str>, AnthropicCompatibleSettingsContent>>,
15    pub bedrock: Option<AmazonBedrockSettingsContent>,
16    pub deepseek: Option<DeepseekSettingsContent>,
17    pub google: Option<GoogleSettingsContent>,
18    #[serde(rename = "llama.cpp")]
19    pub llama_cpp: Option<LlamaCppSettingsContent>,
20    pub lmstudio: Option<LmStudioSettingsContent>,
21    pub mistral: Option<MistralSettingsContent>,
22    pub ollama: Option<OllamaSettingsContent>,
23    pub opencode: Option<OpenCodeSettingsContent>,
24    pub open_router: Option<OpenRouterSettingsContent>,
25    pub openai: Option<OpenAiSettingsContent>,
26    pub openai_compatible: Option<HashMap<Arc<str>, OpenAiCompatibleSettingsContent>>,
27    pub vercel_ai_gateway: Option<VercelAiGatewaySettingsContent>,
28    pub x_ai: Option<XAiSettingsContent>,
29    #[serde(rename = "zed.dev")]
30    pub zed_dot_dev: Option<ZedDotDevSettingsContent>,
31}
32
33#[with_fallible_options]
34#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
35pub struct AnthropicSettingsContent {
36    pub api_url: Option<String>,
37    pub available_models: Option<Vec<AnthropicAvailableModel>>,
38    pub custom_headers: Option<HashMap<String, String>>,
39}
40
41#[with_fallible_options]
42#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
43pub struct AnthropicCompatibleSettingsContent {
44    pub api_url: String,
45    pub available_models: Vec<AnthropicCompatibleAvailableModel>,
46    pub custom_headers: Option<HashMap<String, String>>,
47}
48
49#[with_fallible_options]
50#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
51pub struct AnthropicCompatibleAvailableModel {
52    /// The model's name in the provider's API. e.g. claude-3-5-sonnet-latest
53    pub name: String,
54    /// The model's name in Omega's UI, such as in the model selector dropdown menu in the assistant panel.
55    pub display_name: Option<String>,
56    /// The model's context window size.
57    pub max_tokens: u64,
58    /// A model `name` to substitute when calling tools, in case the primary model doesn't support tool calling.
59    pub tool_override: Option<String>,
60    pub max_output_tokens: Option<u64>,
61    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
62    pub default_temperature: Option<f32>,
63    #[serde(default)]
64    pub extra_beta_headers: Vec<String>,
65    /// The model's mode (e.g. thinking)
66    pub mode: Option<ModelMode>,
67    #[serde(default)]
68    pub capabilities: AnthropicCompatibleModelCapabilities,
69}
70
71#[with_fallible_options]
72#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
73pub struct AnthropicCompatibleModelCapabilities {
74    pub tools: bool,
75    pub images: bool,
76    /// Whether to send explicit `cache_control` breakpoints for prompt caching.
77    /// Leave disabled if the provider rejects requests containing them.
78    pub prompt_caching: bool,
79}
80
81impl Default for AnthropicCompatibleModelCapabilities {
82    fn default() -> Self {
83        Self {
84            tools: true,
85            images: false,
86            prompt_caching: false,
87        }
88    }
89}
90
91#[with_fallible_options]
92#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
93pub struct AnthropicAvailableModel {
94    /// The model's name in the Anthropic API. e.g. claude-3-5-sonnet-latest, claude-3-opus-20240229, etc
95    pub name: String,
96    /// The model's name in Omega's UI, such as in the model selector dropdown menu in the agent panel.
97    pub display_name: Option<String>,
98    /// The model's context window size.
99    pub max_tokens: u64,
100    /// A model `name` to substitute when calling tools, in case the primary model doesn't support tool calling.
101    pub tool_override: Option<String>,
102    /// Configuration of Anthropic's caching API.
103    pub cache_configuration: Option<LanguageModelCacheConfiguration>,
104    pub max_output_tokens: Option<u64>,
105    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
106    pub default_temperature: Option<f32>,
107    #[serde(default)]
108    pub extra_beta_headers: Vec<String>,
109    /// Whether Anthropic's fast mode is available for this model.
110    pub supports_fast_mode: Option<bool>,
111    /// The model's mode (e.g. thinking)
112    pub mode: Option<ModelMode>,
113}
114
115#[with_fallible_options]
116#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
117pub struct AmazonBedrockSettingsContent {
118    pub available_models: Option<Vec<BedrockAvailableModel>>,
119    /// Custom models served through the `bedrock-mantle` endpoint's
120    /// OpenAI-compatible APIs, in addition to the built-in Mantle models
121    /// (GPT-5.6 Sol, GPT-5.6 Terra, GPT-5.6 Luna, GPT-5.5, GPT-5.4, Grok 4.3).
122    pub mantle_available_models: Option<Vec<BedrockMantleAvailableModel>>,
123    pub custom_headers: Option<HashMap<String, String>>,
124    pub endpoint_url: Option<String>,
125    pub region: Option<String>,
126    pub profile: Option<String>,
127    pub authentication_method: Option<BedrockAuthMethodContent>,
128    pub allow_global: Option<bool>,
129    /// The guardrail identifier (ARN or ID) to apply to Bedrock API requests.
130    pub guardrail_identifier: Option<String>,
131    /// The guardrail version to use. Defaults to "DRAFT" if not specified.
132    pub guardrail_version: Option<String>,
133}
134
135#[with_fallible_options]
136#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
137pub struct BedrockAvailableModel {
138    pub name: String,
139    pub display_name: Option<String>,
140    pub max_tokens: u64,
141    pub cache_configuration: Option<LanguageModelCacheConfiguration>,
142    pub max_output_tokens: Option<u64>,
143    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
144    pub default_temperature: Option<f32>,
145    pub mode: Option<ModelMode>,
146}
147
148#[with_fallible_options]
149#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
150pub struct BedrockMantleAvailableModel {
151    /// The model id as expected in Bedrock Mantle request bodies, e.g. `openai.gpt-5.5`.
152    pub name: String,
153    pub display_name: Option<String>,
154    pub max_tokens: u64,
155    pub max_output_tokens: Option<u64>,
156    /// The OpenAI-compatible API this model must be called through.
157    pub protocol: BedrockMantleProtocolContent,
158    pub supports_tools: Option<bool>,
159    pub supports_images: Option<bool>,
160    /// Whether this custom Mantle model supports OpenAI reasoning effort parameters.
161    pub supports_thinking: Option<bool>,
162}
163
164#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
165pub enum BedrockMantleProtocolContent {
166    /// The OpenAI Chat Completions API (`/chat/completions`).
167    #[serde(rename = "chat_completions")]
168    ChatCompletions,
169    /// The OpenAI Responses API (`/responses`).
170    #[serde(rename = "responses")]
171    Responses,
172}
173
174#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
175pub enum BedrockAuthMethodContent {
176    #[serde(rename = "named_profile")]
177    NamedProfile,
178    #[serde(rename = "sso")]
179    SingleSignOn,
180    #[serde(rename = "api_key")]
181    ApiKey,
182    /// IMDSv2, PodIdentity, env vars, etc.
183    #[serde(rename = "default")]
184    Automatic,
185}
186
187#[with_fallible_options]
188#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
189pub struct OllamaSettingsContent {
190    pub api_url: Option<String>,
191    pub auto_discover: Option<bool>,
192    pub available_models: Option<Vec<OllamaAvailableModel>>,
193    pub context_window: Option<u64>,
194    pub custom_headers: Option<HashMap<String, String>>,
195}
196
197#[with_fallible_options]
198#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
199pub struct OllamaAvailableModel {
200    /// The model name in the Ollama API (e.g. "llama3.2:latest")
201    pub name: String,
202    /// The model's name in Omega's UI, such as in the model selector dropdown menu in the agent panel.
203    pub display_name: Option<String>,
204    /// The Context Length parameter to the model (aka num_ctx or n_ctx)
205    pub max_tokens: u64,
206    /// The number of seconds to keep the connection open after the last request
207    pub keep_alive: Option<KeepAlive>,
208    /// Whether the model supports tools
209    pub supports_tools: Option<bool>,
210    /// Whether the model supports vision
211    pub supports_images: Option<bool>,
212    /// Whether to enable think mode
213    pub supports_thinking: Option<bool>,
214}
215
216#[derive(Clone, Serialize, Deserialize, Debug, Eq, PartialEq, JsonSchema, MergeFrom)]
217#[serde(untagged)]
218pub enum KeepAlive {
219    /// Keep model alive for N seconds
220    Seconds(isize),
221    /// Keep model alive for a fixed duration. Accepts durations like "5m", "10m", "1h", "1d", etc.
222    Duration(String),
223}
224
225impl KeepAlive {
226    /// Keep model alive until a new model is loaded or until Ollama shuts down
227    pub fn indefinite() -> Self {
228        Self::Seconds(-1)
229    }
230}
231
232impl Default for KeepAlive {
233    fn default() -> Self {
234        Self::indefinite()
235    }
236}
237
238#[with_fallible_options]
239#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
240pub struct OpenCodeSettingsContent {
241    pub api_url: Option<String>,
242    pub available_models: Option<Vec<OpenCodeAvailableModel>>,
243    pub custom_headers: Option<HashMap<String, String>>,
244    /// Whether to show OpenCode Zen models. Defaults to true.
245    pub show_zen_models: Option<bool>,
246    /// Whether to show OpenCode Go models. Defaults to true.
247    pub show_go_models: Option<bool>,
248    /// Whether to show OpenCode Free models. Defaults to true.
249    pub show_free_models: Option<bool>,
250}
251
252#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom)]
253pub enum OpenCodeApiProtocol {
254    #[serde(rename = "anthropic")]
255    Anthropic,
256    #[serde(rename = "openai_responses", alias = "open_ai_responses")]
257    OpenAiResponses,
258    #[serde(rename = "openai_chat", alias = "open_ai_chat")]
259    OpenAiChat,
260    #[serde(rename = "google")]
261    Google,
262}
263
264#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom)]
265#[serde(rename_all = "snake_case")]
266pub enum OpenCodeModelSubscription {
267    Zen,
268    Go,
269    Free,
270}
271
272#[with_fallible_options]
273#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
274pub struct OpenCodeAvailableModel {
275    pub name: String,
276    pub display_name: Option<String>,
277    pub max_tokens: u64,
278    pub max_output_tokens: Option<u64>,
279    /// The API protocol to use for this model: "anthropic", "openai_responses", "openai_chat", or "google". Defaults to "openai_chat".
280    pub protocol: Option<OpenCodeApiProtocol>,
281    /// The subscription for this model: "zen", "go", or "free". Defaults to Zen.
282    pub subscription: Option<OpenCodeModelSubscription>,
283    /// Custom Model API URL to use for this model.
284    pub custom_model_api_url: Option<String>,
285    /// Supported reasoning effort levels, for example `["low", "medium", "high"].
286    pub reasoning_effort_levels: Option<Vec<ReasoningEffort>>,
287    /// When using OpenAiChat protocol, whether thinking tokens are sent as a dedicated `reasoning_content` field or inline in message text.
288    #[serde(default)]
289    pub interleaved_reasoning: bool,
290}
291
292#[with_fallible_options]
293#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
294pub struct LmStudioSettingsContent {
295    pub api_url: Option<String>,
296    pub api_key: Option<String>,
297    pub available_models: Option<Vec<LmStudioAvailableModel>>,
298    pub custom_headers: Option<HashMap<String, String>>,
299}
300
301#[with_fallible_options]
302#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
303pub struct LmStudioAvailableModel {
304    pub name: String,
305    pub display_name: Option<String>,
306    pub max_tokens: u64,
307    pub supports_tool_calls: bool,
308    pub supports_images: bool,
309}
310
311#[with_fallible_options]
312#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
313pub struct LlamaCppSettingsContent {
314    pub api_url: Option<String>,
315    /// Whether to automatically discover models served by the llama.cpp server.
316    /// Defaults to true.
317    pub auto_discover: Option<bool>,
318    pub available_models: Option<Vec<LlamaCppAvailableModel>>,
319    /// Overrides the context length reported for every llama.cpp model.
320    pub context_window: Option<u64>,
321    pub custom_headers: Option<HashMap<String, String>>,
322}
323
324#[with_fallible_options]
325#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
326pub struct LlamaCppAvailableModel {
327    /// The model id reported by the llama.cpp server (its `--alias` or the model file path).
328    pub name: String,
329    /// The model's name in Omega's UI, such as in the model selector dropdown menu in the agent panel.
330    pub display_name: Option<String>,
331    /// The Context Length parameter to the model (aka n_ctx).
332    pub max_tokens: u64,
333    /// Whether the model supports tools.
334    pub supports_tools: Option<bool>,
335    /// Whether the model supports vision.
336    pub supports_images: Option<bool>,
337    /// Whether the model emits reasoning/thinking content.
338    pub supports_thinking: Option<bool>,
339}
340
341#[with_fallible_options]
342#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
343pub struct DeepseekSettingsContent {
344    pub api_url: Option<String>,
345    pub available_models: Option<Vec<DeepseekAvailableModel>>,
346    pub custom_headers: Option<HashMap<String, String>>,
347}
348
349#[with_fallible_options]
350#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
351pub struct DeepseekAvailableModel {
352    pub name: String,
353    pub display_name: Option<String>,
354    pub max_tokens: u64,
355    pub max_output_tokens: Option<u64>,
356}
357
358#[with_fallible_options]
359#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
360pub struct MistralSettingsContent {
361    pub api_url: Option<String>,
362    pub available_models: Option<Vec<MistralAvailableModel>>,
363    pub custom_headers: Option<HashMap<String, String>>,
364}
365
366#[with_fallible_options]
367#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
368pub struct MistralAvailableModel {
369    pub name: String,
370    pub display_name: Option<String>,
371    pub max_tokens: u64,
372    pub max_output_tokens: Option<u64>,
373    pub max_completion_tokens: Option<u64>,
374    pub supports_tools: Option<bool>,
375    pub supports_images: Option<bool>,
376    pub supports_thinking: Option<bool>,
377}
378
379#[with_fallible_options]
380#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
381pub struct OpenAiSettingsContent {
382    pub api_url: Option<String>,
383    pub available_models: Option<Vec<OpenAiAvailableModel>>,
384    pub custom_headers: Option<HashMap<String, String>>,
385}
386
387#[with_fallible_options]
388#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
389pub struct OpenAiAvailableModel {
390    pub name: String,
391    pub display_name: Option<String>,
392    pub max_tokens: u64,
393    pub max_output_tokens: Option<u64>,
394    pub max_completion_tokens: Option<u64>,
395    pub reasoning_effort: Option<OpenAiReasoningEffort>,
396    #[serde(default)]
397    pub capabilities: OpenAiModelCapabilities,
398}
399
400pub use language_model_core::ReasoningEffort as OpenAiReasoningEffort;
401
402impl MergeFrom for OpenAiReasoningEffort {
403    fn merge_from(&mut self, other: &Self) {
404        *self = *other;
405    }
406}
407
408#[with_fallible_options]
409#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
410pub struct OpenAiCompatibleSettingsContent {
411    pub api_url: String,
412    pub available_models: Vec<OpenAiCompatibleAvailableModel>,
413    pub custom_headers: Option<HashMap<String, String>>,
414}
415
416#[with_fallible_options]
417#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
418pub struct OpenAiModelCapabilities {
419    #[serde(default = "default_true")]
420    pub chat_completions: bool,
421    #[serde(default = "default_true")]
422    pub images: bool,
423}
424
425impl Default for OpenAiModelCapabilities {
426    fn default() -> Self {
427        Self {
428            chat_completions: default_true(),
429            images: default_true(),
430        }
431    }
432}
433
434#[with_fallible_options]
435#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
436pub struct OpenAiCompatibleAvailableModel {
437    pub name: String,
438    pub display_name: Option<String>,
439    pub max_tokens: u64,
440    pub max_output_tokens: Option<u64>,
441    pub max_completion_tokens: Option<u64>,
442    pub reasoning_effort: Option<OpenAiReasoningEffort>,
443    #[serde(default)]
444    pub capabilities: OpenAiCompatibleModelCapabilities,
445}
446
447#[with_fallible_options]
448#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
449pub struct OpenAiCompatibleModelCapabilities {
450    pub tools: bool,
451    pub images: bool,
452    pub parallel_tool_calls: bool,
453    pub prompt_cache_key: bool,
454    #[serde(default = "default_true")]
455    pub chat_completions: bool,
456    #[serde(default)]
457    pub interleaved_reasoning: bool,
458    #[serde(default)]
459    pub max_tokens_parameter: bool,
460}
461
462impl Default for OpenAiCompatibleModelCapabilities {
463    fn default() -> Self {
464        Self {
465            tools: true,
466            images: false,
467            parallel_tool_calls: false,
468            prompt_cache_key: false,
469            chat_completions: default_true(),
470            interleaved_reasoning: false,
471            max_tokens_parameter: false,
472        }
473    }
474}
475
476#[with_fallible_options]
477#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
478pub struct VercelAiGatewaySettingsContent {
479    pub api_url: Option<String>,
480    pub available_models: Option<Vec<VercelAiGatewayAvailableModel>>,
481    pub custom_headers: Option<HashMap<String, String>>,
482}
483
484#[with_fallible_options]
485#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
486pub struct VercelAiGatewayAvailableModel {
487    pub name: String,
488    pub display_name: Option<String>,
489    pub max_tokens: u64,
490    pub max_output_tokens: Option<u64>,
491    pub max_completion_tokens: Option<u64>,
492    #[serde(default)]
493    pub capabilities: OpenAiCompatibleModelCapabilities,
494}
495
496#[with_fallible_options]
497#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
498pub struct GoogleSettingsContent {
499    pub api_url: Option<String>,
500    pub available_models: Option<Vec<GoogleAvailableModel>>,
501    pub custom_headers: Option<HashMap<String, String>>,
502}
503
504#[with_fallible_options]
505#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
506pub struct GoogleAvailableModel {
507    pub name: String,
508    pub display_name: Option<String>,
509    pub max_tokens: u64,
510    pub mode: Option<ModelMode>,
511}
512
513#[with_fallible_options]
514#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
515pub struct XAiSettingsContent {
516    pub api_url: Option<String>,
517    pub available_models: Option<Vec<XaiAvailableModel>>,
518    pub custom_headers: Option<HashMap<String, String>>,
519}
520
521#[with_fallible_options]
522#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
523pub struct XaiAvailableModel {
524    pub name: String,
525    pub display_name: Option<String>,
526    pub max_tokens: u64,
527    pub max_output_tokens: Option<u64>,
528    pub max_completion_tokens: Option<u64>,
529    pub supports_images: Option<bool>,
530    pub supports_tools: Option<bool>,
531    pub parallel_tool_calls: Option<bool>,
532}
533
534#[with_fallible_options]
535#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
536pub struct ZedDotDevSettingsContent {
537    pub available_models: Option<Vec<ZedDotDevAvailableModel>>,
538}
539
540#[with_fallible_options]
541#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
542pub struct ZedDotDevAvailableModel {
543    /// The provider of the language model.
544    pub provider: ZedDotDevAvailableProvider,
545    /// The model's name in the provider's API. e.g. claude-3-5-sonnet-20240620
546    pub name: String,
547    /// The name displayed in the UI, such as in the agent panel model dropdown menu.
548    pub display_name: Option<String>,
549    /// The size of the context window, indicating the maximum number of tokens the model can process.
550    pub max_tokens: usize,
551    /// The maximum number of output tokens allowed by the model.
552    pub max_output_tokens: Option<u64>,
553    /// The maximum number of completion tokens allowed by the model (o1-* only)
554    pub max_completion_tokens: Option<u64>,
555    /// Override this model with a different Anthropic model for tool calls.
556    pub tool_override: Option<String>,
557    /// Indicates whether this custom model supports caching.
558    pub cache_configuration: Option<LanguageModelCacheConfiguration>,
559    /// The default temperature to use for this model.
560    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
561    pub default_temperature: Option<f32>,
562    /// Any extra beta headers to provide when using the model.
563    #[serde(default)]
564    pub extra_beta_headers: Vec<String>,
565    /// The model's mode (e.g. thinking)
566    pub mode: Option<ModelMode>,
567}
568
569#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
570#[serde(rename_all = "lowercase")]
571pub enum ZedDotDevAvailableProvider {
572    Anthropic,
573    OpenAi,
574    Google,
575}
576
577#[with_fallible_options]
578#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
579pub struct OpenRouterSettingsContent {
580    pub api_url: Option<String>,
581    pub available_models: Option<Vec<OpenRouterAvailableModel>>,
582    pub custom_headers: Option<HashMap<String, String>>,
583}
584
585#[with_fallible_options]
586#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
587pub struct OpenRouterAvailableModel {
588    pub name: String,
589    pub display_name: Option<String>,
590    pub max_tokens: u64,
591    pub max_output_tokens: Option<u64>,
592    pub max_completion_tokens: Option<u64>,
593    pub supports_tools: Option<bool>,
594    pub supports_images: Option<bool>,
595    pub mode: Option<ModelMode>,
596    pub provider: Option<OpenRouterProvider>,
597}
598
599#[with_fallible_options]
600#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
601pub struct OpenRouterProvider {
602    order: Option<Vec<String>>,
603    #[serde(default = "default_true")]
604    allow_fallbacks: bool,
605    #[serde(default)]
606    require_parameters: bool,
607    #[serde(default)]
608    data_collection: DataCollection,
609    only: Option<Vec<String>>,
610    ignore: Option<Vec<String>>,
611    quantizations: Option<Vec<String>>,
612    sort: Option<String>,
613}
614
615#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
616#[serde(rename_all = "lowercase")]
617pub enum DataCollection {
618    #[default]
619    Allow,
620    Disallow,
621}
622
623fn default_true() -> bool {
624    true
625}
626
627/// Configuration for caching language model messages.
628#[with_fallible_options]
629#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
630pub struct LanguageModelCacheConfiguration {
631    pub max_cache_anchors: usize,
632    pub should_speculate: bool,
633    pub min_total_token: u64,
634}
635
636pub use language_model_core::ModelMode;
637
638impl MergeFrom for ModelMode {
639    fn merge_from(&mut self, other: &Self) {
640        *self = *other;
641    }
642}
643
Served at tenant.openagents/omega Member data and write actions are omitted.