nsarrazin HF Staff commited on
Commit
c71f447
·
1 Parent(s): aa18570

feat: simplify model page data loading

Browse files
src/routes/models/[...model]/+page.svelte CHANGED
@@ -21,30 +21,15 @@
21
  async function createConversation(message: string) {
22
  try {
23
  loading = true;
24
- // check if $settings.activeModel is a valid model
25
- // else check if it's an assistant, and use that model
26
- // else use the first model
27
 
28
- const validModels = data.models.map((model) => model.id);
29
-
30
- let model;
31
- if (validModels.includes($settings.activeModel)) {
32
- model = $settings.activeModel;
33
- } else {
34
- if (validModels.includes(data.assistant?.modelId)) {
35
- model = data.assistant?.modelId;
36
- } else {
37
- model = data.models[0].id;
38
- }
39
- }
40
  const res = await fetch(`${base}/conversation`, {
41
  method: "POST",
42
  headers: {
43
  "Content-Type": "application/json",
44
  },
45
  body: JSON.stringify({
46
- model,
47
- preprompt: $settings.customPrompts[$settings.activeModel],
48
  }),
49
  });
50
 
@@ -73,10 +58,6 @@
73
  }
74
 
75
  onMount(async () => {
76
- settings.instantSet({
77
- activeModel: modelId,
78
- });
79
-
80
  const query = $page.url.searchParams.get("q");
81
  if (query) createConversation(query);
82
  });
 
21
  async function createConversation(message: string) {
22
  try {
23
  loading = true;
 
 
 
24
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  const res = await fetch(`${base}/conversation`, {
26
  method: "POST",
27
  headers: {
28
  "Content-Type": "application/json",
29
  },
30
  body: JSON.stringify({
31
+ model: modelId,
32
+ preprompt: $settings.customPrompts[modelId],
33
  }),
34
  });
35
 
 
58
  }
59
 
60
  onMount(async () => {
 
 
 
 
61
  const query = $page.url.searchParams.get("q");
62
  if (query) createConversation(query);
63
  });