fix: inconsistent API url requirement between desktop and CLI versions (#6419)
Signed-off-by: Abhijay007 <Abhijay007j@gmail.com>
This commit is contained in:
@@ -1718,7 +1718,7 @@ fn add_provider() -> anyhow::Result<()> {
|
|||||||
.interact()?;
|
.interact()?;
|
||||||
|
|
||||||
let api_url: String = cliclack::input("Provider API URL:")
|
let api_url: String = cliclack::input("Provider API URL:")
|
||||||
.placeholder("https://api.example.com/v1/messages")
|
.placeholder("https://api.example.com/v1")
|
||||||
.validate(|input: &String| {
|
.validate(|input: &String| {
|
||||||
if !input.starts_with("http://") && !input.starts_with("https://") {
|
if !input.starts_with("http://") && !input.starts_with("https://") {
|
||||||
Err("URL must start with either http:// or https://")
|
Err("URL must start with either http:// or https://")
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ impl OpenAiProvider {
|
|||||||
format!("{}://{}", url.scheme(), url.host_str().unwrap_or(""))
|
format!("{}://{}", url.scheme(), url.host_str().unwrap_or(""))
|
||||||
};
|
};
|
||||||
let base_path = url.path().trim_start_matches('/').to_string();
|
let base_path = url.path().trim_start_matches('/').to_string();
|
||||||
let base_path = if base_path.is_empty() {
|
let base_path = if base_path.is_empty() || base_path == "v1" || base_path == "v1/" {
|
||||||
"v1/chat/completions".to_string()
|
"v1/chat/completions".to_string()
|
||||||
} else {
|
} else {
|
||||||
base_path
|
base_path
|
||||||
|
|||||||
+1
-1
@@ -158,7 +158,7 @@ export default function CustomProviderForm({
|
|||||||
id="api-url"
|
id="api-url"
|
||||||
value={apiUrl}
|
value={apiUrl}
|
||||||
onChange={(e) => setApiUrl(e.target.value)}
|
onChange={(e) => setApiUrl(e.target.value)}
|
||||||
placeholder="https://api.example.com/v1/messages"
|
placeholder="https://api.example.com/v1"
|
||||||
aria-invalid={!!validationErrors.apiUrl}
|
aria-invalid={!!validationErrors.apiUrl}
|
||||||
aria-describedby={validationErrors.apiUrl ? 'api-url-error' : undefined}
|
aria-describedby={validationErrors.apiUrl ? 'api-url-error' : undefined}
|
||||||
className={validationErrors.apiUrl ? 'border-red-500' : ''}
|
className={validationErrors.apiUrl ? 'border-red-500' : ''}
|
||||||
|
|||||||
Reference in New Issue
Block a user