|
@@ -14,6 +14,8 @@
|
|
import Plus from '$lib/components/icons/Plus.svelte';
|
|
import Plus from '$lib/components/icons/Plus.svelte';
|
|
import Connection from './Connections/Connection.svelte';
|
|
import Connection from './Connections/Connection.svelte';
|
|
|
|
|
|
|
|
+ import AddConnectionModal from '$lib/components/AddConnectionModal.svelte';
|
|
|
|
+
|
|
const getModels = async () => {
|
|
const getModels = async () => {
|
|
const models = await _getModels(localStorage.token);
|
|
const models = await _getModels(localStorage.token);
|
|
return models;
|
|
return models;
|
|
@@ -25,82 +27,73 @@
|
|
|
|
|
|
onMount(async () => {});
|
|
onMount(async () => {});
|
|
|
|
|
|
|
|
+ const addConnectionHandler = async (connection) => {};
|
|
|
|
+
|
|
const submitHandler = async () => {};
|
|
const submitHandler = async () => {};
|
|
const updateHandler = async () => {};
|
|
const updateHandler = async () => {};
|
|
</script>
|
|
</script>
|
|
|
|
|
|
-<!-- <AddConnectionModal
|
|
|
|
- bind:show={showConnectionModal}
|
|
|
|
- onSubmit={addConnectionHandler}
|
|
|
|
-/> -->
|
|
|
|
|
|
+<AddConnectionModal direct bind:show={showConnectionModal} onSubmit={addConnectionHandler} />
|
|
|
|
|
|
<form class="flex flex-col h-full justify-between text-sm" on:submit|preventDefault={submitHandler}>
|
|
<form class="flex flex-col h-full justify-between text-sm" on:submit|preventDefault={submitHandler}>
|
|
<div class=" overflow-y-scroll scrollbar-hidden h-full">
|
|
<div class=" overflow-y-scroll scrollbar-hidden h-full">
|
|
<div class="my-2">
|
|
<div class="my-2">
|
|
- <div class="space-y-2 pr-1.5">
|
|
|
|
- <div class="flex justify-between items-center text-sm">
|
|
|
|
- <div class=" font-medium">{$i18n.t('Direct Connections')}</div>
|
|
|
|
|
|
+ <div class="pr-1.5">
|
|
|
|
+ <div class="">
|
|
|
|
+ <div class="flex justify-between items-center">
|
|
|
|
+ <div class="font-medium">{$i18n.t('Manage Direct Connections')}</div>
|
|
|
|
+
|
|
|
|
+ <Tooltip content={$i18n.t(`Add Connection`)}>
|
|
|
|
+ <button
|
|
|
|
+ class="px-1"
|
|
|
|
+ on:click={() => {
|
|
|
|
+ showConnectionModal = true;
|
|
|
|
+ }}
|
|
|
|
+ type="button"
|
|
|
|
+ >
|
|
|
|
+ <Plus />
|
|
|
|
+ </button>
|
|
|
|
+ </Tooltip>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="flex flex-col gap-1.5 mt-1.5">
|
|
|
|
+ {#each config?.OPENAI_API_BASE_URLS ?? [] as url, idx}
|
|
|
|
+ <Connection
|
|
|
|
+ bind:url
|
|
|
|
+ bind:key={config.OPENAI_API_KEYS[idx]}
|
|
|
|
+ bind:config={config.OPENAI_API_CONFIGS[idx]}
|
|
|
|
+ onSubmit={() => {
|
|
|
|
+ updateHandler();
|
|
|
|
+ }}
|
|
|
|
+ onDelete={() => {
|
|
|
|
+ config.OPENAI_API_BASE_URLS = config.OPENAI_API_BASE_URLS.filter(
|
|
|
|
+ (url, urlIdx) => idx !== urlIdx
|
|
|
|
+ );
|
|
|
|
+ config.OPENAI_API_KEYS = config.OPENAI_API_KEYS.filter(
|
|
|
|
+ (key, keyIdx) => idx !== keyIdx
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let newConfig = {};
|
|
|
|
+ config.OPENAI_API_BASE_URLS.forEach((url, newIdx) => {
|
|
|
|
+ newConfig[newIdx] =
|
|
|
|
+ config.OPENAI_API_CONFIGS[newIdx < idx ? newIdx : newIdx + 1];
|
|
|
|
+ });
|
|
|
|
+ config.OPENAI_API_CONFIGS = newConfig;
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
|
|
+ {/each}
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
+ <hr class=" border-gray-50 dark:border-gray-850" />
|
|
|
|
+
|
|
<div class="mt-1.5">
|
|
<div class="mt-1.5">
|
|
<div class="text-xs text-gray-500">
|
|
<div class="text-xs text-gray-500">
|
|
{$i18n.t('Connect to your own OpenAI compatible API endpoints.')}
|
|
{$i18n.t('Connect to your own OpenAI compatible API endpoints.')}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
- {#if false}
|
|
|
|
- <hr class=" border-gray-50 dark:border-gray-850" />
|
|
|
|
-
|
|
|
|
- <div class="">
|
|
|
|
- <div class="flex justify-between items-center">
|
|
|
|
- <div class="font-medium">{$i18n.t('Manage Connections')}</div>
|
|
|
|
-
|
|
|
|
- <Tooltip content={$i18n.t(`Add Connection`)}>
|
|
|
|
- <button
|
|
|
|
- class="px-1"
|
|
|
|
- on:click={() => {
|
|
|
|
- showConnectionModal = true;
|
|
|
|
- }}
|
|
|
|
- type="button"
|
|
|
|
- >
|
|
|
|
- <Plus />
|
|
|
|
- </button>
|
|
|
|
- </Tooltip>
|
|
|
|
- </div>
|
|
|
|
-
|
|
|
|
- <div class="flex flex-col gap-1.5 mt-1.5">
|
|
|
|
- {#each config?.OPENAI_API_BASE_URLS ?? [] as url, idx}
|
|
|
|
- <Connection
|
|
|
|
- bind:url
|
|
|
|
- bind:key={config.OPENAI_API_KEYS[idx]}
|
|
|
|
- bind:config={config.OPENAI_API_CONFIGS[idx]}
|
|
|
|
- onSubmit={() => {
|
|
|
|
- updateHandler();
|
|
|
|
- }}
|
|
|
|
- onDelete={() => {
|
|
|
|
- config.OPENAI_API_BASE_URLS = config.OPENAI_API_BASE_URLS.filter(
|
|
|
|
- (url, urlIdx) => idx !== urlIdx
|
|
|
|
- );
|
|
|
|
- config.OPENAI_API_KEYS = config.OPENAI_API_KEYS.filter(
|
|
|
|
- (key, keyIdx) => idx !== keyIdx
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- let newConfig = {};
|
|
|
|
- config.OPENAI_API_BASE_URLS.forEach((url, newIdx) => {
|
|
|
|
- newConfig[newIdx] =
|
|
|
|
- config.OPENAI_API_CONFIGS[newIdx < idx ? newIdx : newIdx + 1];
|
|
|
|
- });
|
|
|
|
- config.OPENAI_API_CONFIGS = newConfig;
|
|
|
|
- }}
|
|
|
|
- />
|
|
|
|
- {/each}
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- {/if}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
- <hr class=" border-gray-50 dark:border-gray-850" />
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="flex justify-end pt-3 text-sm font-medium">
|
|
<div class="flex justify-end pt-3 text-sm font-medium">
|