Thomas G. Lopes commited on
Commit
761e5b4
·
1 Parent(s): 79784ac

add docs link

Browse files
src/lib/components/Icons/IconExternal.svelte ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let classNames = "";
3
+ </script>
4
+
5
+ <svg class={classNames} xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"
6
+ ><path fill="currentColor" d="M10 6v2h12.59L6 24.59L7.41 26L24 9.41V22h2V6H10z" /></svg
7
+ >
src/lib/components/InferencePlayground/InferencePlayground.svelte CHANGED
@@ -24,6 +24,7 @@
24
  import HFTokenModal from "./InferencePlaygroundHFTokenModal.svelte";
25
  import ModelSelector from "./InferencePlaygroundModelSelector.svelte";
26
  import ModelSelectorModal from "./InferencePlaygroundModelSelectorModal.svelte";
 
27
 
28
  const startMessageUser: ConversationMessage = { role: "user", content: "" };
29
 
@@ -380,9 +381,7 @@
380
  target="_blank"
381
  class="flex items-center gap-0.5 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"
382
  >
383
- <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"
384
- ><path fill="currentColor" d="M10 6v2h12.59L6 24.59L7.41 26L24 9.41V22h2V6H10z" /></svg
385
- >
386
  Model page
387
  </a>
388
  </div>
 
24
  import HFTokenModal from "./InferencePlaygroundHFTokenModal.svelte";
25
  import ModelSelector from "./InferencePlaygroundModelSelector.svelte";
26
  import ModelSelectorModal from "./InferencePlaygroundModelSelectorModal.svelte";
27
+ import IconExternal from "../Icons/IconExternal.svelte";
28
 
29
  const startMessageUser: ConversationMessage = { role: "user", content: "" };
30
 
 
381
  target="_blank"
382
  class="flex items-center gap-0.5 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"
383
  >
384
+ <IconExternal />
 
 
385
  Model page
386
  </a>
387
  </div>
src/lib/components/InferencePlayground/InferencePlaygroundCodeSnippets.svelte CHANGED
@@ -16,6 +16,7 @@
16
  type InferenceSnippetLanguage,
17
  } from "./inferencePlaygroundUtils";
18
  import { keys, fromEntries, entries } from "$lib/utils/object";
 
19
 
20
  hljs.registerLanguage("javascript", javascript);
21
  hljs.registerLanguage("python", python);
@@ -69,19 +70,30 @@
69
  type InstallInstructions = {
70
  title: string;
71
  content: string;
 
72
  };
73
- $: installInstructions = (function getInstallInstructions() {
74
  if (lang === "javascript") {
75
- const toInstall = selectedSnippet.client.includes("hugging") ? "@huggingface/inference" : "openai";
 
 
 
 
76
  return {
77
  title: `Install ${toInstall}`,
78
  content: `npm install --save ${toInstall}`,
 
79
  };
80
  } else if (lang === "python") {
81
- const toInstall = selectedSnippet.client.includes("hugging") ? "huggingface_hub" : "openai";
 
 
 
 
82
  return {
83
  title: `Install the latest`,
84
  content: `pip install --upgrade ${toInstall}`,
 
85
  };
86
  }
87
  })();
@@ -165,7 +177,17 @@
165
 
166
  {#if installInstructions}
167
  <div class="flex items-center justify-between px-2 pt-6 pb-4">
168
- <h2 class="font-semibold">{installInstructions.title}</h2>
 
 
 
 
 
 
 
 
 
 
169
  <div class="flex items-center gap-x-4">
170
  <button
171
  class="flex items-center gap-x-2 rounded-md border bg-white px-1.5 py-0.5 text-sm shadow-xs transition dark:border-gray-800 dark:bg-gray-800"
 
16
  type InferenceSnippetLanguage,
17
  } from "./inferencePlaygroundUtils";
18
  import { keys, fromEntries, entries } from "$lib/utils/object";
19
+ import IconExternal from "../Icons/IconExternal.svelte";
20
 
21
  hljs.registerLanguage("javascript", javascript);
22
  hljs.registerLanguage("python", python);
 
70
  type InstallInstructions = {
71
  title: string;
72
  content: string;
73
+ docs: string;
74
  };
75
+ $: installInstructions = (function getInstallInstructions(): InstallInstructions | undefined {
76
  if (lang === "javascript") {
77
+ const isHugging = selectedSnippet.client.includes("hugging");
78
+ const toInstall = isHugging ? "@huggingface/inference" : "openai";
79
+ const docs = isHugging
80
+ ? "https://huggingface.co/docs/huggingface.js/inference/README"
81
+ : "https://platform.openai.com/docs/libraries";
82
  return {
83
  title: `Install ${toInstall}`,
84
  content: `npm install --save ${toInstall}`,
85
+ docs,
86
  };
87
  } else if (lang === "python") {
88
+ const isHugging = selectedSnippet.client.includes("hugging");
89
+ const toInstall = isHugging ? "huggingface_hub" : "openai";
90
+ const docs = isHugging
91
+ ? "https://huggingface.co/docs/huggingface_hub/guides/inference"
92
+ : "https://platform.openai.com/docs/libraries";
93
  return {
94
  title: `Install the latest`,
95
  content: `pip install --upgrade ${toInstall}`,
96
+ docs,
97
  };
98
  }
99
  })();
 
177
 
178
  {#if installInstructions}
179
  <div class="flex items-center justify-between px-2 pt-6 pb-4">
180
+ <h2 class="flex items-baseline gap-2 font-semibold">
181
+ {installInstructions.title}
182
+ <a
183
+ href={installInstructions.docs}
184
+ target="_blank"
185
+ class="relative -bottom-[1px] flex items-center gap-1 text-sm font-normal text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"
186
+ >
187
+ <IconExternal classNames="size-3" />
188
+ Docs
189
+ </a>
190
+ </h2>
191
  <div class="flex items-center gap-x-4">
192
  <button
193
  class="flex items-center gap-x-2 rounded-md border bg-white px-1.5 py-0.5 text-sm shadow-xs transition dark:border-gray-800 dark:bg-gray-800"