refac: azure openai

This commit is contained in:
Timothy Jaeryang Baek
2025-05-19 04:31:04 +04:00
parent 2f2a7ee0b0
commit 2ab5aa4d34
4 changed files with 40 additions and 28 deletions

View File

@@ -33,7 +33,7 @@
let connectionType = 'external';
let azure = false;
$: azure =
(url.includes('openai.azure.com') || url.includes('cognitive.microsoft.com')) && !direct
(url.includes('azure.com') || url.includes('cognitive.microsoft.com')) && !direct
? true
: false;
@@ -106,6 +106,28 @@
return;
}
if (azure) {
if (!apiVersion) {
loading = false;
toast.error('API Version is required');
return;
}
if (!key) {
loading = false;
toast.error('Key is required');
return;
}
if (modelIds.length === 0) {
loading = false;
toast.error('Deployment names are required');
return;
}
}
// remove trailing slash from url
url = url.replace(/\/$/, '');
@@ -149,6 +171,7 @@
} else {
connectionType = connection.config?.connection_type ?? 'external';
azure = connection.config?.azure ?? false;
apiVersion = connection.config?.api_version ?? '';
}
}
};
@@ -382,9 +405,10 @@
url: url
})}
{:else if azure}
{$i18n.t('Leave empty to include all models from "{{url}}" endpoint', {
{$i18n.t('Deployment names are required for Azure OpenAI.')}
<!-- {$i18n.t('Leave empty to include all models from "{{url}}" endpoint', {
url: `${url}/openai/deployments`
})}
})} -->
{:else}
{$i18n.t('Leave empty to include all models from "{{url}}/models" endpoint', {
url: url
@@ -394,7 +418,7 @@
{/if}
</div>
<hr class=" border-gray-100 dark:border-gray-700/10 my-2.5 w-full" />
<hr class=" border-gray-100 dark:border-gray-700/10 my-1.5 w-full" />
<div class="flex items-center">
<input

View File

@@ -62,7 +62,7 @@
class="absolute top-0 bottom-0 left-0 right-0 opacity-60 bg-white dark:bg-gray-900 z-10"
></div>
{/if}
<div class="flex w-full">
<div class="flex w-full gap-2">
<div class="flex-1 relative">
<input
class=" outline-hidden w-full bg-transparent {pipeline ? 'pr-8' : ''}"

View File

@@ -62,7 +62,7 @@
class="absolute top-0 bottom-0 left-0 right-0 opacity-60 bg-white dark:bg-gray-900 z-10"
></div>
{/if}
<div class="flex w-full">
<div class="flex w-full gap-2">
<div class="flex-1 relative">
<input
class=" outline-hidden w-full bg-transparent {pipeline ? 'pr-8' : ''}"