Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

chore: add more props to openclaw config

Vanalite09c5b66873d5
diff --git a/src-tauri/src/core/openclaw/commands.rs b/src-tauri/src/core/openclaw/commands.rs
index 08836bdc1..7c10ceaae 100644
--- a/src-tauri/src/core/openclaw/commands.rs
+++ b/src-tauri/src/core/openclaw/commands.rs
@@ -1464,6 +1464,11 @@ pub async fn openclaw_configure(config_input: Option<OpenClawConfigInput>) -> Re
existing["models"]["providers"]["jan"]["apiKey"] =
serde_json::json!(config.models.providers.jan.api_key);
}
+ // Always update the jan provider baseUrl when an explicit URL was provided
+ if config.models.providers.jan.base_url != DEFAULT_JAN_BASE_URL {
+ existing["models"]["providers"]["jan"]["baseUrl"] =
+ serde_json::json!(config.models.providers.jan.base_url);
+ }
existing
} else {
defaults
@@ -1619,21 +1624,19 @@ pub async fn openclaw_sync_model(
let display_name = model_name.unwrap_or_else(|| model_id.clone());
- // Determine context window based on Jan provider type
- let context_window = if provider.as_deref() == Some("llamacpp") || provider.as_deref() == Some("mlx") {
- 16000
- } else {
- 128000
- };
-
// OpenClaw models.providers.jan.models expects an array of objects with
// at minimum { id, name }. The id must be the plain model name — OpenClaw
// prepends the provider key ("jan/") when resolving references.
+ // Context window is declared as 131072 for all models — the actual limit
+ // is enforced by the inference engine, not this metadata.
let model_def = serde_json::json!({
"id": model_id,
"name": display_name,
- "contextWindow": context_window,
- "maxTokens": 4096
+ "input": ["text"],
+ "reasoning": false,
+ "contextWindow": 131072,
+ "maxTokens": 16384,
+ "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
});
// Read, modify, write the config directly (works for both Docker and direct process)
@@ -1700,22 +1703,22 @@ pub async fn openclaw_sync_all_models(
});
}
- // Build model definition objects.
- // Only { id, name } are required; contextWindow and maxTokens are optional.
+ // Build model definition objects matching the CLI's rich format so OpenClaw
+ // can make optimal decisions about context, output limits, and cost.
+ // Use the actual context window from Jan's model settings when available,
+ // falling back to 131072 (128K) as a reasonable default.
let model_defs: Vec<serde_json::Value> = models
.iter()
.map(|entry| {
- let context_window = if entry.provider == "llamacpp" || entry.provider == "mlx" {
- 16000
- } else {
- 128000
- };
-
+ let ctx = entry.context_window.unwrap_or(131072);
serde_json::json!({
"id": entry.model_id,
"name": entry.display_name,
- "contextWindow": context_window,
- "maxTokens": 4096
+ "input": ["text"],
+ "reasoning": false,
+ "contextWindow": ctx,
+ "maxTokens": 16384,
+ "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
})
})
.collect();
diff --git a/src-tauri/src/core/openclaw/models.rs b/src-tauri/src/core/openclaw/models.rs
index 0d143b659..08c3bef68 100644
--- a/src-tauri/src/core/openclaw/models.rs
+++ b/src-tauri/src/core/openclaw/models.rs
@@ -523,6 +523,9 @@ pub struct ModelSyncEntry {
/// Human-readable display name
#[serde(rename = "displayName")]
pub display_name: String,
+ /// Context window size from Jan's model settings (ctx_len). None = use default.
+ #[serde(rename = "contextWindow")]
+ pub context_window: Option<u32>,
}
/// Result of bulk model sync
diff --git a/web-app/src/containers/dialogs/EnableProgressDialog.tsx b/web-app/src/containers/dialogs/EnableProgressDialog.tsx
index 4643e2767..4c7ce3be7 100644
--- a/web-app/src/containers/dialogs/EnableProgressDialog.tsx
+++ b/web-app/src/containers/dialogs/EnableProgressDialog.tsx
@@ -112,9 +112,10 @@ export function EnableProgressDialog({
setIsRunning(true)
try {
- const { apiKey } = useLocalApiServer.getState()
+ const { apiKey, serverPort, apiPrefix } = useLocalApiServer.getState()
+ const janBaseUrl = `http://localhost:${serverPort}${apiPrefix}`
const result = await invoke<EnableResult>('openclaw_enable', {
- configInput: apiKey ? { janApiKey: apiKey } : null,
+ configInput: { janApiKey: apiKey || undefined, janBaseUrl },
})
if (result.success) {
@@ -151,6 +152,10 @@ export function EnableProgressDialog({
})
if (actualPort && actualPort !== serverPort) {
useLocalApiServer.getState().setServerPort(actualPort)
+ // Update OpenClaw's baseUrl to point at the actual port
+ await invoke('openclaw_configure', {
+ configInput: { janBaseUrl: `http://localhost:${actualPort}${apiPrefix}` },
+ }).catch(() => {})
}
setServerStatus('running')
} catch {
diff --git a/web-app/src/utils/openclaw.ts b/web-app/src/utils/openclaw.ts
index 531734c20..fd939a8b9 100644
--- a/web-app/src/utils/openclaw.ts
+++ b/web-app/src/utils/openclaw.ts
@@ -91,7 +91,7 @@ export async function syncAllModelsToOpenClaw(
selectedModelId?: string
): Promise<number> {
try {
- const models: Array<{ modelId: string; provider: string; displayName: string }> = []
+ const models: Array<{ modelId: string; provider: string; displayName: string; contextWindow?: number }> = []
for (const provider of providers) {
if (!provider.active) continue
@@ -101,10 +101,19 @@ export async function syncAllModelsToOpenClaw(
if (!modelId || typeof modelId !== 'string') continue
if (model.embedding) continue
+ // Extract context window from Jan's model settings (ctx_len)
+ const ctxLenRaw = model.settings?.ctx_len?.controller_props?.value
+ const contextWindow = typeof ctxLenRaw === 'number' && ctxLenRaw > 0
+ ? ctxLenRaw
+ : typeof ctxLenRaw === 'string' && parseInt(ctxLenRaw) > 0
+ ? parseInt(ctxLenRaw)
+ : undefined
+
models.push({
modelId,
provider: provider.provider,
displayName: model.displayName || model.name || modelId,
+ contextWindow,
})
}
}