- Move svg-export-{defs,paths}.ts into svg-export/ folder
(defs.ts, paths.ts, index.ts) instead of prefix-based split
- Remove duplicate getChildren lambda in fig-import.ts importPages
- Remove dead dashPattern local in kiwi-convert.ts nodeChangeToProps
- Restore useful explanatory comments in instance-overrides.ts
(DSD propagation, direct vs cloned assignments, seed skipping)
- Rename applyEffectOverrides → applyShapeAndEffectOverrides
(handles polygon props + shadow + blur, not just effects)
- Format src/ with oxfmt
96 lines
2.8 KiB
Vue
96 lines
2.8 KiB
Vue
<script setup lang="ts">
|
|
import { ref } from 'vue'
|
|
|
|
import ProviderSelect from '@/components/chat/ProviderSelect.vue'
|
|
import { uiInput } from '@/components/ui/input'
|
|
import { useAIChat } from '@/composables/use-chat'
|
|
|
|
const { providerID, providerDef, setAPIKey, customBaseURL, customModelID } = useAIChat()
|
|
|
|
const keyInput = ref('')
|
|
const baseURLInput = ref(customBaseURL.value)
|
|
const customModelInput = ref(customModelID.value)
|
|
|
|
function save() {
|
|
const key = keyInput.value.trim()
|
|
if (!key) return
|
|
if (providerDef.value.supportsCustomBaseURL) {
|
|
customBaseURL.value = baseURLInput.value.trim()
|
|
}
|
|
if (providerDef.value.supportsCustomModel) {
|
|
customModelID.value = customModelInput.value.trim()
|
|
}
|
|
setAPIKey(key)
|
|
keyInput.value = ''
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div data-test-id="provider-setup" class="flex flex-1 flex-col items-center justify-center px-6">
|
|
<icon-lucide-sparkles class="mb-3 size-7 text-muted" />
|
|
<p class="mb-5 text-center text-xs text-muted">Connect an AI provider to start chatting.</p>
|
|
|
|
<form class="flex w-full flex-col gap-2" @submit.prevent="save">
|
|
<ProviderSelect
|
|
test-id="provider-selector"
|
|
trigger-class="w-full justify-between rounded border border-border bg-input px-2.5 py-1.5 text-xs text-surface"
|
|
item-class="rounded px-2 py-1.5 text-[11px]"
|
|
/>
|
|
|
|
<!-- Base URL (OpenAI-compatible only) -->
|
|
<input
|
|
v-if="providerDef.supportsCustomBaseURL"
|
|
v-model="baseURLInput"
|
|
type="text"
|
|
data-test-id="provider-base-url"
|
|
placeholder="Base URL (e.g. http://localhost:11434/v1)"
|
|
:class="uiInput()"
|
|
/>
|
|
|
|
<!-- Custom model ID (OpenAI-compatible only) -->
|
|
<input
|
|
v-if="providerDef.supportsCustomModel"
|
|
v-model="customModelInput"
|
|
type="text"
|
|
data-test-id="provider-custom-model"
|
|
placeholder="Model ID (e.g. llama-3.3-70b)"
|
|
:class="uiInput()"
|
|
/>
|
|
|
|
<input
|
|
v-model="keyInput"
|
|
type="password"
|
|
data-test-id="api-key-input"
|
|
:placeholder="providerDef.keyPlaceholder"
|
|
:class="uiInput()"
|
|
/>
|
|
|
|
<button
|
|
type="submit"
|
|
data-test-id="api-key-save"
|
|
class="mt-1 w-full rounded bg-accent py-1.5 text-xs font-medium text-white hover:bg-accent/90"
|
|
:disabled="!keyInput.trim()"
|
|
>
|
|
Connect
|
|
</button>
|
|
</form>
|
|
|
|
<a
|
|
v-if="providerDef.keyURL"
|
|
:href="providerDef.keyURL"
|
|
target="_blank"
|
|
data-test-id="api-key-get-link"
|
|
class="mt-2.5 text-[10px] text-muted underline hover:text-surface"
|
|
>
|
|
Get an {{ providerDef.name }} API key →
|
|
</a>
|
|
|
|
<p
|
|
v-if="providerID === 'openrouter'"
|
|
class="mt-3 text-center text-[10px] leading-relaxed text-muted/50"
|
|
>
|
|
One key for 100+ models from all providers.
|
|
</p>
|
|
</div>
|
|
</template>
|