chore(release): backport #44066 to rc/1.105.0 (#44215)

* feat(mcp)!: disable stdio MCP servers by default (#44066)

* feat(mcp)!: disable stdio MCP servers by default

stdio MCP servers now only run when the proxy is started with
LITELLM_ENABLE_MCP_STDIO=true. While it is off, existing stdio servers stay
registered but never start: tool listings skip them quietly, direct tool
calls and health checks return a 403 naming the env var, and creating or
updating a stdio server is rejected. The flag is read from the process
environment only, so DB-stored environment_variables cannot turn it on.

The UI reads mcp_stdio_enabled from /.well-known/litellm-ui-config to grey
out the stdio transport, show a banner on stdio forms, and badge stdio
server cards.

BREAKING CHANGE: stdio MCP servers are off by default. Set
LITELLM_ENABLE_MCP_STDIO=true in the proxy environment and restart to keep
using them.

* fix(mcp): ignore stdio flag from config file and read UI flag from the selected worker

LITELLM_ENABLE_MCP_STDIO set under environment_variables in config.yaml is now skipped like the DB-stored value, so only the process environment can enable stdio. The dashboard reads mcp_stdio_enabled from the proxy it is managing, so a control plane shows each worker's own setting.

* test(mcp): cover non-mapping payloads in the shared transport validator

* fix(mcp): skip blocked stdio servers quietly in every listing and keep the UI unchanged until the flag loads

Prompt, resource and resource-template listings now skip a blocked stdio server at debug level like tool listing does, instead of logging a warning per server on every call. The dashboard only treats stdio as disabled once the proxy explicitly reports mcp_stdio_enabled false, so a proxy with the flag on, or an older one without the field, renders exactly as before with no flicker while loading.

* fix(mcp): route blocked stdio tool calls to the flag error and warn once per server

A gateway tools/call naming a blocked stdio server's tool now returns the
LITELLM_ENABLE_MCP_STDIO message instead of "Tool not found".

The "will not start" warning moves out of build_mcp_server_from_table, which
DB reload re-runs on every cycle for rows with a NULL updated_at and which
drafts and test-connection also call. It now fires when a row first enters
the registry or changes transport.

* fix(ui): explain on the server detail page why a stdio server is inert

The Overview and MCP Tools tabs showed "No tools available" with no reason
while stdio is disabled. The detail page now shows the same warning banner
as the edit form, and hands off to the form's banner once editing starts.

* refactor(ui): name the stdio banner conditions on the server detail page

Keeps local/no-long-condition-chain within its budget

* fix(proxy): log the ignored DB-stored LITELLM_ENABLE_MCP_STDIO warning once

The DB config sync re-reads environment_variables on every cycle, so a stored
flag logged the warning on each sync per worker

(cherry picked from commit 2b85808011)

* chore: update Next.js build artifacts (2026-10-02 17:40 UTC, node v24.19.0)
This commit is contained in:
yuneng-jiang 2026-10-02 11:22:11 -07:00 • committed by GitHub
parent fe9b6fd603
commit 3ee3b230db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
611 changed files with 7866 additions and 6269 deletions

View file

@ -169,7 +169,7 @@ start_proxy() {
INTEGRATION_UPSTREAM_URL="$INTEGRATION_UPSTREAM_URL" \
LITELLM_MASTER_KEY="$LITELLM_MASTER_KEY" LITELLM_SALT_KEY="$LITELLM_SALT_KEY" LITELLM_UI_PATH="$LITELLM_UI_PATH" PROXY_BASE_URL="http://127.0.0.1:$port" \
LITELLM_LICENSE="${LITELLM_LICENSE:-}" \
LITELLM_MODE=PRODUCTION STORE_MODEL_IN_DB=True "${cost_map_env[@]}" \
LITELLM_MODE=PRODUCTION STORE_MODEL_IN_DB=True LITELLM_ENABLE_MCP_STDIO=true "${cost_map_env[@]}" \
AWS_EC2_METADATA_DISABLED=true DO_NOT_TRACK=1 COVERAGE_FILE="$coverage_data" \
"${proxy_command[@]}" --config tests/integration/proxy_config.yaml \
--host 127.0.0.1 --port "$port" --num_workers 1 --telemetry False \

View file

@ -142,6 +142,12 @@ from litellm.proxy._experimental.mcp_server.result_conversion import (
from litellm.proxy._experimental.mcp_server.sampling_handler import (
MCP_SAMPLING_AVAILABLE,
)
from litellm.proxy._experimental.mcp_server.stdio_gate import (
MCP_STDIO_DISABLED_MESSAGE,
is_mcp_stdio_blocked,
is_mcp_stdio_enabled,
warn_if_mcp_stdio_blocked,
)
from litellm.proxy._experimental.mcp_server.tool_catalog_guard import (
CatalogAlert,
apply_description_overrides,
@ -2464,6 +2470,7 @@ class MCPServerManager:
alias=alias,
server_name=server_name,
)
warn_if_mcp_stdio_blocked(server_name, server_config.get("transport"))
auth_type = server_config.get("auth_type", None)
manual_issuer = _blank_to_none(server_config.get("issuer"))
@ -3282,6 +3289,7 @@ class MCPServerManager:
# `credentials` field is the only one still encrypted here).
# Re-decrypting plaintext would zero the values, so build with
# env_vars_are_encrypted=False.
self._warn_if_newly_blocked_stdio(mcp_server, None)
new_server: Final = await self.build_mcp_server_from_table(mcp_server, env_vars_are_encrypted=False)
self._assign_unique_short_prefix(new_server)
self._invalidate_server_definition_caches(mcp_server.server_id)
@ -4280,6 +4288,8 @@ class MCPServerManager:
# Handle stdio transport
if transport == MCPTransport.stdio:
if not is_mcp_stdio_enabled():
raise HTTPException(status_code=403, detail=MCP_STDIO_DISABLED_MESSAGE)
resolved_env: Final = (
stdio_env
if stdio_env is not None
@ -4439,6 +4449,9 @@ class MCPServerManager:
global_mcp_tool_registry,
)
if self._skip_blocked_stdio_listing(server, "tool"):
return []
verbose_logger.debug("Connecting to url: %s", server.url)
verbose_logger.info("_get_tools_from_server for %s...", server.name)
@ -4638,6 +4651,19 @@ class MCPServerManager:
)
return server.server_id, hashlib.sha256(material.encode()).hexdigest()
@staticmethod
def _warn_if_newly_blocked_stdio(row: LiteLLM_MCPServerTable, previous: MCPServer | None) -> None:
if previous is None or previous.transport != row.transport:
warn_if_mcp_stdio_blocked(row.alias or row.server_name, row.transport)
def _skip_blocked_stdio_listing(self, server: MCPServer, listing: str) -> bool:
if not is_mcp_stdio_blocked(server.transport):
return False
verbose_logger.debug(
"Skipping %s listing for MCP server %s: %s", listing, server.name, MCP_STDIO_DISABLED_MESSAGE
)
return True
async def get_prompts_from_server(
self,
server: MCPServer,
@ -4648,6 +4674,8 @@ class MCPServerManager:
raw_headers: dict[str, str] | None = None,
client_ip: str | None = None,
) -> list[Prompt]:
if self._skip_blocked_stdio_listing(server, "prompt"):
return []
try:
headers: Final = (
dict(
@ -4694,6 +4722,8 @@ class MCPServerManager:
raw_headers: dict[str, str] | None = None,
client_ip: str | None = None,
) -> list[Resource]:
if self._skip_blocked_stdio_listing(server, "resource"):
return []
try:
headers: Final = (
dict(
@ -4740,6 +4770,8 @@ class MCPServerManager:
raw_headers: dict[str, str] | None = None,
client_ip: str | None = None,
) -> list[ResourceTemplate]:
if self._skip_blocked_stdio_listing(server, "resource template"):
return []
try:
headers: Final = (
dict(
@ -6324,6 +6356,8 @@ class MCPServerManager:
mcp_server = fallback
if mcp_server is None:
raise ValueError(f"Tool {name} not found")
if is_mcp_stdio_blocked(mcp_server.transport):
raise HTTPException(status_code=403, detail=MCP_STDIO_DISABLED_MESSAGE)
if resolved_by_server_name_only and not self.server_exposes_tool(mcp_server, name):
raise ValueError(f"Tool {name} not found")
@ -6708,7 +6742,10 @@ class MCPServerManager:
if matched is not None:
matched_prefix, original_tool_name = matched
matched_server: Final = prefix_to_server.get(matched_prefix)
if matched_server is not None and self.server_exposes_tool(matched_server, original_tool_name):
if matched_server is not None and (
self.server_exposes_tool(matched_server, original_tool_name)
or is_mcp_stdio_blocked(matched_server.transport)
):
return matched_server
return None
@ -6770,6 +6807,7 @@ class MCPServerManager:
alias=getattr(server, "alias", None),
server_name=getattr(server, "server_name", None),
)
self._warn_if_newly_blocked_stdio(server, existing_server)
verbose_logger.debug("Building server from DB: %s (%s)", server.server_id, server.server_name)
# raw_rows come straight from the DB, so their global env var
# values (like credentials) are still encrypted here, unlike the

View file

@ -0,0 +1,28 @@
import os
from typing import Final
from litellm._logging import verbose_logger
from litellm.types.mcp import MCPTransport
MCP_STDIO_ENABLED_ENV_VAR: Final = "LITELLM_ENABLE_MCP_STDIO"
MCP_STDIO_DISABLED_MESSAGE: Final = (
f"stdio MCP servers are disabled on this proxy. "
f"Set {MCP_STDIO_ENABLED_ENV_VAR}=true on the proxy and restart to enable them"
)
def is_mcp_stdio_enabled() -> bool:
return os.getenv(MCP_STDIO_ENABLED_ENV_VAR, "").strip().lower() == "true"
def is_mcp_stdio_flag_key(env_var_name: str) -> bool:
return env_var_name.upper() == MCP_STDIO_ENABLED_ENV_VAR
def is_mcp_stdio_blocked(transport: str | None) -> bool:
return transport == MCPTransport.stdio and not is_mcp_stdio_enabled()
def warn_if_mcp_stdio_blocked(server_name: str | None, transport: str | None) -> None:
if is_mcp_stdio_blocked(transport):
verbose_logger.warning("MCP server '%s' will not start: %s", server_name, MCP_STDIO_DISABLED_MESSAGE)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
:HL["/litellm-asset-prefix/_next/static/chunks/1kid9zr1--h6y.css","style"]
:HL["/litellm-asset-prefix/_next/static/chunks/3146e697tym4_.css","style"]
:HL["/litellm-asset-prefix/_next/static/chunks/2alrbzipdex33.css","style"]
:HL["/litellm-asset-prefix/_next/static/media/83afe278b6a6bb3c-s.p.2bn3s6zvc0dyp.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
0:{"tree":{"name":"","param":null,"prefetchHints":4176,"slots":{"children":{"name":"(dashboard)","param":null,"prefetchHints":4192,"slots":{"children":{"name":"__PAGE__","param":null,"prefetchHints":4256,"slots":null}}}}},"staleTime":300,"buildId":"kXnLzJ6ylsRPmgSkCkCKM"}
0:{"tree":{"name":"","param":null,"prefetchHints":4176,"slots":{"children":{"name":"(dashboard)","param":null,"prefetchHints":4192,"slots":{"children":{"name":"__PAGE__","param":null,"prefetchHints":4256,"slots":null}}}}},"staleTime":300,"buildId":"quBUyCQG3gJ3QNK71eX1m"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,35 @@
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,972520,e=>{"use strict";let t=(0,e.i(475254).default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);e.s(["ArrowRight",0,t],972520)},411929,e=>{"use strict";var t=e.i(843476),r=e.i(271645),s=e.i(972520),a=e.i(174886),o=e.i(519455),n=e.i(515288),i=e.i(624687),l=e.i(571303),d=e.i(602869),c=e.i(417385);let u=({accessToken:e})=>{let[u,m]=(0,r.useState)(`{
"model": "openai/gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Explain quantum computing in simple terms"
}
],
"temperature": 0.7,
"max_tokens": 500,
"stream": true
}`),[p,h]=(0,r.useState)(""),[x,f]=(0,r.useState)(!1),g=async()=>{f(!0);try{let a;try{a=JSON.parse(u)}catch(e){c.toast.fromError("Invalid JSON in request body"),f(!1);return}let o={call_type:"completion",request_body:a};if(!e){c.toast.fromError("No access token found"),f(!1);return}let n=await (0,d.transformRequestCall)(e,o);if(n.raw_request_api_base&&n.raw_request_body){var t,r,s;let e,a,o=(t=n.raw_request_api_base,r=n.raw_request_body,s=n.raw_request_headers||{},e=JSON.stringify(r,null,2).split("\n").map(e=>` ${e}`).join("\n"),a=Object.entries(s).map(([e,t])=>`-H '${e}: ${t}'`).join(" \\\n "),`curl -X POST \\
${t} \\
${a?`${a} \\
`:""}-H 'Content-Type: application/json' \\
-d '{
${e}
}'`);h(o),c.toast.success("Request transformed successfully")}else{let e="string"==typeof n?n:JSON.stringify(n);h(e),c.toast.info("Transformed request received in unexpected format")}}catch(e){console.error("Error transforming request:",e),c.toast.fromError("Failed to transform request")}finally{f(!1)}};return(0,t.jsxs)("div",{className:"p-2",children:[(0,t.jsx)("h1",{className:"text-lg font-medium text-foreground",children:"Playground"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"See how LiteLLM transforms your request for the specified provider."}),(0,t.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)(n.CardHeader,{children:[(0,t.jsx)(n.CardTitle,{className:"text-2xl font-bold",children:"Original Request"}),(0,t.jsx)(n.CardDescription,{children:"The request you would send to LiteLLM /chat/completions endpoint."})]}),(0,t.jsx)(n.CardContent,{children:(0,t.jsx)(i.Textarea,{className:"h-72 resize-none p-4 font-mono text-sm field-sizing-fixed",value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),g())},placeholder:"Press Cmd/Ctrl + Enter to transform"})}),(0,t.jsx)(n.CardFooter,{className:"justify-end",children:(0,t.jsxs)(o.Button,{onClick:g,disabled:x,children:[(0,t.jsx)("span",{children:"Transform"}),x?(0,t.jsx)(l.UiLoadingSpinner,{className:"size-4"}):(0,t.jsx)(s.ArrowRight,{})]})})]}),(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)(n.CardHeader,{children:[(0,t.jsx)(n.CardTitle,{className:"text-2xl font-bold",children:"Transformed Request"}),(0,t.jsx)(n.CardDescription,{children:"How LiteLLM transforms your request for the specified provider."}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Note: Sensitive headers are not shown."})]}),(0,t.jsx)(n.CardContent,{children:(0,t.jsxs)("div",{className:"relative rounded-md bg-muted",children:[(0,t.jsx)("pre",{className:"h-72 overflow-auto p-4 font-mono text-sm",children:p||`curl -X POST \\
https://api.openai.com/v1/chat/completions \\
-H 'Authorization: Bearer sk-xxx' \\
-H 'Content-Type: application/json' \\
-d '{
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
}
],
"temperature": 0.7
}'`}),(0,t.jsx)(o.Button,{variant:"ghost",size:"icon-sm","aria-label":"Copy to clipboard",className:"absolute top-2 right-2",onClick:()=>{navigator.clipboard.writeText(p||""),c.toast.success("Copied to clipboard")},children:(0,t.jsx)(a.Copy,{})})]})})]})]}),(0,t.jsx)("div",{className:"mt-4 text-right",children:(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Found an error? File an issue"," ",(0,t.jsx)("a",{className:"underline underline-offset-4",href:"https://github.com/BerriAI/litellm/issues",target:"_blank",rel:"noopener noreferrer",children:"here"}),"."]})})]})};var m=e.i(135214);e.s(["default",0,function(){let{accessToken:e}=(0,m.default)();return(0,t.jsx)(u,{accessToken:e})}],411929)}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,248536,e=>{"use strict";var s=e.i(843476),t=e.i(271645),l=e.i(405033),n=e.i(227409);function i(){let{accessToken:e,selectedMCPServers:t,setSelectedMCPServers:i}=(0,l.useChatShell)();return(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-auto w-full py-8 px-8",children:(0,s.jsx)(n.default,{accessToken:e,selectedServers:t,onChange:i})})}e.s(["default",0,function(){return(0,s.jsx)(t.Suspense,{children:(0,s.jsx)(i,{})})}])}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,7 @@
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,191905,e=>{"use strict";var t=e.i(843476),n=e.i(466828),s=e.i(677572),r=e.i(778917),a=e.i(196631);let o=({href:e,className:n})=>(0,t.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Open documentation in a new tab",className:(0,a.cn)("inline-flex items-center gap-2 rounded-xl border border-border bg-card/80 px-3.5 py-2 text-sm font-medium text-foreground shadow-xs","hover:bg-card focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring active:translate-y-[0.5px]",n),children:[(0,t.jsx)("span",{children:"API Reference Docs"}),(0,t.jsx)(r.ExternalLink,{"aria-hidden":!0,className:"h-4 w-4 opacity-80"}),(0,t.jsx)("span",{className:"sr-only",children:"(opens in a new tab)"})]}),i=({proxySettings:e})=>{let r="<your_proxy_base_url>",a=e?.LITELLM_UI_API_DOC_BASE_URL;return a&&a.trim()?r=a:e?.PROXY_BASE_URL&&(r=e.PROXY_BASE_URL),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-2 p-8 h-[80vh] w-full mt-2",children:(0,t.jsxs)("div",{className:"mb-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold text-foreground",children:"OpenAI Compatible Proxy: API Reference"}),(0,t.jsx)(o,{className:"ml-3 shrink-0",href:"https://docs.litellm.ai/docs/proxy/user_keys"})]}),(0,t.jsxs)("p",{className:"mt-2 mb-2 text-sm text-muted-foreground",children:["LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below"," "]}),(0,t.jsxs)(s.Tabs,{defaultValue:"openai",children:[(0,t.jsxs)(s.TabsList,{variant:"line",className:"border-b rounded-none w-full justify-start h-auto p-0",children:[(0,t.jsx)(s.TabsTrigger,{value:"openai",className:"rounded-none px-4 py-2 flex-none",children:"OpenAI Python SDK"}),(0,t.jsx)(s.TabsTrigger,{value:"llamaindex",className:"rounded-none px-4 py-2 flex-none",children:"LlamaIndex"}),(0,t.jsx)(s.TabsTrigger,{value:"langchain",className:"rounded-none px-4 py-2 flex-none",children:"Langchain Py"})]}),(0,t.jsx)(s.TabsContent,{value:"openai",keepMounted:!0,children:(0,t.jsx)(n.default,{language:"python",code:`import openai
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,191905,e=>{"use strict";var t=e.i(843476),n=e.i(466828),r=e.i(677572),s=e.i(778917),a=e.i(196631);let o=({href:e,className:n})=>(0,t.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Open documentation in a new tab",className:(0,a.cn)("inline-flex items-center gap-2 rounded-xl border border-border bg-card/80 px-3.5 py-2 text-sm font-medium text-foreground shadow-xs","hover:bg-card focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring active:translate-y-[0.5px]",n),children:[(0,t.jsx)("span",{children:"API Reference Docs"}),(0,t.jsx)(s.ExternalLink,{"aria-hidden":!0,className:"h-4 w-4 opacity-80"}),(0,t.jsx)("span",{className:"sr-only",children:"(opens in a new tab)"})]}),i=({proxySettings:e})=>{let s="<your_proxy_base_url>",a=e?.LITELLM_UI_API_DOC_BASE_URL;return a&&a.trim()?s=a:e?.PROXY_BASE_URL&&(s=e.PROXY_BASE_URL),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-2 p-8 h-[80vh] w-full mt-2",children:(0,t.jsxs)("div",{className:"mb-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold text-foreground",children:"OpenAI Compatible Proxy: API Reference"}),(0,t.jsx)(o,{className:"ml-3 shrink-0",href:"https://docs.litellm.ai/docs/proxy/user_keys"})]}),(0,t.jsxs)("p",{className:"mt-2 mb-2 text-sm text-muted-foreground",children:["LiteLLM is OpenAI Compatible. This means your API Key works with the OpenAI SDK. Just replace the base_url to point to your litellm proxy. Example Below"," "]}),(0,t.jsxs)(r.Tabs,{defaultValue:"openai",children:[(0,t.jsxs)(r.TabsList,{variant:"line",className:"border-b rounded-none w-full justify-start h-auto p-0",children:[(0,t.jsx)(r.TabsTrigger,{value:"openai",className:"rounded-none px-4 py-2 flex-none",children:"OpenAI Python SDK"}),(0,t.jsx)(r.TabsTrigger,{value:"llamaindex",className:"rounded-none px-4 py-2 flex-none",children:"LlamaIndex"}),(0,t.jsx)(r.TabsTrigger,{value:"langchain",className:"rounded-none px-4 py-2 flex-none",children:"Langchain Py"})]}),(0,t.jsx)(r.TabsContent,{value:"openai",keepMounted:!0,children:(0,t.jsx)(n.default,{language:"python",code:`import openai
client = openai.OpenAI(
api_key="your_api_key",
base_url="${r}" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys
base_url="${s}" # LiteLLM Proxy is OpenAI compatible, Read More: https://docs.litellm.ai/docs/proxy/user_keys
)
response = client.chat.completions.create(
@ -14,7 +14,7 @@ response = client.chat.completions.create(
]
)
print(response)`})}),(0,t.jsx)(s.TabsContent,{value:"llamaindex",keepMounted:!0,children:(0,t.jsx)(n.default,{language:"python",code:`import os, dotenv
print(response)`})}),(0,t.jsx)(r.TabsContent,{value:"llamaindex",keepMounted:!0,children:(0,t.jsx)(n.default,{language:"python",code:`import os, dotenv
from llama_index.llms import AzureOpenAI
from llama_index.embeddings import AzureOpenAIEmbedding
@ -23,15 +23,15 @@ from llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext
llm = AzureOpenAI(
engine="azure-gpt-3.5", # model_name on litellm proxy
temperature=0.0,
azure_endpoint="${r}", # litellm proxy endpoint
api_key="sk-1234", # litellm proxy API Key
azure_endpoint="${s}", # litellm proxy endpoint
api_key="<your-master-key>", # litellm proxy API Key
api_version="2023-07-01-preview",
)
embed_model = AzureOpenAIEmbedding(
deployment_name="azure-embedding-model",
azure_endpoint="${r}",
api_key="sk-1234",
azure_endpoint="${s}",
api_key="<your-master-key>",
api_version="2023-07-01-preview",
)
@ -41,7 +41,7 @@ index = VectorStoreIndex.from_documents(documents, service_context=service_conte
query_engine = index.as_query_engine()
response = query_engine.query("What did the author do growing up?")
print(response)`})}),(0,t.jsx)(s.TabsContent,{value:"langchain",keepMounted:!0,children:(0,t.jsx)(n.default,{language:"python",code:`from langchain.chat_models import ChatOpenAI
print(response)`})}),(0,t.jsx)(r.TabsContent,{value:"langchain",keepMounted:!0,children:(0,t.jsx)(n.default,{language:"python",code:`from langchain.chat_models import ChatOpenAI
from langchain.prompts.chat import (
ChatPromptTemplate,
HumanMessagePromptTemplate,
@ -50,7 +50,7 @@ from langchain.prompts.chat import (
from langchain.schema import HumanMessage, SystemMessage
chat = ChatOpenAI(
openai_api_base="${r}",
openai_api_base="${s}",
model = "gpt-3.5-turbo",
temperature=0.1
)
@ -65,4 +65,4 @@ messages = [
]
response = chat(messages)
print(response)`})})]})]})})};var l=e.i(541202),d=e.i(135214),m=e.i(592392);e.s(["default",0,()=>{let{accessToken:e}=(0,d.default)(),n=(0,m.default)(e);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.DeprecationBanner,{featureName:"The API Reference tab"}),(0,t.jsx)(i,{proxySettings:n})]})}],191905)},541202,e=>{"use strict";var t=e.i(843476),n=e.i(271645),s=e.i(522016),r=e.i(952571),a=e.i(37727);e.s(["DeprecationBanner",0,({featureName:e})=>{let[o,i]=(0,n.useState)(!1);return o?null:(0,t.jsxs)("div",{role:"alert",className:"mb-4 flex items-start gap-3 rounded-lg border border-border bg-muted/50 px-4 py-3 text-sm",children:[(0,t.jsx)(r.Info,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"font-medium",children:`${e} is on a draft deprecation list`}),(0,t.jsxs)("p",{className:"mt-1 break-words text-muted-foreground",children:[`${e} is one of several experimental features we're considering removing, potentially as early as September 1, 2026. This list is a draft and is not final. If you rely on this feature, please share feedback on the `,(0,t.jsx)(s.default,{href:"https://github.com/BerriAI/litellm/discussions/32090",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-4",children:"deprecation discussion"}),"."]})]}),(0,t.jsx)("button",{type:"button","aria-label":"Close",onClick:()=>i(!0),className:"shrink-0 rounded-md p-0.5 text-muted-foreground transition-colors hover:text-foreground",children:(0,t.jsx)(a.X,{className:"size-4"})})]})}])}]);
print(response)`})})]})]})})};var l=e.i(541202),d=e.i(135214),m=e.i(592392);e.s(["default",0,()=>{let{accessToken:e}=(0,d.default)(),n=(0,m.default)(e);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.DeprecationBanner,{featureName:"The API Reference tab"}),(0,t.jsx)(i,{proxySettings:n})]})}],191905)},541202,e=>{"use strict";var t=e.i(843476),n=e.i(271645),r=e.i(522016),s=e.i(952571),a=e.i(37727);e.s(["DeprecationBanner",0,({featureName:e})=>{let[o,i]=(0,n.useState)(!1);return o?null:(0,t.jsxs)("div",{role:"alert",className:"mb-4 flex items-start gap-3 rounded-lg border border-border bg-muted/50 px-4 py-3 text-sm",children:[(0,t.jsx)(s.Info,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"font-medium",children:`${e} is on a draft deprecation list`}),(0,t.jsxs)("p",{className:"mt-1 break-words text-muted-foreground",children:[`${e} is one of several experimental features we're considering removing, potentially as early as September 1, 2026. This list is a draft and is not final. If you rely on this feature, please share feedback on the `,(0,t.jsx)(r.default,{href:"https://github.com/BerriAI/litellm/discussions/32090",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-4",children:"deprecation discussion"}),"."]})]}),(0,t.jsx)("button",{type:"button","aria-label":"Close",onClick:()=>i(!0),className:"shrink-0 rounded-md p-0.5 text-muted-foreground transition-colors hover:text-foreground",children:(0,t.jsx)(a.X,{className:"size-4"})})]})}])}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,312130,e=>{"use strict";var t=e.i(843476),l=e.i(271645),a=e.i(519455),o=e.i(515288),s=e.i(793479),r=e.i(110204),n=e.i(571303),i=e.i(275144),u=e.i(602869),d=e.i(417385);let c=({userID:e,userRole:c,accessToken:m})=>{let{setLogoUrl:h,setLogoUrlDark:g,setFaviconUrl:p}=(0,i.useTheme)(),[x,f]=(0,l.useState)(""),[v,j]=(0,l.useState)(""),[y,_]=(0,l.useState)(""),[b,C]=(0,l.useState)(!1);(0,l.useEffect)(()=>{m&&L()},[m]);let L=async()=>{try{let e=(0,u.getProxyBaseUrl)(),t=e?`${e}/get/ui_theme_settings`:"/get/ui_theme_settings",l=await fetch(t,{method:"GET",headers:{[(0,u.getGlobalLitellmHeaderName)()]:`Bearer ${m}`,"Content-Type":"application/json"}});if(l.ok){let e=await l.json();f(e.values?.logo_url||""),j(e.values?.logo_url_dark||""),_(e.values?.favicon_url||""),h(e.values?.logo_url||null),g(e.values?.logo_url_dark||null),p(e.values?.favicon_url||null)}}catch(e){console.error("Error fetching theme settings:",e)}},N=async()=>{C(!0);try{let e=(0,u.getProxyBaseUrl)(),t=e?`${e}/update/ui_theme_settings`:"/update/ui_theme_settings";if((await fetch(t,{method:"PATCH",headers:{[(0,u.getGlobalLitellmHeaderName)()]:`Bearer ${m}`,"Content-Type":"application/json"},body:JSON.stringify({logo_url:x||null,logo_url_dark:v||null,favicon_url:y||null})})).ok)d.toast.success("Theme settings updated successfully!"),h(x||null),g(v||null),p(y||null);else throw Error("Failed to update settings")}catch(e){console.error("Error updating theme settings:",e),d.toast.fromError("Failed to update theme settings")}finally{C(!1)}},k=async()=>{f(""),j(""),_(""),h(null),g(null),p(null),C(!0);try{let e=(0,u.getProxyBaseUrl)(),t=e?`${e}/update/ui_theme_settings`:"/update/ui_theme_settings";if((await fetch(t,{method:"PATCH",headers:{[(0,u.getGlobalLitellmHeaderName)()]:`Bearer ${m}`,"Content-Type":"application/json"},body:JSON.stringify({logo_url:null,logo_url_dark:null,favicon_url:null})})).ok)d.toast.success("Theme settings reset to default!");else throw Error("Failed to reset")}catch(e){console.error("Error resetting theme settings:",e),d.toast.fromError("Failed to reset theme settings")}finally{C(!1)}};return m?(0,t.jsxs)("div",{className:"w-full mx-auto max-w-4xl px-6 py-8",children:[(0,t.jsxs)("div",{className:"mb-8",children:[(0,t.jsx)("h1",{className:"mb-2 text-2xl font-bold",children:"UI Theme Customization"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Customize your LiteLLM admin dashboard with a custom logo and favicon."})]}),(0,t.jsx)(o.Card,{children:(0,t.jsxs)(o.CardContent,{className:"space-y-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(r.Label,{htmlFor:"ui-theme-logo-url",className:"mb-2",children:"Custom Logo URL"}),(0,t.jsx)(s.Input,{id:"ui-theme-logo-url",placeholder:"https://example.com/logo.png",value:x,onChange:e=>{f(e.target.value),h(e.target.value||null)}}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Enter a URL for your custom logo or leave empty for default"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(r.Label,{htmlFor:"ui-theme-logo-url-dark",className:"mb-2",children:"Custom Logo URL (dark mode)"}),(0,t.jsx)(s.Input,{id:"ui-theme-logo-url-dark",placeholder:"https://example.com/logo-dark.png",value:v,onChange:e=>{j(e.target.value),g(e.target.value||null)}}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Enter a URL for a logo suited to dark backgrounds, or leave empty to reuse the logo above"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(r.Label,{htmlFor:"ui-theme-favicon-url",className:"mb-2",children:"Custom Favicon URL"}),(0,t.jsx)(s.Input,{id:"ui-theme-favicon-url",placeholder:"https://example.com/favicon.ico",value:y,onChange:e=>{_(e.target.value),p(e.target.value||null)}}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Enter a URL for your custom favicon (.ico, .png, or .svg) or leave empty for default"})]}),(0,t.jsxs)("div",{className:"flex gap-3 pt-4",children:[(0,t.jsxs)(a.Button,{onClick:N,disabled:b,children:[b&&(0,t.jsx)(n.UiLoadingSpinner,{className:"size-4"}),"Save Changes"]}),(0,t.jsxs)(a.Button,{variant:"outline",onClick:k,disabled:b,children:[b&&(0,t.jsx)(n.UiLoadingSpinner,{className:"size-4"}),"Reset to Default"]})]})]})})]}):null};var m=e.i(135214);e.s(["default",0,function(){let{accessToken:e,userRole:l,userId:a}=(0,m.default)();return(0,t.jsx)(c,{userID:a,userRole:l,accessToken:e})}],312130)}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,269638,t=>{"use strict";let a=(0,t.i(475254).default)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);t.s(["CheckCircle",0,a],269638)},431343,t=>{"use strict";let a=(0,t.i(475254).default)("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);t.s(["Play",0,a],431343)},868499,t=>{"use strict";var a=t.i(843476);t.s([],558762),t.i(558762);var e=t.i(366250),o=t.i(402820),l=t.i(156736),r=t.i(209793),i=t.i(784324),n=t.i(264951),s=t.i(77173);let d=t.i(313488).DialogTrigger;var u=t.i(974217),g=t.i(325326),c=t.i(301807);let p={modal:!0,disablePointerDismissal:!0,role:"alertdialog"};class f extends g.DialogHandle{constructor(t){super(t??new c.DialogStore(p)),t&&this.store.update(p)}}t.s(["Backdrop",()=>o.DialogBackdrop,"Close",()=>l.DialogClose,"Description",()=>r.DialogDescription,"Handle",0,f,"Popup",()=>i.DialogPopup,"Portal",()=>n.DialogPortal,"Root",0,function(t){return(0,e.useRenderDialogRoot)(t,"alert-dialog")},"Title",()=>s.DialogTitle,"Trigger",0,d,"Viewport",()=>u.DialogViewport,"createHandle",0,function(){return new f}],734604);var m=t.i(734604),m=m,x=t.i(196631),D=t.i(519455);function j({...t}){return(0,a.jsx)(m.Portal,{"data-slot":"alert-dialog-portal",...t})}function z({className:t,...e}){return(0,a.jsx)(m.Backdrop,{"data-slot":"alert-dialog-overlay",className:(0,x.cn)("fixed inset-0 isolate z-popup bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",t),...e})}t.s(["AlertDialog",0,function({...t}){return(0,a.jsx)(m.Root,{"data-slot":"alert-dialog",...t})},"AlertDialogAction",0,function({className:t,variant:e="default",size:o="default",...l}){return(0,a.jsx)(m.Close,{"data-slot":"alert-dialog-action",className:(0,x.cn)(t),render:(0,a.jsx)(D.Button,{variant:e,size:o}),...l})},"AlertDialogCancel",0,function({className:t,variant:e="outline",size:o="default",...l}){return(0,a.jsx)(m.Close,{"data-slot":"alert-dialog-cancel",className:(0,x.cn)(t),render:(0,a.jsx)(D.Button,{variant:e,size:o}),...l})},"AlertDialogContent",0,function({className:t,size:e="default",...o}){return(0,a.jsxs)(j,{children:[(0,a.jsx)(z,{}),(0,a.jsx)(m.Popup,{"data-slot":"alert-dialog-content","data-size":e,className:(0,x.cn)("group/alert-dialog-content fixed top-1/2 left-1/2 z-popup grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...o})]})},"AlertDialogDescription",0,function({className:t,...e}){return(0,a.jsx)(m.Description,{"data-slot":"alert-dialog-description",className:(0,x.cn)("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),...e})},"AlertDialogFooter",0,function({className:t,...e}){return(0,a.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,x.cn)("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),...e})},"AlertDialogHeader",0,function({className:t,...e}){return(0,a.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,x.cn)("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),...e})},"AlertDialogTitle",0,function({className:t,...e}){return(0,a.jsx)(m.Title,{"data-slot":"alert-dialog-title",className:(0,x.cn)("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),...e})},"AlertDialogTrigger",0,function({...t}){return(0,a.jsx)(m.Trigger,{"data-slot":"alert-dialog-trigger",...t})}],868499)}]);

View file

@ -0,0 +1 @@
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,595468,e=>{"use strict";var i=e.i(123287);e.s(["CheckCircle2",()=>i.default])},798031,e=>{"use strict";let i=(0,e.i(475254).default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);e.s(["default",0,i])},373884,e=>{"use strict";var i=e.i(798031);e.s(["XCircle",()=>i.default])},77705,e=>{"use strict";let i=(0,e.i(475254).default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);e.s(["EyeOff",0,i],77705)},286536,e=>{"use strict";let i=(0,e.i(475254).default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["Eye",0,i],286536)},450240,e=>{"use strict";var i=e.i(843476),r=e.i(286536),t=e.i(77705),d=e.i(271645),s=e.i(950594);let a=d.forwardRef(({className:e,groupClassName:a,disabled:l,...o},c)=>{let[n,u]=d.useState(!1);return(0,i.jsxs)(s.InputGroup,{className:a,children:[(0,i.jsx)(s.InputGroupInput,{...o,ref:c,type:n?"text":"password",disabled:l,className:e}),(0,i.jsx)(s.InputGroupAddon,{align:"inline-end",children:(0,i.jsx)(s.InputGroupButton,{size:"icon-xs",disabled:l,"aria-label":n?"Hide password":"Show password",onClick:()=>u(e=>!e),children:n?(0,i.jsx)(t.EyeOff,{}):(0,i.jsx)(r.Eye,{})})})]})});a.displayName="PasswordInput",e.s(["PasswordInput",0,a])},182668,e=>{"use strict";var i=e.i(843476),r=e.i(271645),t=e.i(653145),d=e.i(542450);e.s(["FormField",0,({control:e,name:s,label:a,description:l,orientation:o,className:c,children:n})=>{let u=r.useId(),p=`${u}-control`,y=`${u}-description`,h=`${u}-error`;return(0,i.jsx)(t.Controller,{control:e,name:s,render:({field:e,fieldState:r})=>{let t=void 0!==r.error,s=[void 0!==l?y:void 0,t?h:void 0].filter(e=>void 0!==e).join(" ")||void 0,u={...e,id:p,"aria-invalid":t||void 0,"aria-describedby":s};return(0,i.jsxs)(d.Field,{orientation:o,"data-invalid":t||void 0,className:c,children:[void 0!==a&&(0,i.jsx)(d.FieldLabel,{htmlFor:p,children:a}),n(u),void 0!==l&&(0,i.jsx)(d.FieldDescription,{id:y,children:l}),(0,i.jsx)(d.FieldError,{id:h,errors:[r.error]})]})}})}])}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,35440,e=>{"use strict";var t=e.i(843476),s=e.i(405033),a=e.i(271645),l=e.i(217923),d=e.i(266027),r=e.i(602869),i=e.i(519455),o=e.i(302747);function n(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function u({data:e,maxVal:s}){let a=Math.max(2,Math.floor(200/Math.max(e.length,1)));return(0,t.jsx)("div",{className:"flex items-end gap-px",style:{height:48},children:e.map((e,l)=>{let d=s>0?Math.max(2,e/s*48):2;return(0,t.jsx)("div",{className:"bg-primary rounded-[1px]",style:{width:a,height:d,opacity:.7+e/Math.max(s,1)*.3}},l)})})}let c=[{value:"7d",label:"7d"},{value:"30d",label:"30d"},{value:"90d",label:"90d"}],m=({accessToken:e,userId:s})=>{let m,x,[h,v]=(0,a.useState)("30d"),{start:g,end:b}=(m=new Date,(x=new Date).setDate(m.getDate()-("7d"===h?7:"30d"===h?30:90)),{start:x,end:m}),{data:p,isLoading:f}=(0,d.useQuery)({queryKey:["chat-user-usage",e,s,h],queryFn:()=>(0,r.dailyActivityAggregatedCall)("user",{accessToken:e,startTime:g,endTime:b,entityIds:s?[s]:null}),enabled:!!e}),j=p?.metadata,N=p?.results??[],_=N.map(e=>e.metrics.spend),y=N.map(e=>e.metrics.api_requests),q=Math.max(..._,0),S=Math.max(...y,0),k=j?[{label:"Total Spend",value:`$${j.total_spend.toFixed(2)}`},{label:"API Requests",value:n(j.total_api_requests)},{label:"Tokens Used",value:n(j.total_tokens),sub:`${n(j.total_prompt_tokens)} in / ${n(j.total_completion_tokens)} out`},{label:"Success Rate",value:j.total_api_requests>0?`${(j.total_successful_requests/j.total_api_requests*100).toFixed(1)}%`:"N/A",sub:j.total_failed_requests>0?`${j.total_failed_requests} failed`:void 0,subVariant:j.total_failed_requests>0?"error":void 0}]:[];return(0,t.jsxs)("div",{className:"w-full",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-semibold text-foreground mb-0.5",children:"Your Usage"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground m-0",children:"Spend and request activity"})]}),(0,t.jsx)("div",{className:"flex gap-1",children:c.map(e=>(0,t.jsx)(i.Button,{variant:h===e.value?"default":"outline",size:"sm",onClick:()=>v(e.value),children:e.label},e.value))})]}),f?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3",children:[void 0,void 0,void 0,void 0].map((e,s)=>(0,t.jsxs)("div",{className:"border rounded-lg p-4 bg-card flex flex-col gap-2",children:[(0,t.jsx)(o.Skeleton,{className:"h-3 w-1/2"}),(0,t.jsx)(o.Skeleton,{className:"h-5 w-2/3"})]},s))}):j&&0!==j.total_api_requests?(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3 mb-5",children:k.map(e=>(0,t.jsxs)("div",{className:"border rounded-lg p-4 bg-card",children:[(0,t.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:e.label}),(0,t.jsx)("div",{className:"text-xl font-semibold text-foreground",children:e.value}),e.sub&&(0,t.jsx)("div",{className:`text-xs mt-0.5 ${"error"===e.subVariant?"text-destructive":"text-muted-foreground"}`,children:e.sub})]},e.label))}),N.length>1&&(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"border rounded-lg p-4 bg-card",children:[(0,t.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:"Daily Spend"}),(0,t.jsx)(u,{data:_,maxVal:q})]}),(0,t.jsxs)("div",{className:"border rounded-lg p-4 bg-card",children:[(0,t.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:"Daily Requests"}),(0,t.jsx)(u,{data:y,maxVal:S})]})]})]}):(0,t.jsxs)("div",{className:"text-center text-muted-foreground text-sm py-12 border border-dashed rounded-lg",children:[(0,t.jsx)(l.BarChart3,{className:"h-6 w-6 mb-3 mx-auto text-muted-foreground/50"}),"No usage data for this period"]})]})};e.s(["default",0,function(){let{accessToken:e,userId:a}=(0,s.useChatShell)();return(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-auto w-full py-8 px-8",children:(0,t.jsx)(m,{accessToken:e,userId:a})})}],35440)},302747,e=>{"use strict";var t=e.i(843476),s=e.i(196631);e.s(["Skeleton",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"skeleton",className:(0,s.cn)("animate-pulse rounded-md bg-muted",e),...a})}])}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show more