|
5 | 5 | showSettings, |
6 | 6 | DEFAULT_SYSTEM_MESSAGE, |
7 | 7 | db, |
| 8 | + getOpenAi, |
| 9 | + chatModels, |
8 | 10 | } from "$lib/stores/stores"; |
9 | 11 | import { DB_NAME } from "$lib/constants"; |
10 | 12 | import AutosizeTextarea from "./AutosizeTextarea.svelte"; |
|
13 | 15 | import { ChatMessage, Thread } from "$lib/db"; |
14 | 16 | import { mapKeys, toCamelCase } from "$lib/utils"; |
15 | 17 | import CloseButton from "./CloseButton.svelte"; |
| 18 | + import type OpenAI from "openai"; |
16 | 19 |
|
17 | 20 | let schema; |
18 | 21 | let migrationVersion; |
|
21 | 24 | ?.map((x) => x.sql) |
22 | 25 | ?.filter((x) => !x.includes("sqlite_") && !x.includes("crsql")); |
23 | 26 | migrationVersion = (await $db?.execA<number[]>(`PRAGMA user_version`))?.[0]; |
| 27 | + |
| 28 | + if (!$chatModels.length) { |
| 29 | + const openai = getOpenAi(); |
| 30 | + const xs = await openai.models.list(); |
| 31 | + $chatModels = xs.data |
| 32 | + .filter((x) => x.id.startsWith("gpt")) |
| 33 | + .sort((a, b) => a.id.localeCompare(b.id)); |
| 34 | + } |
24 | 35 | }); |
25 | 36 | let showAdvanced = false; |
26 | 37 | </script> |
|
96 | 107 | <label for="a" class="label"> Model: </label> |
97 | 108 | <div class:info={$gptProfileStore.model === "gpt-4"}> |
98 | 109 | <select id="a" class="input rounded w-full" bind:value={$gptProfileStore.model}> |
99 | | - <option value="gpt-3.5-turbo">gpt-3.5-turbo</option> |
100 | | - <option value="gpt-3.5-turbo-16k">gpt-3.5-turbo-16k</option> |
101 | | - <option value="gpt-4">gpt-4</option> |
| 110 | + {#each $chatModels as model} |
| 111 | + <option value={model.id}>{model.id}</option> |
| 112 | + {/each} |
102 | 113 | </select> |
103 | 114 | {#if $gptProfileStore.model === "gpt-4"} |
104 | 115 | <p> |
|
0 commit comments