mishig HF staff commited on
Commit
bd6645c
1 Parent(s): ad1d85c

get org avatars dynamically

Browse files
src/lib/components/InferencePlayground/InferencePlaygroundModelSelector.svelte CHANGED
@@ -6,6 +6,18 @@
6
  export let conversation: Conversation;
7
  export let disabled = false;
8
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  $: [nameSpace, modelName] = conversation.model.id.split('/');
10
  </script>
11
 
@@ -22,11 +34,13 @@
22
  >
23
  <div class="flex flex-col items-start">
24
  <div class="flex items-center gap-1 text-sm text-gray-500 dark:text-gray-300">
25
- <img
26
- class="size-3 flex-none rounded bg-gray-200 object-cover"
27
- src="https://cdn-avatars.huggingface.co/v1/production/uploads/646cf8084eefb026fb8fd8bc/oCTqufkdTkjyGodsx1vo1.png"
28
- alt=""
29
- />
 
 
30
  {nameSpace}
31
  </div>
32
  <div>{modelName}</div>
 
6
  export let conversation: Conversation;
7
  export let disabled = false;
8
 
9
+ async function getAvatarUrl(orgName: string) {
10
+ const url = `https://huggingface.co/api/organizations/${orgName}/avatar`;
11
+ const res = await fetch(url);
12
+ if (!res.ok) {
13
+ console.error(`Error getting avatar url for org: ${orgName}`, res.status, res.statusText);
14
+ return;
15
+ }
16
+ const json = await res.json();
17
+ const { avatarUrl } = json;
18
+ return avatarUrl;
19
+ }
20
+
21
  $: [nameSpace, modelName] = conversation.model.id.split('/');
22
  </script>
23
 
 
34
  >
35
  <div class="flex flex-col items-start">
36
  <div class="flex items-center gap-1 text-sm text-gray-500 dark:text-gray-300">
37
+ {#await getAvatarUrl(nameSpace) then avatarUrl}
38
+ <img
39
+ class="size-3 flex-none rounded bg-gray-200 object-cover"
40
+ src={avatarUrl}
41
+ alt="{nameSpace} avatar"
42
+ />
43
+ {/await}
44
  {nameSpace}
45
  </div>
46
  <div>{modelName}</div>