diff --git a/ui/src/model-manager/missing-models-drawer/MissingModelItem.tsx b/ui/src/model-manager/missing-models-drawer/MissingModelItem.tsx
new file mode 100644
index 0000000..25f17b8
--- /dev/null
+++ b/ui/src/model-manager/missing-models-drawer/MissingModelItem.tsx
@@ -0,0 +1,89 @@
+import { GridItem, VStack, Button, Text } from "@chakra-ui/react";
+import { IconExternalLink } from "@tabler/icons-react";
+import { useEffect, useState } from "react";
+
+export interface MissingModel {
+ class_type: string;
+ input_name: string;
+ received_value: string;
+}
+
+interface Props {
+ model: MissingModel;
+}
+
+export default function MissingModelItem({ model }: Props) {
+ const [suggestedUrls, setSuggestedUrls] = useState<{ url: string, name: string }[]>([]);
+ const modelName = formatSearchQuery(model.received_value);
+ const getSearchData = async () => {
+ // huggingface search
+ const hfData = await fetch(`https://huggingface.co/api/models?limit=3&search=${modelName}`);
+ const hfSearchResult = await hfData.json() as { id: string; modelId: string }[];
+ const hfUrls = hfSearchResult.map(({ modelId }) => ({ name: `${modelId.split('/')[1]} on HuggingFace`, url: `https://huggingface.co/${modelId}` }));
+ console.log(modelName, "hf", hfSearchResult, hfUrls);
+ // civitai search
+ const civitaiData = await fetch(`https://civitai.com/api/v1/models?limit=3&query=${modelName}`);
+ const civitaiSearchResult = await civitaiData.json() as { items: { id: string, name: string }[] };
+ const civitaiUrls = civitaiSearchResult.items?.map(({ name, id }) => ({ name: `${name} on civitAI`, url: `https://civitai.com/models/${id}` })) ?? [];
+ console.log(modelName, "civitai", civitaiSearchResult, civitaiUrls);
+ // set suggested urls
+ setSuggestedUrls([...hfUrls, ...civitaiUrls]);
+ };
+ useEffect(() => {
+ getSearchData();
+ }, [model]);
+
+ console.log(suggestedUrls);
+
+ return (
+
+
+ {model.class_type}
+ Input:
+ {model.input_name}
+ Received Value:
+ {model.received_value}
+ {suggestedUrls.map(({ url, name }) => (
+ }
+ size={"sm"}
+ onClick={() => {
+ window.open(url, "_blank");
+ }}
+ >
+ {name}
+
+ ))}
+ }
+ size={"sm"}
+ onClick={() => {
+ window.open(
+ `https://civitai.com/search/models?sortBy=models_v5&query=${modelName}`,
+ "_blank",
+ );
+ }}
+ >
+ Search in CivitAI
+
+
+
+ );
+}
+
+function formatSearchQuery(query: string): string {
+ return query
+ // Remove file extension
+ .replace(/\.[^/.]+$/, "")
+ // Replace special characters with space
+ .replace(/[^a-zA-Z0-9]/g, " ")
+ // Add space before capital letters
+ .replace(/([A-Z])/g, " $1")
+ .trim();
+}
\ No newline at end of file
diff --git a/ui/src/model-manager/missing-models-drawer/MissingModelsListDrawer.tsx b/ui/src/model-manager/missing-models-drawer/MissingModelsListDrawer.tsx
index 8c5ad0a..f218a04 100644
--- a/ui/src/model-manager/missing-models-drawer/MissingModelsListDrawer.tsx
+++ b/ui/src/model-manager/missing-models-drawer/MissingModelsListDrawer.tsx
@@ -1,22 +1,17 @@
import {
Box,
- Button,
Card,
CardHeader,
Flex,
Grid,
- GridItem,
Heading,
Portal,
- Text,
- VStack,
} from "@chakra-ui/react";
-import { useEffect, useState } from "react";
+import { useEffect } from "react";
// @ts-ignore
import { app } from "/scripts/app.js";
import InstallModelsButton from "../install-models/InstallModelsButton";
-import InatallModelsModal from "../install-models/InatallModelsModal";
-import { IconExternalLink } from "@tabler/icons-react";
+import MissingModelItem from "./MissingModelItem";
export interface MissingModel {
class_type: string;
@@ -33,9 +28,6 @@ export default function MissingModelsListDrawer({
onClose,
missingModels,
}: Props) {
- const [showInstallModels, setShowInstallModels] = useState(false);
- const [searchQuery, setSearchQuery] = useState("");
-
useEffect(() => {
app.canvasEl.addEventListener("click", onClose);
return () => {
@@ -46,81 +38,33 @@ export default function MissingModelsListDrawer({
const DRAWER_WIDTH = 440;
return (
- <>
-
-
-
-
-
-
- Models
-
-
-
-
-
- {missingModels.map((model) => {
- return (
-
-
- {model.class_type}
- Input:
- {model.input_name}
- Received Value:
- {model.received_value}
-
- }
- size={"sm"}
- onClick={() => {
- window.open(
- `https://civitai.com/search/models?sortBy=models_v5&query=${formatSearchQuery(model.received_value)}`,
- "_blank",
- );
- }}
- >
- Search in CivitAI
-
-
- );
- })}
-
-
-
-
- {showInstallModels && (
- setShowInstallModels(false)}
- />
- )}
- >
+
+
+
+
+
+
+ Models
+
+
+
+
+
+ {missingModels.map((model) => )}
+
+
+
+
);
}
-
-function formatSearchQuery(query: string): string {
- // Remove file extension
- let formattedQuery = query
- .replace(/\.[^/.]+$/, "")
- // Replace special characters with space
- // .replace(/[^a-zA-Z0-9]/g, " ")
- // Add space before capital letters
- // .replace(/([A-Z])/g, " $1")
- .trim();
-
- return formattedQuery;
-}
diff --git a/ui/src/model-manager/topbar/ModelManagerTopbar.tsx b/ui/src/model-manager/topbar/ModelManagerTopbar.tsx
index 0dc41d8..a85d2d4 100644
--- a/ui/src/model-manager/topbar/ModelManagerTopbar.tsx
+++ b/ui/src/model-manager/topbar/ModelManagerTopbar.tsx
@@ -1,11 +1,10 @@
import { Box, Button, HStack } from "@chakra-ui/react";
-import { useEffect, useState, DragEvent } from "react";
-import React from "react";
+import { lazy, useEffect, useState, DragEvent } from "react";
import ModelsListDrawer from "../models-list-drawer/ModelsListDrawer";
// @ts-ignore
import { app } from "/scripts/app.js";
-const AddMissingModelsButton = React.lazy(
+const AddMissingModelsButton = lazy(
() => import("./InstallMissingModelsButton"),
);
interface Props {}