Thomas G. Lopes commited on
Commit
a57e83b
·
1 Parent(s): ebdeff1
src/lib/components/inference-playground/model-selector.svelte CHANGED
@@ -62,3 +62,4 @@
62
  {/if}
63
 
64
  <ProviderSelect bind:conversation />
 
 
62
  {/if}
63
 
64
  <ProviderSelect bind:conversation />
65
+
src/lib/components/inference-playground/playground.svelte CHANGED
@@ -1,5 +1,5 @@
1
  <script lang="ts">
2
- import type { ConversationMessage, ModelWithTokenizer } from "$lib/types.js";
3
 
4
  import { handleNonStreamingResponse, handleStreamingResponse, isSystemPromptSupported } from "./utils.js";
5
 
@@ -24,6 +24,7 @@
24
  import ProjectSelect from "./project-select.svelte";
25
  import { showQuotaModal } from "../quota-modal.svelte";
26
  import Toaster from "../toaster.svelte";
 
27
 
28
  const startMessageUser: ConversationMessage = { role: "user", content: "" };
29
 
@@ -50,13 +51,14 @@
50
  const compareActive = $derived(session.project.conversations.length === 2);
51
 
52
  function reset() {
53
- session.project.conversations = session.project.conversations.map(conversation => {
54
  return {
55
  ...conversation,
56
  systemMessage: { role: "system", content: "" },
57
  messages: [{ ...startMessageUser }],
58
  };
59
  });
 
60
  }
61
 
62
  async function runInference(conversationIdx: number) {
 
1
  <script lang="ts">
2
+ import type { ConversationMessage, ModelWithTokenizer, Project } from "$lib/types.js";
3
 
4
  import { handleNonStreamingResponse, handleStreamingResponse, isSystemPromptSupported } from "./utils.js";
5
 
 
24
  import ProjectSelect from "./project-select.svelte";
25
  import { showQuotaModal } from "../quota-modal.svelte";
26
  import Toaster from "../toaster.svelte";
27
+ import typia from "typia";
28
 
29
  const startMessageUser: ConversationMessage = { role: "user", content: "" };
30
 
 
51
  const compareActive = $derived(session.project.conversations.length === 2);
52
 
53
  function reset() {
54
+ const c = session.project.conversations.map(conversation => {
55
  return {
56
  ...conversation,
57
  systemMessage: { role: "system", content: "" },
58
  messages: [{ ...startMessageUser }],
59
  };
60
  });
61
+ if (typia.is<Project["conversations"]>(c)) session.project.conversations = c;
62
  }
63
 
64
  async function runInference(conversationIdx: number) {
src/lib/state/session.svelte.ts CHANGED
@@ -93,8 +93,11 @@ class SessionState {
93
  const modelsFromSearch = searchModelIds.map(id => models.all.find(model => model.id === id)).filter(Boolean);
94
  if (modelsFromSearch.length > 0) savedSession.activeProjectId = "default";
95
 
96
- const min = Math.min(dp.conversations.length, modelsFromSearch.length, searchProviders.length);
97
- dp.conversations = dp.conversations.slice(0, min);
 
 
 
98
  for (let i = 0; i < min; i++) {
99
  const conversation = dp.conversations[i] ?? defaultConversation;
100
  dp.conversations[i] = {
 
93
  const modelsFromSearch = searchModelIds.map(id => models.all.find(model => model.id === id)).filter(Boolean);
94
  if (modelsFromSearch.length > 0) savedSession.activeProjectId = "default";
95
 
96
+ let min = Math.min(dp.conversations.length, modelsFromSearch.length, searchProviders.length);
97
+ min = Math.max(1, min);
98
+ const convos = dp.conversations.slice(0, min);
99
+ if (typia.is<Project["conversations"]>(convos)) dp.conversations = convos;
100
+
101
  for (let i = 0; i < min; i++) {
102
  const conversation = dp.conversations[i] ?? defaultConversation;
103
  dp.conversations[i] = {
src/lib/types.ts CHANGED
@@ -15,7 +15,7 @@ export type Conversation = {
15
  };
16
 
17
  export type Project = {
18
- conversations: Conversation[];
19
  id: string;
20
  name: string;
21
  };
 
15
  };
16
 
17
  export type Project = {
18
+ conversations: [Conversation] | [Conversation, Conversation];
19
  id: string;
20
  name: string;
21
  };