Skip to content

Commit 69b9c1a

Browse files
committed
UI fix provider
1 parent 7d00dc1 commit 69b9c1a

File tree

2 files changed

+125
-30
lines changed

2 files changed

+125
-30
lines changed

src/App.svelte

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
import Fuse from "fuse.js";
66
import Typewriter from "svelte-typewriter";
7+
import { getProviderInitial, getProviderLogo } from "./providers";
78
89
type Item = {
910
name: string;
@@ -181,34 +182,6 @@ We also need to update [${RESOURCE_BACKUP_NAME}](https://github.com/${REPO_FULL_
181182
loading = false;
182183
}
183184
}
184-
185-
function getProviderInitial(provider: string): string {
186-
if (!provider) return "?";
187-
188-
// Map common providers to their initials/abbreviations
189-
const providerMap: { [key: string]: string } = {
190-
"anthropic": "A",
191-
"openai": "O",
192-
"azure": "Az",
193-
"bedrock": "B",
194-
"vertex_ai": "V",
195-
"cohere": "C",
196-
"huggingface": "H",
197-
"replicate": "R",
198-
"groq": "G",
199-
"together_ai": "T",
200-
"mistral": "M",
201-
"deepinfra": "D",
202-
};
203-
204-
const lowerProvider = provider.toLowerCase();
205-
if (providerMap[lowerProvider]) {
206-
return providerMap[lowerProvider];
207-
}
208-
209-
// Default to first letter uppercase
210-
return provider.charAt(0).toUpperCase();
211-
}
212185
</script>
213186

214187
<main class="container">
@@ -312,7 +285,24 @@ We also need to update [${RESOURCE_BACKUP_NAME}](https://github.com/${REPO_FULL_
312285
<td class="model-name">
313286
<div class="model-info">
314287
<div class="provider-avatar">
315-
{getProviderInitial(litellm_provider)}
288+
{#if getProviderLogo(litellm_provider)}
289+
<img
290+
src={getProviderLogo(litellm_provider)}
291+
alt={litellm_provider}
292+
class="provider-logo-img"
293+
on:error={(e) => {
294+
e.currentTarget.style.display = 'none';
295+
e.currentTarget.nextElementSibling.style.display = 'flex';
296+
}}
297+
/>
298+
<div class="provider-initial" style="display: none;">
299+
{getProviderInitial(litellm_provider)}
300+
</div>
301+
{:else}
302+
<div class="provider-initial">
303+
{getProviderInitial(litellm_provider)}
304+
</div>
305+
{/if}
316306
</div>
317307
<span class="model-title">{name}</span>
318308
</div>
@@ -470,14 +460,38 @@ We also need to update [${RESOURCE_BACKUP_NAME}](https://github.com/${REPO_FULL_
470460
width: 40px;
471461
height: 40px;
472462
border-radius: 50%;
473-
background-color: #1a1a1a;
463+
background-color: white;
474464
color: white;
475465
display: flex;
476466
align-items: center;
477467
justify-content: center;
478468
font-weight: 600;
479469
font-size: 0.9rem;
480470
flex-shrink: 0;
471+
overflow: hidden;
472+
position: relative;
473+
padding: 6px;
474+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
475+
}
476+
477+
.provider-logo-img {
478+
width: 100%;
479+
height: 100%;
480+
object-fit: contain;
481+
}
482+
483+
.provider-initial {
484+
width: 100%;
485+
height: 100%;
486+
display: flex;
487+
align-items: center;
488+
justify-content: center;
489+
background-color: #1a1a1a;
490+
color: white;
491+
font-weight: 600;
492+
font-size: 0.9rem;
493+
border-radius: 50%;
494+
margin: -6px;
481495
}
482496
483497
.model-title {

src/providers.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Provider utility functions for mapping provider names to logos and initials
3+
*/
4+
5+
/**
6+
* Get the initial/abbreviation for a provider name
7+
*/
8+
export function getProviderInitial(provider: string): string {
9+
if (!provider) return "?";
10+
11+
// Map common providers to their initials/abbreviations
12+
const providerMap: { [key: string]: string } = {
13+
"anthropic": "A",
14+
"openai": "O",
15+
"azure": "Az",
16+
"bedrock": "B",
17+
"vertex_ai": "V",
18+
"cohere": "C",
19+
"huggingface": "H",
20+
"replicate": "R",
21+
"groq": "G",
22+
"together_ai": "T",
23+
"mistral": "M",
24+
"deepinfra": "D",
25+
};
26+
27+
const lowerProvider = provider.toLowerCase();
28+
if (providerMap[lowerProvider]) {
29+
return providerMap[lowerProvider];
30+
}
31+
32+
// Default to first letter uppercase
33+
return provider.charAt(0).toUpperCase();
34+
}
35+
36+
/**
37+
* Get the logo URL for a provider from the LiteLLM GitHub repository
38+
* Returns null if no logo is available for the provider
39+
*/
40+
export function getProviderLogo(provider: string): string | null {
41+
if (!provider) return null;
42+
43+
// Map provider names to their logo filenames in the LiteLLM repo (actual files from GitHub)
44+
const providerLogoMap: { [key: string]: string } = {
45+
"openai": "openai_small.svg",
46+
"azure": "microsoft_azure.svg",
47+
"anthropic": "anthropic.svg",
48+
"bedrock": "bedrock.svg",
49+
"vertex_ai": "google.svg",
50+
"vertexai": "google.svg",
51+
"cohere": "cohere.svg",
52+
"groq": "groq.svg",
53+
"mistral": "mistral.svg",
54+
"deepinfra": "deepinfra.png",
55+
"databricks": "databricks.svg",
56+
"fireworks_ai": "fireworks.svg",
57+
"fireworks": "fireworks.svg",
58+
"ollama": "ollama.svg",
59+
"openrouter": "openrouter.svg",
60+
"deepseek": "deepseek.svg",
61+
"cerebras": "cerebras.svg",
62+
"oracle": "oracle.svg",
63+
"text-completion-openai": "openai_small.svg",
64+
"text-completion-codestral": "mistral.svg",
65+
"codestral": "mistral.svg",
66+
"sagemaker": "aws.svg",
67+
"aws": "aws.svg",
68+
"google": "google.svg",
69+
"gemini": "google.svg",
70+
};
71+
72+
const lowerProvider = provider.toLowerCase();
73+
const logoFilename = providerLogoMap[lowerProvider];
74+
75+
if (logoFilename) {
76+
return `https://raw.githubusercontent.com/BerriAI/litellm/main/ui/litellm-dashboard/public/assets/logos/${logoFilename}`;
77+
}
78+
79+
return null;
80+
}
81+

0 commit comments

Comments
 (0)