Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/goose-cli/src/commands/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,7 @@ fn add_provider() -> anyhow::Result<()> {
headers,
requires_auth,
catalog_provider_id: None,
base_path: None,
})?;

cliclack::outro(format!("Custom provider added: {}", display_name))?;
Expand Down
4 changes: 4 additions & 0 deletions crates/goose-server/src/routes/config_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ pub struct UpdateCustomProviderRequest {
pub requires_auth: bool,
#[serde(default)]
pub catalog_provider_id: Option<String>,
#[serde(default)]
pub base_path: Option<String>,
}

fn default_requires_auth() -> bool {
Expand Down Expand Up @@ -655,6 +657,7 @@ pub async fn create_custom_provider(
headers: request.headers,
requires_auth: request.requires_auth,
catalog_provider_id: request.catalog_provider_id,
base_path: request.base_path,
},
)?;

Expand Down Expand Up @@ -726,6 +729,7 @@ pub async fn update_custom_provider(
headers: request.headers,
requires_auth: request.requires_auth,
catalog_provider_id: request.catalog_provider_id,
base_path: request.base_path,
},
)?;

Expand Down
6 changes: 6 additions & 0 deletions crates/goose/src/config/declarative_providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub struct DeclarativeProviderConfig {
pub requires_auth: bool,
#[serde(default)]
pub catalog_provider_id: Option<String>,
#[serde(default)]
pub base_path: Option<String>,
}

fn default_requires_auth() -> bool {
Expand Down Expand Up @@ -105,6 +107,7 @@ pub struct CreateCustomProviderParams {
pub headers: Option<HashMap<String, String>>,
pub requires_auth: bool,
pub catalog_provider_id: Option<String>,
pub base_path: Option<String>,
}

#[derive(Debug, Clone)]
Expand All @@ -119,6 +122,7 @@ pub struct UpdateCustomProviderParams {
pub headers: Option<HashMap<String, String>>,
pub requires_auth: bool,
pub catalog_provider_id: Option<String>,
pub base_path: Option<String>,
}

pub fn create_custom_provider(
Expand Down Expand Up @@ -159,6 +163,7 @@ pub fn create_custom_provider(
supports_streaming: params.supports_streaming,
requires_auth: params.requires_auth,
catalog_provider_id: params.catalog_provider_id,
base_path: params.base_path,
};

let custom_providers_dir = custom_providers_dir();
Expand Down Expand Up @@ -221,6 +226,7 @@ pub fn update_custom_provider(params: UpdateCustomProviderParams) -> Result<()>
supports_streaming: params.supports_streaming,
requires_auth: params.requires_auth,
catalog_provider_id: params.catalog_provider_id,
base_path: params.base_path,
Comment thread
dprince marked this conversation as resolved.
};

let file_path = custom_providers_dir().join(format!("{}.json", updated_config.name));
Expand Down
12 changes: 8 additions & 4 deletions crates/goose/src/providers/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,15 @@ impl OpenAiProvider {
} else {
format!("{}://{}", url.scheme(), url.host_str().unwrap_or(""))
};
let base_path = url.path().trim_start_matches('/').to_string();
let base_path = if base_path.is_empty() || base_path == "v1" || base_path == "v1/" {
"v1/chat/completions".to_string()
let base_path = if let Some(ref explicit_path) = config.base_path {
explicit_path.trim_start_matches('/').to_string()
Comment thread
dprince marked this conversation as resolved.
} else {
base_path
let url_path = url.path().trim_start_matches('/').to_string();
if url_path.is_empty() || url_path == "v1" || url_path == "v1/" {
"v1/chat/completions".to_string()
} else {
url_path
}
};

let timeout_secs = config.timeout_seconds.unwrap_or(600);
Expand Down
8 changes: 8 additions & 0 deletions ui/desktop/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4177,6 +4177,10 @@
"api_key_env": {
"type": "string"
},
"base_path": {
"type": "string",
"nullable": true
},
"base_url": {
"type": "string"
},
Expand Down Expand Up @@ -8159,6 +8163,10 @@
"api_url": {
"type": "string"
},
"base_path": {
"type": "string",
"nullable": true
},
"catalog_provider_id": {
"type": "string",
"nullable": true
Expand Down
2 changes: 2 additions & 0 deletions ui/desktop/src/api/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export type CspMetadata = {

export type DeclarativeProviderConfig = {
api_key_env?: string;
base_path?: string | null;
base_url: string;
catalog_provider_id?: string | null;
description?: string | null;
Expand Down Expand Up @@ -1477,6 +1478,7 @@ export type UiMetadata = {
export type UpdateCustomProviderRequest = {
api_key: string;
api_url: string;
base_path?: string | null;
catalog_provider_id?: string | null;
display_name: string;
engine: string;
Expand Down