瀏覽代碼

feat: azure openai connections ui

Timothy Jaeryang Baek 4 月之前
父節點
當前提交
47f8b3500b
共有 1 個文件被更改,包括 33 次插入1 次删除
  1. 33 1
      src/lib/components/AddConnectionModal.svelte

+ 33 - 1
src/lib/components/AddConnectionModal.svelte

@@ -32,9 +32,13 @@
 
 	let connectionType = 'external';
 	let azure = false;
+	$: azure =
+		url.includes('openai.azure.com') || url.includes('cognitive.microsoft.com') ? true : false;
 
 	let prefixId = '';
 	let enable = true;
+	let apiVersion = '';
+
 	let tags = [];
 
 	let modelId = '';
@@ -100,7 +104,7 @@
 				prefix_id: prefixId,
 				model_ids: modelIds,
 				connection_type: connectionType,
-				...(!ollama && azure ? { azure: true } : {})
+				...(!ollama && azure ? { azure: true, api_version: apiVersion } : {})
 			}
 		};
 
@@ -286,6 +290,27 @@
 							</div>
 						</div>
 
+						{#if azure}
+							<div class="flex gap-2 mt-2">
+								<div class="flex flex-col w-full">
+									<div class=" mb-1 text-xs text-gray-500">{$i18n.t('API Version')}</div>
+
+									<div class="flex-1">
+										<Tooltip content={$i18n.t('Specify the API version to use')}>
+											<input
+												class="w-full text-sm bg-transparent placeholder:text-gray-300 dark:placeholder:text-gray-700 outline-hidden"
+												type="text"
+												bind:value={apiVersion}
+												placeholder={$i18n.t('API Version')}
+												autocomplete="off"
+												required
+											/>
+										</Tooltip>
+									</div>
+								</div>
+							</div>
+						{/if}
+
 						<div class="flex gap-2 mt-2">
 							<div class="flex flex-col w-full">
 								<div class=" mb-1.5 text-xs text-gray-500">{$i18n.t('Tags')}</div>
@@ -342,6 +367,13 @@
 										{$i18n.t('Leave empty to include all models from "{{url}}/api/tags" endpoint', {
 											url: url
 										})}
+									{:else if azure}
+										{$i18n.t(
+											'Leave empty to include all models from "{{url}}/openai/deployments" endpoint',
+											{
+												url: url
+											}
+										)}
 									{:else}
 										{$i18n.t('Leave empty to include all models from "{{url}}/models" endpoint', {
 											url: url