MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / choose_github_model

Function choose_github_model

crates/opencode-cli/src/main.rs:4060–4088  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4058}
4059
4060async fn choose_github_model() -> anyhow::Result<String> {
4061 if let Ok(model) = std::env::var("OPENCODE_GITHUB_MODEL") {
4062 if !model.trim().is_empty() {
4063 return Ok(model);
4064 }
4065 }
4066 if let Ok(model) = std::env::var("MODEL") {
4067 if !model.trim().is_empty() {
4068 return Ok(model);
4069 }
4070 }
4071
4072 let cwd = std::env::current_dir()?;
4073 let config = load_config(&cwd)?;
4074 if let Some(model) = &config.model {
4075 if model.contains('/') {
4076 return Ok(model.clone());
4077 }
4078 }
4079
4080 let registry = setup_providers(&config).await?;
4081 if let Some(provider) = registry.list().first() {
4082 if let Some(model) = provider.models().first() {
4083 return Ok(format!("{}/{}", provider.id(), model.id));
4084 }
4085 }
4086
4087 Ok("openai/gpt-4.1".to_string())
4088}
4089
4090fn build_github_workflow(model: &str) -> String {
4091 let provider = model.split('/').next().unwrap_or_default();

Callers 1

handle_github_commandFunction · 0.85

Calls 7

load_configFunction · 0.85
setup_providersFunction · 0.85
is_emptyMethod · 0.80
containsMethod · 0.80
cloneMethod · 0.45
listMethod · 0.45
modelsMethod · 0.45

Tested by

no test coverage detected