Skip to content

Commit fad4b22

Browse files
Add Raw JSON tab to model detail panel
Adds a third tab alongside 'Python SDK' and 'AI Gateway (Proxy)' in the expanded model detail view that displays the complete raw JSON entry for each model from the LiteLLM pricing database. Includes copy-to-clipboard support and fixes CSS for the 3-tab button group. Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
1 parent 6c8485b commit fad4b22

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

src/App.svelte

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
}
5151
5252
// Quick start tab state per model
53-
let codeTabStates: Record<string, "sdk" | "proxy"> = {};
53+
let codeTabStates: Record<string, "sdk" | "proxy" | "json"> = {};
5454
5555
onMount(() => {
5656
const urlParams = new URLSearchParams(window.location.search);
@@ -260,6 +260,15 @@ We also need to update [${RESOURCE_BACKUP_NAME}](https://github.com/${REPO_FULL_
260260
return labels[mode] || mode;
261261
}
262262
263+
function getRawModelJson(name: string): string {
264+
if (!index) return "{}";
265+
const allItems = (index as any)["_docs"] as Item[];
266+
const item = allItems.find((i: Item) => i.name === name);
267+
if (!item) return "{}";
268+
const { name: _n, ...rest } = item;
269+
return JSON.stringify(rest, null, 2);
270+
}
271+
263272
function filterResults(
264273
query: string,
265274
selectedProvider: string,
@@ -643,15 +652,24 @@ We also need to update [${RESOURCE_BACKUP_NAME}](https://github.com/${REPO_FULL_
643652
class:active={codeTabStates[name] === "proxy"}
644653
on:click|stopPropagation={() => { codeTabStates[name] = "proxy"; codeTabStates = codeTabStates; }}
645654
>AI Gateway (Proxy)</button>
655+
<button
656+
class="code-tab"
657+
class:active={codeTabStates[name] === "json"}
658+
on:click|stopPropagation={() => { codeTabStates[name] = "json"; codeTabStates = codeTabStates; }}
659+
>Raw JSON</button>
646660
</div>
647661
{#if !codeTabStates[name] || codeTabStates[name] === "sdk"}
648662
<button class="copy-code-btn" on:click|stopPropagation={() => copyToClipboard(`from litellm import completion\n\nresponse = completion(\n model="${getDisplayModelName(name, litellm_provider)}",\n messages=[{"role": "user", "content": "Hello!"}]\n)`)}>
649663
{copiedModel.includes("from litellm") ? "Copied!" : "Copy"}
650664
</button>
651-
{:else}
665+
{:else if codeTabStates[name] === "proxy"}
652666
<button class="copy-code-btn" on:click|stopPropagation={() => copyToClipboard(`curl http://0.0.0.0:4000/v1/chat/completions \\\n -H "Content-Type: application/json" \\\n -H "Authorization: Bearer sk-1234" \\\n -d '{\n "model": "${getDisplayModelName(name, litellm_provider)}",\n "messages": [{"role": "user", "content": "Hello!"}]\n }'`)}>
653667
{copiedModel.includes("curl") ? "Copied!" : "Copy"}
654668
</button>
669+
{:else}
670+
<button class="copy-code-btn" on:click|stopPropagation={() => copyToClipboard(getRawModelJson(name))}>
671+
{copiedModel === getRawModelJson(name) ? "Copied!" : "Copy"}
672+
</button>
655673
{/if}
656674
</div>
657675
{#if !codeTabStates[name] || codeTabStates[name] === "sdk"}
@@ -661,7 +679,7 @@ response = completion(
661679
model=<span class="code-str">"{getDisplayModelName(name, litellm_provider)}"</span>,
662680
messages=[{`{`}<span class="code-str">"role"</span>: <span class="code-str">"user"</span>, <span class="code-str">"content"</span>: <span class="code-str">"Hello!"</span>{`}`}]
663681
)</code></pre>
664-
{:else}
682+
{:else if codeTabStates[name] === "proxy"}
665683
<pre class="code-snippet"><code><span class="code-comment"># Start proxy: litellm --model {getDisplayModelName(name, litellm_provider)}</span>
666684

667685
curl http://0.0.0.0:4000/v1/chat/completions \
@@ -671,6 +689,8 @@ curl http://0.0.0.0:4000/v1/chat/completions \
671689
"model": "{getDisplayModelName(name, litellm_provider)}",
672690
"messages": [{`{`}"role": "user", "content": "Hello!"{`}`}]
673691
{`}`}'</span></code></pre>
692+
{:else}
693+
<pre class="code-snippet"><code>{getRawModelJson(name)}</code></pre>
674694
{/if}
675695
</div>
676696

@@ -1408,6 +1428,9 @@ curl http://0.0.0.0:4000/v1/chat/completions \
14081428
14091429
.code-tab:last-child {
14101430
border-radius: 0 6px 6px 0;
1431+
}
1432+
1433+
.code-tab + .code-tab {
14111434
border-left: none;
14121435
}
14131436

0 commit comments

Comments
 (0)