mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
allow clicking into keys
This commit is contained in:
parent
063aedc6c6
commit
2c4dd29944
2 changed files with 37 additions and 8 deletions
|
|
@ -0,0 +1,28 @@
|
|||
import { KeyResponse } from "./key_list";
|
||||
|
||||
export const transformKeyInfo = (apiResponse: any): KeyResponse => {
|
||||
const { key, info } = apiResponse;
|
||||
|
||||
return {
|
||||
token: key,
|
||||
key_name: info.key_name,
|
||||
key_alias: info.key_alias,
|
||||
spend: info.spend,
|
||||
expires: info.expires,
|
||||
models: info.models,
|
||||
aliases: info.aliases,
|
||||
config: info.config,
|
||||
user_id: info.user_id,
|
||||
team_id: info.team_id,
|
||||
permissions: info.permissions,
|
||||
max_parallel_requests: info.max_parallel_requests,
|
||||
metadata: info.metadata,
|
||||
tpm_limit: info.tpm_limit,
|
||||
rpm_limit: info.rpm_limit,
|
||||
max_budget: info.max_budget,
|
||||
budget_duration: info.budget_duration,
|
||||
organization_id: info.organization_id,
|
||||
created_at: info.created_at,
|
||||
litellm_budget_table: info.litellm_budget_table,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
import React, { useState } from "react";
|
||||
import { BarChart } from "@tremor/react";
|
||||
import KeyInfoView from "./key_info_view";
|
||||
import { keyInfoCall } from "./networking";
|
||||
import { keyInfoV1Call } from "./networking";
|
||||
import { transformKeyInfo } from "../components/key_team_helpers/transform_key_info";
|
||||
|
||||
interface TopKeyViewProps {
|
||||
topKeys: any[];
|
||||
|
|
@ -22,15 +23,15 @@ const TopKeyView: React.FC<TopKeyViewProps> = ({
|
|||
const [keyData, setKeyData] = useState<any | undefined>(undefined);
|
||||
|
||||
const handleKeyClick = async (item: any) => {
|
||||
if (!accessToken || !item.key) return;
|
||||
if (!accessToken) return;
|
||||
|
||||
console.log("Clicked item:", item);
|
||||
try {
|
||||
// Get the full key data using the API key
|
||||
const keyInfo = await keyInfoCall(accessToken, [item.key]);
|
||||
if (keyInfo && keyInfo.keys && keyInfo.keys.length > 0) {
|
||||
setKeyData(keyInfo.keys[0]);
|
||||
setSelectedKey(item.key);
|
||||
}
|
||||
// Use item.key instead of item.api_key
|
||||
const keyInfo = await keyInfoV1Call(accessToken, item.api_key);
|
||||
const transformedKeyData = transformKeyInfo(keyInfo);
|
||||
setKeyData(transformedKeyData);
|
||||
setSelectedKey(item.key);
|
||||
} catch (error) {
|
||||
console.error("Error fetching key info:", error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue