diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsx
index 33c6de5..113709c 100644
--- a/src/components/SettingsModal.tsx
+++ b/src/components/SettingsModal.tsx
@@ -1,9 +1,11 @@
import {
+ Alert,
Anchor,
Button,
- Group,
+ Flex,
List,
Modal,
+ Select,
Stack,
Text,
TextInput,
@@ -13,6 +15,7 @@ import { notifications } from "@mantine/notifications";
import { useLiveQuery } from "dexie-react-hooks";
import { cloneElement, ReactElement, useEffect, useState } from "react";
import { db } from "../db";
+import { availableModels, defaultModel } from "../utils/constants";
import { checkOpenAIKey } from "../utils/openai";
export function SettingsModal({ children }: { children: ReactElement }) {
@@ -20,14 +23,20 @@ export function SettingsModal({ children }: { children: ReactElement }) {
const [submitting, setSubmitting] = useState(false);
const [value, setValue] = useState("");
+ const [model, setModel] = useState(defaultModel);
- const apiKey = useLiveQuery(async () => {
- return (await db.settings.where({ id: "general" }).toArray())[0];
+ const settings = useLiveQuery(async () => {
+ return db.settings.where({ id: "general" }).first();
});
+
useEffect(() => {
- if (!apiKey?.openAiApiKey) return;
- setValue(apiKey.openAiApiKey);
- }, [apiKey]);
+ if (settings?.openAiApiKey) {
+ setValue(settings.openAiApiKey);
+ }
+ if (settings?.openAiModel) {
+ setModel(settings.openAiModel);
+ }
+ }, [settings]);
return (
<>
@@ -69,7 +78,7 @@ export function SettingsModal({ children }: { children: ReactElement }) {
}
}}
>
-
+
Save
-
+
@@ -101,6 +110,21 @@ export function SettingsModal({ children }: { children: ReactElement }) {
+