File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
src/lib/components/InferencePlayground Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 2
2
import type { ModelEntryWithTokenizer } from " ./types" ;
3
3
import { type ChatCompletionInputMessage } from " @huggingface/tasks" ;
4
4
5
+ import { page } from " $app/stores" ;
5
6
import { defaultGenerationConfig } from " ./generationConfigSettings" ;
6
7
import {
7
8
createHfInference ,
24
25
const startMessageUser: ChatCompletionInputMessage = { role: " user" , content: " " };
25
26
const startMessageSystem: ChatCompletionInputMessage = { role: " system" , content: " " };
26
27
28
+ const modelIdFromQueryParam = $page .url .searchParams .get (" modelId" );
29
+ const modelFromQueryParam = models .find (model => model .id === modelIdFromQueryParam );
30
+
27
31
let conversation: Conversation = {
28
- model: models .find (m => FEATUED_MODELS_IDS .includes (m .id )) ?? models [0 ],
32
+ model: modelFromQueryParam ?? models .find (m => FEATUED_MODELS_IDS .includes (m .id )) ?? models [0 ],
29
33
config: defaultGenerationConfig ,
30
34
messages: [{ ... startMessageUser }],
31
35
systemMessage: startMessageSystem ,
Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import type { Conversation , ModelEntryWithTokenizer } from " ./types" ;
3
3
4
+ import { goto } from " $app/navigation" ;
5
+ import { page } from " $app/stores" ;
6
+
4
7
import IconCaret from " ../Icons/IconCaret.svelte" ;
5
8
import ModelSelectorModal from " ./InferencePlaygroundModelSelectorModal.svelte" ;
6
9
27
30
return ;
28
31
}
29
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 });
30
37
}
31
38
32
39
$ : [nameSpace , modelName ] = conversation .model .id .split (" /" );
You can’t perform that action at this time.
0 commit comments