Skip to content

Commit 25c844d

Browse files
gary149nsarrazin
andauthored
Models page (#849)
* add models page * add logo * models discussion * add default hint * Update +page.svelte * mishig review * fix typecheck --------- Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com>
1 parent bfec739 commit 25c844d

File tree

7 files changed

+98
-0
lines changed

7 files changed

+98
-0
lines changed

.env.template

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ MODELS=`[
44
{
55
"name" : "mistralai/Mixtral-8x7B-Instruct-v0.1",
66
"description" : "The latest MoE model from Mistral AI! 8x7B and outperforms Llama 2 70B in most benchmarks.",
7+
"logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/mistral-logo.png",
78
"websiteUrl" : "https://mistral.ai/news/mixtral-of-experts/",
89
"modelUrl": "https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1",
910
"preprompt" : "",
@@ -33,6 +34,7 @@ MODELS=`[
3334
{
3435
"name": "meta-llama/Llama-2-70b-chat-hf",
3536
"description": "The latest and biggest model from Meta, fine-tuned for chat.",
37+
"logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/meta-logo.png",
3638
"websiteUrl": "https://ai.meta.com/llama/",
3739
"modelUrl": "https://huggingface.co/meta-llama/Llama-2-70b-chat-hf",
3840
"preprompt": " ",
@@ -62,6 +64,7 @@ MODELS=`[
6264
{
6365
"name" : "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
6466
"description" : "Nous Hermes 2 Mixtral 8x7B DPO is the new flagship Nous Research model trained over the Mixtral 8x7B MoE LLM.",
67+
"logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/nous-logo.png",
6568
"websiteUrl" : "https://nousresearch.com/",
6669
"modelUrl": "https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
6770
"chatPromptTemplate" : "{{#if @root.preprompt}}<|im_start|>system\n{{@root.preprompt}}<|im_end|>\n{{/if}}{{#each messages}}{{#ifUser}}<|im_start|>user\n{{content}}<|im_end|>\n<|im_start|>assistant\n{{/ifUser}}{{#ifAssistant}}{{content}}<|im_end|>\n{{/ifAssistant}}{{/each}}",
@@ -91,6 +94,7 @@ MODELS=`[
9194
"name": "codellama/CodeLlama-70b-Instruct-hf",
9295
"displayName": "codellama/CodeLlama-70b-Instruct-hf",
9396
"description": "Code Llama, a state of the art code model from Meta. Now in 70B!",
97+
"logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/meta-logo.png",
9498
"websiteUrl": "https://ai.meta.com/blog/code-llama-large-language-model-coding/",
9599
"modelUrl": "https://huggingface.co/codellama/CodeLlama-70b-Instruct-hf",
96100
"preprompt": "",
@@ -121,6 +125,7 @@ MODELS=`[
121125
"name": "mistralai/Mistral-7B-Instruct-v0.1",
122126
"displayName": "mistralai/Mistral-7B-Instruct-v0.1",
123127
"description": "Mistral 7B is a new Apache 2.0 model, released by Mistral AI that outperforms Llama2 13B in benchmarks.",
128+
"logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/mistral-logo.png",
124129
"websiteUrl": "https://mistral.ai/news/announcing-mistral-7b/",
125130
"modelUrl": "https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1",
126131
"preprompt": "",
@@ -152,6 +157,7 @@ MODELS=`[
152157
"name": "mistralai/Mistral-7B-Instruct-v0.2",
153158
"displayName": "mistralai/Mistral-7B-Instruct-v0.2",
154159
"description": "Mistral 7B is a new Apache 2.0 model, released by Mistral AI that outperforms Llama2 13B in benchmarks.",
160+
"logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/mistral-logo.png",
155161
"websiteUrl": "https://mistral.ai/news/announcing-mistral-7b/",
156162
"modelUrl": "https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2",
157163
"preprompt": "",
@@ -182,6 +188,7 @@ MODELS=`[
182188
"name": "openchat/openchat-3.5-0106",
183189
"displayName": "openchat/openchat-3.5-0106",
184190
"description": "OpenChat 3.5 is the #1 model on MT-Bench, with only 7B parameters.",
191+
"logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/openchat-logo.png",
185192
"websiteUrl": "https://huggingface.co/openchat/openchat-3.5-0106",
186193
"modelUrl": "https://huggingface.co/openchat/openchat-3.5-0106",
187194
"preprompt": "",

src/lib/components/NavMenu.svelte

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import NavConversationItem from "./NavConversationItem.svelte";
99
import type { LayoutData } from "../../routes/$types";
1010
import type { ConvSidebar } from "$lib/types/ConvSidebar";
11+
import type { Model } from "$lib/types/Model";
1112
import { page } from "$app/stores";
1213
1314
export let conversations: ConvSidebar[] = [];
@@ -41,6 +42,8 @@
4142
month: "This month",
4243
older: "Older",
4344
} as const;
45+
46+
const nModels: number = $page.data.models.filter((el: Model) => !el.unlisted).length;
4447
</script>
4548

4649
<div class="sticky top-0 flex flex-none items-center justify-between px-3 py-3.5 max-sm:pt-0">
@@ -108,6 +111,18 @@
108111
>
109112
Theme
110113
</button>
114+
{#if nModels > 1}
115+
<a
116+
href="{base}/models"
117+
class="flex h-9 flex-none items-center gap-1.5 rounded-lg pl-2.5 pr-2 text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700"
118+
>
119+
Models
120+
<span
121+
class="ml-auto rounded-full border border-gray-300 px-2 py-0.5 text-xs text-gray-500 dark:border-gray-500 dark:text-gray-400"
122+
>{nModels}</span
123+
>
124+
</a>
125+
{/if}
111126
{#if $page.data.enableAssistants}
112127
<a
113128
href="{base}/assistants"

src/lib/server/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const modelConfig = z.object({
2525
name: z.string().default(""),
2626
displayName: z.string().min(1).optional(),
2727
description: z.string().min(1).optional(),
28+
logoUrl: z.string().url().optional(),
2829
websiteUrl: z.string().url().optional(),
2930
modelUrl: z.string().url().optional(),
3031
datasetName: z.string().min(1).optional(),

src/lib/types/Model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export type Model = Pick<
1010
| "promptExamples"
1111
| "parameters"
1212
| "description"
13+
| "logoUrl"
1314
| "modelUrl"
1415
| "datasetUrl"
1516
| "preprompt"

src/routes/+layout.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
149149
datasetUrl: model.datasetUrl,
150150
displayName: model.displayName,
151151
description: model.description,
152+
logoUrl: model.logoUrl,
152153
promptExamples: model.promptExamples,
153154
parameters: model.parameters,
154155
preprompt: model.preprompt,

src/routes/api/models/+server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export async function GET() {
1010
datasetUrl: model.datasetUrl,
1111
displayName: model.displayName,
1212
description: model.description,
13+
logoUrl: model.logoUrl,
1314
promptExamples: model.promptExamples,
1415
preprompt: model.preprompt,
1516
multimodal: model.multimodal,

src/routes/models/+page.svelte

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<script lang="ts">
2+
import type { PageData } from "./$types";
3+
4+
import { PUBLIC_APP_NAME } from "$env/static/public";
5+
import { isHuggingChat } from "$lib/utils/isHuggingChat";
6+
7+
import { base } from "$app/paths";
8+
import { page } from "$app/stores";
9+
10+
import CarbonHelpFilled from "~icons/carbon/help-filled";
11+
12+
export let data: PageData;
13+
</script>
14+
15+
<svelte:head>
16+
{#if isHuggingChat}
17+
<title>HuggingChat - Models</title>
18+
<meta property="og:title" content="HuggingChat - Models" />
19+
<meta property="og:type" content="link" />
20+
<meta property="og:description" content="Browse HuggingChat available models" />
21+
<meta property="og:url" content={$page.url.href} />
22+
{/if}
23+
</svelte:head>
24+
25+
<div class="scrollbar-custom mr-1 h-full overflow-y-auto py-12 md:py-24">
26+
<div class="pt-42 mx-auto flex flex-col px-5 xl:w-[60rem] 2xl:w-[64rem]">
27+
<div class="flex items-center">
28+
<h1 class="text-2xl font-bold">Models</h1>
29+
{#if isHuggingChat}
30+
<a
31+
href="https://huggingface.co/spaces/huggingchat/chat-ui/discussions/372"
32+
class="ml-auto dark:text-gray-400 dark:hover:text-gray-300"
33+
target="_blank"
34+
>
35+
<CarbonHelpFilled />
36+
</a>
37+
{/if}
38+
</div>
39+
<h3 class="text-gray-500">All models available on {PUBLIC_APP_NAME}</h3>
40+
<dl class="mt-8 grid grid-cols-1 gap-3 sm:gap-5 xl:grid-cols-2">
41+
{#each data.models.filter((el) => !el.unlisted) as model, index (model.id)}
42+
<a
43+
href="{base}/settings/{model.id}"
44+
class="relative flex flex-col gap-2 overflow-hidden rounded-xl border bg-gray-50/50 px-6 py-5 shadow hover:bg-gray-50 hover:shadow-inner dark:border-gray-800/70 dark:bg-gray-950/20 dark:hover:bg-gray-950/40"
45+
>
46+
<div class="flex items-center justify-between">
47+
{#if model.logoUrl}
48+
<img
49+
class=" overflown aspect-square size-6 rounded border dark:border-gray-700"
50+
src={model.logoUrl}
51+
alt=""
52+
/>
53+
{:else}
54+
<div class="size-6 rounded border border-transparent bg-gray-300 dark:bg-gray-800" />
55+
{/if}
56+
{#if index === 0}
57+
<div
58+
class="rounded-full border border-gray-300 px-2 py-0.5 text-xs text-gray-500 dark:border-gray-500 dark:text-gray-400"
59+
>
60+
Default
61+
</div>
62+
{/if}
63+
</div>
64+
<dt class="flex items-center gap-2 font-semibold">
65+
{model.displayName}
66+
</dt>
67+
<dd class="text-sm text-gray-500 dark:text-gray-400">{model.description || "-"}</dd>
68+
</a>
69+
{/each}
70+
</dl>
71+
</div>
72+
</div>

0 commit comments

Comments
 (0)