Publish harness and TUI open-source
initial sync from the monorepo
This commit is contained in:
commit
c68e39f604
2734 changed files with 1437016 additions and 0 deletions
13
crates/codegen/xai-grok-models/Cargo.toml
Normal file
13
crates/codegen/xai-grok-models/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
license = "Apache-2.0"
|
||||
name = "xai-grok-models"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
description = "Default model IDs for the grok CLI, loaded from the embedded default_models.json."
|
||||
|
||||
[dependencies]
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
18
crates/codegen/xai-grok-models/default_models.json
Normal file
18
crates/codegen/xai-grok-models/default_models.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"default": "grok-build",
|
||||
"web_search": "grok-4.20-multi-agent",
|
||||
"image_description": "grok-build",
|
||||
"session_summary": "grok-build",
|
||||
"models": [
|
||||
{
|
||||
"model": "grok-build",
|
||||
"name": "Grok Build",
|
||||
"description": "Best for advanced coding tasks",
|
||||
"context_window": 500000,
|
||||
"temperature": 0.7,
|
||||
"top_p": 0.95,
|
||||
"api_backend": "responses",
|
||||
"supported_in_api": false
|
||||
}
|
||||
]
|
||||
}
|
||||
70
crates/codegen/xai-grok-models/src/lib.rs
Normal file
70
crates/codegen/xai-grok-models/src/lib.rs
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
//! Default model IDs loaded from `default_models.json` at runtime.
|
||||
//! Edit that JSON file to change them.
|
||||
//!
|
||||
//! At runtime each model is resolved via:
|
||||
//! CLI flag > ENV var > config.toml > remote settings > these defaults
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
/// The raw JSON, embedded at compile time. Re-exported through the
|
||||
/// `xai_grok_shell::models` facade and consumed by `agent::config`, so it must
|
||||
/// be `pub` (was `pub(crate)` when this lived inside the shell crate).
|
||||
pub const DEFAULT_MODELS_JSON: &str = include_str!("../default_models.json");
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
struct DefaultModels {
|
||||
default: String,
|
||||
/// Falls back to `default` if not specified in JSON.
|
||||
web_search: Option<String>,
|
||||
/// Falls back to `default` if not specified in JSON.
|
||||
image_description: Option<String>,
|
||||
/// Falls back to `default` if not specified in JSON.
|
||||
session_summary: Option<String>,
|
||||
models: Vec<DefaultModelEntry>,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
struct DefaultModelEntry {
|
||||
model: String,
|
||||
}
|
||||
|
||||
static DEFAULTS: LazyLock<DefaultModels> = LazyLock::new(|| {
|
||||
let defaults: DefaultModels = serde_json::from_str(DEFAULT_MODELS_JSON)
|
||||
.expect("default_models.json: invalid JSON or missing 'default' field");
|
||||
|
||||
// Baked-in JSON — a mismatch here is a developer error, not a runtime condition.
|
||||
let model_ids: Vec<&str> = defaults.models.iter().map(|m| m.model.as_str()).collect();
|
||||
assert!(
|
||||
model_ids.contains(&defaults.default.as_str()),
|
||||
"default_models.json: 'default' is '{}' but 'models' array only has {model_ids:?}",
|
||||
defaults.default,
|
||||
);
|
||||
|
||||
defaults
|
||||
});
|
||||
|
||||
/// Primary model for coding tasks and general fallback.
|
||||
pub fn default_model() -> &'static str {
|
||||
&DEFAULTS.default
|
||||
}
|
||||
|
||||
/// Model for web search tool synthesis. Falls back to default model.
|
||||
pub fn default_web_search_model() -> &'static str {
|
||||
DEFAULTS.web_search.as_deref().unwrap_or(&DEFAULTS.default)
|
||||
}
|
||||
|
||||
/// Model for image describe. Falls back to default model.
|
||||
pub fn default_image_description_model() -> &'static str {
|
||||
DEFAULTS
|
||||
.image_description
|
||||
.as_deref()
|
||||
.unwrap_or(&DEFAULTS.default)
|
||||
}
|
||||
|
||||
/// Model for session title generation. Falls back to default model.
|
||||
pub fn default_session_summary_model() -> &'static str {
|
||||
DEFAULTS
|
||||
.session_summary
|
||||
.as_deref()
|
||||
.unwrap_or(&DEFAULTS.default)
|
||||
}
|
||||
Loading…
Reference in a new issue