MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / options

Function options

crates/opencode-provider/src/transform.rs:1177–1314  ·  view source on GitHub ↗

Generate provider-specific options for a model.

(
    model: &models::ModelInfo,
    session_id: &str,
    provider_options: &HashMap<String, serde_json::Value>,
)

Source from the content-addressed store, hash-verified

1175
1176/// Generate provider-specific options for a model.
1177pub fn options(
1178 model: &models::ModelInfo,
1179 session_id: &str,
1180 provider_options: &HashMap<String, serde_json::Value>,
1181) -> HashMap<String, serde_json::Value> {
1182 use serde_json::json;
1183 let mut result = HashMap::new();
1184
1185 let npm = model
1186 .provider
1187 .as_ref()
1188 .and_then(|p| p.npm.as_deref())
1189 .unwrap_or("");
1190 let api_id = model
1191 .provider
1192 .as_ref()
1193 .and_then(|p| p.api.as_deref())
1194 .unwrap_or("");
1195 let model_id = model.id.to_lowercase();
1196 let provider_id = &model_id; // In the TS, model.providerID is used; here we approximate from model.id
1197
1198 // OpenAI store=false
1199 if provider_id == "openai" || npm == "@ai-sdk/openai" || npm == "@ai-sdk/github-copilot" {
1200 result.insert("store".to_string(), json!(false));
1201 }
1202
1203 // OpenRouter usage include
1204 if npm == "@openrouter/ai-sdk-provider" {
1205 result.insert("usage".to_string(), json!({"include": true}));
1206 if api_id.contains("gemini-3") {
1207 result.insert("reasoning".to_string(), json!({"effort": "high"}));
1208 }
1209 }
1210
1211 // Baseten / opencode chat_template_args
1212 if provider_id == "baseten"
1213 || (provider_id.starts_with("opencode")
1214 && (api_id == "kimi-k2-thinking" || api_id == "glm-4.6"))
1215 {
1216 result.insert(
1217 "chat_template_args".to_string(),
1218 json!({"enable_thinking": true}),
1219 );
1220 }
1221
1222 // zai/zhipuai thinking config
1223 if (provider_id == "zai" || provider_id == "zhipuai") && npm == "@ai-sdk/openai-compatible" {
1224 result.insert(
1225 "thinking".to_string(),
1226 json!({"type": "enabled", "clear_thinking": false}),
1227 );
1228 }
1229
1230 // OpenAI prompt cache key
1231 if provider_id == "openai"
1232 || provider_options
1233 .get("setCacheKey")
1234 .and_then(|v| v.as_bool())

Callers

nothing calls this directly

Calls 3

newFunction · 0.85
containsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected