Thomas G. Lopes commited on
Commit
16c3549
·
1 Parent(s): 0ff4ef8

fix reactivity

Browse files
src/lib/components/InferencePlayground/InferencePlaygroundCodeSnippets.svelte CHANGED
@@ -38,16 +38,21 @@
38
 
39
  $: tokenStr = getTokenStr(showToken);
40
 
41
- function getSnippet(lang: InferenceSnippetLanguage, tokenStr: string) {
 
 
 
 
 
42
  return getInferenceSnippet(conversation.model, conversation.provider as InferenceProvider, lang, tokenStr, {
43
  messages: conversation.messages,
44
  });
45
  }
46
 
47
  $: clientSnippetsByLang = {
48
- javascript: getSnippet("js", tokenStr),
49
- python: getSnippet("python", tokenStr),
50
- http: getSnippet("curl", tokenStr),
51
  } as Record<Language, GetInferenceSnippetReturn>;
52
 
53
  const selectedClientIdxByLang: Record<Language, number> = Object.fromEntries(lanuages.map(lang => [lang, 0]));
 
38
 
39
  $: tokenStr = getTokenStr(showToken);
40
 
41
+ type GetSnippetArgs = {
42
+ tokenStr: string;
43
+ conversation: Conversation;
44
+ lang: InferenceSnippetLanguage;
45
+ };
46
+ function getSnippet({ tokenStr, conversation, lang }: GetSnippetArgs) {
47
  return getInferenceSnippet(conversation.model, conversation.provider as InferenceProvider, lang, tokenStr, {
48
  messages: conversation.messages,
49
  });
50
  }
51
 
52
  $: clientSnippetsByLang = {
53
+ javascript: getSnippet({ lang: "js", tokenStr, conversation }),
54
+ python: getSnippet({ lang: "python", tokenStr, conversation }),
55
+ http: getSnippet({ lang: "curl", tokenStr, conversation }),
56
  } as Record<Language, GetInferenceSnippetReturn>;
57
 
58
  const selectedClientIdxByLang: Record<Language, number> = Object.fromEntries(lanuages.map(lang => [lang, 0]));