fix: activate custom provider after adding via configure (#9213)
Signed-off-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -2013,6 +2013,7 @@ fn collect_custom_headers() -> anyhow::Result<Option<std::collections::HashMap<S
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add_provider() -> anyhow::Result<()> {
|
fn add_provider() -> anyhow::Result<()> {
|
||||||
|
let config = Config::global();
|
||||||
let provider_type = cliclack::select("What type of API is this?")
|
let provider_type = cliclack::select("What type of API is this?")
|
||||||
.item(
|
.item(
|
||||||
"openai_compatible",
|
"openai_compatible",
|
||||||
@@ -2097,7 +2098,7 @@ fn add_provider() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
let headers = collect_custom_headers()?;
|
let headers = collect_custom_headers()?;
|
||||||
|
|
||||||
create_custom_provider(CreateCustomProviderParams {
|
let provider_config = create_custom_provider(CreateCustomProviderParams {
|
||||||
engine: provider_type.to_string(),
|
engine: provider_type.to_string(),
|
||||||
display_name: display_name.clone(),
|
display_name: display_name.clone(),
|
||||||
api_url,
|
api_url,
|
||||||
@@ -2111,6 +2112,21 @@ fn add_provider() -> anyhow::Result<()> {
|
|||||||
preserves_thinking: None,
|
preserves_thinking: None,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
if !provider_config.models.is_empty() {
|
||||||
|
let model_items: Vec<_> = provider_config
|
||||||
|
.models
|
||||||
|
.iter()
|
||||||
|
.map(|m| (m.name.as_str(), m.name.as_str(), ""))
|
||||||
|
.collect();
|
||||||
|
if let Ok(model) = cliclack::select("Which model should be the default?")
|
||||||
|
.items(&model_items)
|
||||||
|
.interact()
|
||||||
|
{
|
||||||
|
config.set_goose_provider(&provider_config.name)?;
|
||||||
|
config.set_goose_model(model)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cliclack::outro(format!("Custom provider added: {}", display_name))?;
|
cliclack::outro(format!("Custom provider added: {}", display_name))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user