diff --git a/src/components/Common/Playground/EditMessageForm.tsx b/src/components/Common/Playground/EditMessageForm.tsx index e864e1c..e818f24 100644 --- a/src/components/Common/Playground/EditMessageForm.tsx +++ b/src/components/Common/Playground/EditMessageForm.tsx @@ -49,13 +49,13 @@ export const EditMessageForm = (props: Props) => {
diff --git a/src/components/Option/Models/AddOllamaModelModal.tsx b/src/components/Option/Models/AddOllamaModelModal.tsx new file mode 100644 index 0000000..dd2bd01 --- /dev/null +++ b/src/components/Option/Models/AddOllamaModelModal.tsx @@ -0,0 +1,67 @@ +import { useForm } from "@mantine/form" +import { useMutation } from "@tanstack/react-query" +import { Input, Modal, notification } from "antd" +import { Download } from "lucide-react" +import { useTranslation } from "react-i18next" + +type Props = { + open: boolean + setOpen: (open: boolean) => void +} + +export const AddOllamaModelModal: React.FC = ({ open, setOpen }) => { + const { t } = useTranslation(["settings", "common", "openai"]) + + const form = useForm({ + initialValues: { + model: "" + } + }) + + const pullModel = async (modelName: string) => { + notification.info({ + message: t("manageModels.notification.pullModel"), + description: t("manageModels.notification.pullModelDescription", { + modelName + }) + }) + + setOpen(false) + + form.reset() + + browser.runtime.sendMessage({ + type: "pull_model", + modelName + }) + + return true + } + + const { mutate: pullOllamaModel } = useMutation({ + mutationFn: pullModel + }) + return ( + setOpen(false)}> +
pullOllamaModel(values.model))}> + + + +
+
+ ) +} diff --git a/src/components/Option/Models/index.tsx b/src/components/Option/Models/index.tsx index bd14c30..b2cab08 100644 --- a/src/components/Option/Models/index.tsx +++ b/src/components/Option/Models/index.tsx @@ -1,18 +1,11 @@ -import { useMutation, } from "@tanstack/react-query" -import { - notification, - Modal, - Input, - Segmented -} from "antd" +import { Segmented } from "antd" import dayjs from "dayjs" import relativeTime from "dayjs/plugin/relativeTime" import { useState } from "react" -import { useForm } from "@mantine/form" -import { Download } from "lucide-react" import { useTranslation } from "react-i18next" import { OllamaModelsTable } from "./OllamaModelsTable" import { CustomModelsTable } from "./CustomModelsTable" +import { AddOllamaModelModal } from "./AddOllamaModelModal" dayjs.extend(relativeTime) @@ -22,36 +15,6 @@ export const ModelsBody = () => { const { t } = useTranslation(["settings", "common", "openai"]) - const form = useForm({ - initialValues: { - model: "" - } - }) - - const pullModel = async (modelName: string) => { - notification.info({ - message: t("manageModels.notification.pullModel"), - description: t("manageModels.notification.pullModelDescription", { - modelName - }) - }) - - setOpen(false) - - form.reset() - - browser.runtime.sendMessage({ - type: "pull_model", - modelName - }) - - return true - } - - const { mutate: pullOllamaModel } = useMutation({ - mutationFn: pullModel - }) - return (
@@ -60,7 +23,11 @@ export const ModelsBody = () => {
@@ -88,28 +55,7 @@ export const ModelsBody = () => { {segmented === "ollama" ? : }
- setOpen(false)}> -
pullOllamaModel(values.model))}> - - - -
-
+
) } diff --git a/src/db/models.ts b/src/db/models.ts index e985472..c9d294d 100644 --- a/src/db/models.ts +++ b/src/db/models.ts @@ -10,6 +10,7 @@ type Model = { name: string provider_id: string lookup: string + model_type: string db_type: string } export const generateID = () => { @@ -140,7 +141,8 @@ export const createManyModels = async ( lookup: `${item.model_id}_${item.provider_id}`, id: `${item.model_id}_${generateID()}`, db_type: "openai_model", - name: item.name.replaceAll(/accounts\/[^\/]+\/models\//g, "") + name: item.name.replaceAll(/accounts\/[^\/]+\/models\//g, ""), + model_type: "chat" } }) @@ -168,7 +170,8 @@ export const createModel = async ( name, provider_id, lookup: `${model_id}_${provider_id}`, - db_type: "openai_model" + db_type: "openai_model", + model_type: "chat" } await db.create(model) return model diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 4b3826a..6ee62a9 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -41,11 +41,6 @@ i18n de: de }, fallbackLng: "en", - detection: { - order: ['localStorage', 'navigator'], - caches: ['localStorage'] - }, - supportedLngs: supportedLanguages, lng: localStorage.getItem("i18nextLng") || "en", });