Skip to content

Commit

Permalink
Merge pull request #24 from goodguysarvagya/main
Browse files Browse the repository at this point in the history
Redesigned the model component.
  • Loading branch information
AndriyMulyar authored Oct 21, 2023
2 parents 45ff981 + fc4a1e8 commit 363c3bb
Show file tree
Hide file tree
Showing 19 changed files with 463 additions and 431 deletions.
180 changes: 90 additions & 90 deletions frontend/gpt4all.io/package-lock.json

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file removed frontend/gpt4all.io/public/code_still.png
Binary file not shown.
Binary file added frontend/gpt4all.io/public/code_still.webp
Binary file not shown.
Binary file removed frontend/gpt4all.io/public/gpt4all-128.png
Binary file not shown.
Binary file added frontend/gpt4all.io/public/gpt4all-128.webp
Binary file not shown.
Binary file removed frontend/gpt4all.io/public/nomic_logo.png
Binary file not shown.
Binary file added frontend/gpt4all.io/public/nomic_logo.webp
Binary file not shown.
Binary file removed frontend/gpt4all.io/public/poem_still.png
Binary file not shown.
Binary file added frontend/gpt4all.io/public/poem_still.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed frontend/gpt4all.io/public/roman_gpt4all_still.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
578 changes: 313 additions & 265 deletions frontend/gpt4all.io/src/App.js

Large diffs are not rendered by default.

136 changes: 60 additions & 76 deletions frontend/gpt4all.io/src/components/models.jsx
Original file line number Diff line number Diff line change
@@ -1,88 +1,72 @@
import React, { useState, useEffect } from "react";
import * as DOMPurify from "dompurify";
import { ArrowBigDownDash } from "lucide-react";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "./ui/select";

const getModels = async () => {
const response = await fetch("https://gpt4all.io/models/models2.json");
const jsonData = await response.json();
return jsonData;
}
const response = await fetch("https://gpt4all.io/models/models2.json");
//const response = await fetch(
//"https://raw.githubusercontent.com/nomic-ai/gpt4all/main/gpt4all-chat/metadata/models.json"
//);
const jsonData = await response.json();
return jsonData;
};

const ModelsTable = () =>
{
const [models, setModels] = useState([]);
const [selectedModel, setSelectedModel] = useState({});
const ModelsTable = () => {
const [models, setModels] = useState([]);

// TODO: handle errors
useEffect(() => {
async function fetchData() {
const modelData = await getModels();
setModels(modelData);
setSelectedModel(modelData[0]);
}
fetchData();
}, []);

const onSelect = (val) => {
models.forEach((obj,idx) => {

if(obj.filename === val) {
setSelectedModel(models[idx]);
}
});
useEffect(() => {
async function fetchData() {
const modelData = await getModels();
setModels(modelData);
}
fetchData();
}, []);

return (
<div className="flex flex-col justify-center gap-4 mx-auto">
<h2 className="text-4xl font-bold text-center mb-2">Model Explorer</h2>
<Select onValueChange={onSelect}>
<SelectTrigger className="w-[300px] sm:w-[400px] mx-auto">
<SelectValue placeholder={models[0] && models[0].filename}/>
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>Model Explorer</SelectLabel>
{
models.map((obj, idx) =>
<SelectItem value={obj.filename} key={idx}>{obj.filename}</SelectItem>
)
}
</SelectGroup>
</SelectContent>
</Select>

<div className="w-[600px] sm:w-[800px] py-4 border-t border-b border-dashed flex justify-center relative">
<div className="absolute top-0 left-0 w-[600px] border-l border-r border-dashed translate-x-24 -translate-y-4 h-72"></div>
<div className="w-[350px] sm:w-[400px] min-h-64 sm:min-h-56 relative p-4 rounded-md border shadow-md">
<div className="w-full h-full rounded-md bg-white p-4 flex flex-col relative">
<div className="border-b pb-2 mb-2">
<h4 className="text-xl font-bold">{selectedModel.filename}</h4>
</div>
return (
<div className="flex flex-col justify-center gap-4 mx-auto">
<div className="flex justify-end mt-4"></div>
<h2 className="text-4xl font-bold text-center mb-2">Model Explorer</h2>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
{models.map((model, idx) => (
<div
key={idx}
className="rounded-xl bg-white dark:bg-gray-800 p-4 border dark:border-gray-600 shadow-md flex flex-col justify-between hover:shadow-xl"
>
<div className="mt-0">
<span className="inline-block bg-red-300 rounded-sm px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">
SIZE: {(model.filesize / 1024 ** 3).toFixed(2)} GB
</span>
<span className="inline-block bg-blue-300 rounded-sm px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">
RAM: {model.ramrequired} GB
</span>
</div>
<div>
<h4 className="text-xl font-bold mb-2">{model.filename}</h4>
<div
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(model.description),
}}
className="text-gray-600 mb-2"
/>
</div>

<div dangerouslySetInnerHTML={
{
__html: DOMPurify.sanitize(selectedModel.description)
}
}/>

<a className="place-self-end" href={'url' in selectedModel ? `${selectedModel.url}` : `https://gpt4all.io/models/${selectedModel.filename}`}>
<ArrowBigDownDash className="w-6 h-6"/>
</a>

</div>
</div>
<div className="mt-3">
<a
className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 mr-2 mb-2"
href={
"url" in model
? `${model.url}`
: `https://gpt4all.io/models/${model.filename}`
}
>
Download <ArrowBigDownDash className="w-4 h-6 inline" />
</a>
</div>
</div>
)
}
</div>
))}
</div>
</div>
);
};

export default ModelsTable;
export default ModelsTable;

0 comments on commit 363c3bb

Please sign in to comment.