Skip to content
Merged
2 changes: 1 addition & 1 deletion crates/goose-cli/src/commands/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ pub async fn configure_provider_dialog() -> Result<bool, Box<dyn Error>> {
let models_res = {
let temp_model_config = goose::model::ModelConfig::new(&provider_meta.default_model)?;
let temp_provider = create(provider_name, temp_model_config)?;
temp_provider.fetch_supported_models_async().await
temp_provider.fetch_supported_models().await
};
spin.stop(style("Model fetch complete").green());

Expand Down
64 changes: 25 additions & 39 deletions crates/goose-cli/src/session/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,18 @@ pub fn render_prompts(prompts: &HashMap<String, Vec<String>>) {

pub fn render_prompt_info(info: &PromptInfo) {
println!();

if let Some(ext) = &info.extension {
println!(" {}: {}", style("Extension").green(), ext);
}

println!(" Prompt: {}", style(&info.name).cyan().bold());

if let Some(desc) = &info.description {
println!("\n {}", desc);
}
render_arguments(info);
println!();
}

fn render_arguments(info: &PromptInfo) {
if let Some(args) = &info.arguments {
println!("\n Arguments:");
for arg in args {
Expand All @@ -323,7 +324,6 @@ pub fn render_prompt_info(info: &PromptInfo) {
);
}
}
println!();
}

pub fn render_extension_success(name: &str) {
Expand Down Expand Up @@ -491,6 +491,23 @@ fn get_tool_params_max_length() -> usize {
.unwrap_or(40)
}

fn print_value(value: &Value, debug: bool) {
let formatted = match value {
Value::String(s) => {
if !debug && s.len() > get_tool_params_max_length() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shows up as:

image

is that intended when not debug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know - I didn't really touch this code, the new linter rules force me to break up this function

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah - fair enough, yes refactoring makes reviewing diffs very difficult when it breaks up things (wish the diff was a bit smarter, and could point out the code previously existed - if you search for it you can see but easy to miss). Yeah makes sense, just odd I never saw this before.

style(format!("[REDACTED: {} chars]", s.len())).yellow()
} else {
style(s.to_string()).green()
}
}
Value::Number(n) => style(n.to_string()).yellow(),
Value::Bool(b) => style(b.to_string()).yellow(),
Value::Null => style("null".to_string()).dim(),
_ => unreachable!(),
};
println!("{}", formatted);
}

fn print_params(value: &Value, depth: usize, debug: bool) {
let indent = INDENT.repeat(depth);

Expand All @@ -509,21 +526,9 @@ fn print_params(value: &Value, depth: usize, debug: bool) {
print_params(item, depth + 2, debug);
}
}
Value::String(s) => {
if !debug && s.len() > get_tool_params_max_length() {
println!("{}{}: {}", indent, style(key).dim(), style("...").dim());
} else {
println!("{}{}: {}", indent, style(key).dim(), style(s).green());
}
}
Value::Number(n) => {
println!("{}{}: {}", indent, style(key).dim(), style(n).blue());
}
Value::Bool(b) => {
println!("{}{}: {}", indent, style(key).dim(), style(b).blue());
}
Value::Null => {
println!("{}{}: {}", indent, style(key).dim(), style("null").dim());
_ => {
print!("{}{}: ", indent, style(key).dim());
print_value(val, debug);
}
}
}
Expand All @@ -534,26 +539,7 @@ fn print_params(value: &Value, depth: usize, debug: bool) {
print_params(item, depth + 1, debug);
}
}
Value::String(s) => {
if !debug && s.len() > get_tool_params_max_length() {
println!(
"{}{}",
indent,
style(format!("[REDACTED: {} chars]", s.len())).yellow()
);
} else {
println!("{}{}", indent, style(s).green());
}
}
Value::Number(n) => {
println!("{}{}", indent, style(n).yellow());
}
Value::Bool(b) => {
println!("{}{}", indent, style(b).yellow());
}
Value::Null => {
println!("{}{}", indent, style("null").dim());
}
_ => print_value(value, debug),
}
}

Expand Down
31 changes: 15 additions & 16 deletions crates/goose-server/src/routes/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ async fn get_tools(
path = "/agent/update_provider",
responses(
(status = 200, description = "Update provider completed", body = String),
(status = 400, description = "Bad request - missing or invalid parameters"),
(status = 401, description = "Unauthorized - invalid secret key"),
(status = 500, description = "Internal server error")
)
)]
Expand All @@ -234,29 +236,26 @@ async fn update_agent_provider(
headers: HeaderMap,
Json(payload): Json<UpdateProviderRequest>,
) -> Result<StatusCode, StatusCode> {
// Verify secret key
let secret_key = headers
.get("X-Secret-Key")
.and_then(|value| value.to_str().ok())
.ok_or(StatusCode::UNAUTHORIZED)?;

if secret_key != state.secret_key {
return Err(StatusCode::UNAUTHORIZED);
}
verify_secret_key(&headers, &state)?;

let agent = state
.get_agent()
.await
.map_err(|_| StatusCode::PRECONDITION_FAILED)?;

let config = Config::global();
let model = payload.model.unwrap_or_else(|| {
config
.get_param("GOOSE_MODEL")
.expect("Did not find a model on payload or in env to update provider with")
});
let model_config = ModelConfig::new(&model).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
let new_provider = create(&payload.provider, model_config).unwrap();
let model = match payload
.model
.or_else(|| config.get_param("GOOSE_MODEL").ok())
{
Some(m) => m,
None => return Err(StatusCode::BAD_REQUEST),
};

let model_config = ModelConfig::new(&model).map_err(|_| StatusCode::BAD_REQUEST)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice if we could include text with these, but maybe leave that for another change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree - I didn't quickly see how that works though. there's a whole bunch of other handlers that would be helped


let new_provider =
create(&payload.provider, model_config).map_err(|_| StatusCode::BAD_REQUEST)?;
agent
.update_provider(new_provider)
.await
Expand Down
Loading
Loading