Spaces:
Sleeping
Sleeping
set/get model from query params
Browse files
src/lib/components/InferencePlayground/InferencePlayground.svelte
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
import type { ModelEntryWithTokenizer } from "./types";
|
| 3 |
import { type ChatCompletionInputMessage } from "@huggingface/tasks";
|
| 4 |
|
|
|
|
| 5 |
import { defaultGenerationConfig } from "./generationConfigSettings";
|
| 6 |
import {
|
| 7 |
createHfInference,
|
|
@@ -24,8 +25,11 @@
|
|
| 24 |
const startMessageUser: ChatCompletionInputMessage = { role: "user", content: "" };
|
| 25 |
const startMessageSystem: ChatCompletionInputMessage = { role: "system", content: "" };
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
let conversation: Conversation = {
|
| 28 |
-
model: models.find(m => FEATUED_MODELS_IDS.includes(m.id)) ?? models[0],
|
| 29 |
config: defaultGenerationConfig,
|
| 30 |
messages: [{ ...startMessageUser }],
|
| 31 |
systemMessage: startMessageSystem,
|
|
|
|
| 2 |
import type { ModelEntryWithTokenizer } from "./types";
|
| 3 |
import { type ChatCompletionInputMessage } from "@huggingface/tasks";
|
| 4 |
|
| 5 |
+
import { page } from "$app/stores";
|
| 6 |
import { defaultGenerationConfig } from "./generationConfigSettings";
|
| 7 |
import {
|
| 8 |
createHfInference,
|
|
|
|
| 25 |
const startMessageUser: ChatCompletionInputMessage = { role: "user", content: "" };
|
| 26 |
const startMessageSystem: ChatCompletionInputMessage = { role: "system", content: "" };
|
| 27 |
|
| 28 |
+
const modelIdFromQueryParam = $page.url.searchParams.get("modelId");
|
| 29 |
+
const modelFromQueryParam = models.find(model => model.id === modelIdFromQueryParam);
|
| 30 |
+
|
| 31 |
let conversation: Conversation = {
|
| 32 |
+
model: modelFromQueryParam ?? models.find(m => FEATUED_MODELS_IDS.includes(m.id)) ?? models[0],
|
| 33 |
config: defaultGenerationConfig,
|
| 34 |
messages: [{ ...startMessageUser }],
|
| 35 |
systemMessage: startMessageSystem,
|
src/lib/components/InferencePlayground/InferencePlaygroundModelSelector.svelte
CHANGED
|
@@ -1,6 +1,9 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
import type { Conversation, ModelEntryWithTokenizer } from "./types";
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
import IconCaret from "../Icons/IconCaret.svelte";
|
| 5 |
import ModelSelectorModal from "./InferencePlaygroundModelSelectorModal.svelte";
|
| 6 |
|
|
@@ -27,6 +30,10 @@
|
|
| 27 |
return;
|
| 28 |
}
|
| 29 |
conversation.model = model;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
$: [nameSpace, modelName] = conversation.model.id.split("/");
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
import type { Conversation, ModelEntryWithTokenizer } from "./types";
|
| 3 |
|
| 4 |
+
import { goto } from "$app/navigation";
|
| 5 |
+
import { page } from "$app/stores";
|
| 6 |
+
|
| 7 |
import IconCaret from "../Icons/IconCaret.svelte";
|
| 8 |
import ModelSelectorModal from "./InferencePlaygroundModelSelectorModal.svelte";
|
| 9 |
|
|
|
|
| 30 |
return;
|
| 31 |
}
|
| 32 |
conversation.model = model;
|
| 33 |
+
|
| 34 |
+
const url = new URL($page.url);
|
| 35 |
+
url.searchParams.set("modelId", model.id);
|
| 36 |
+
goto(url.toString(), { replaceState: true });
|
| 37 |
}
|
| 38 |
|
| 39 |
$: [nameSpace, modelName] = conversation.model.id.split("/");
|