Merge pull request #4166 from BerriAI/litellm_use_local_model_cost_map

[Fix] -  Error selecting model provider from UI
This commit is contained in:
Ishaan Jaff
2024-06-12 20:08:56 -07:00
committed by GitHub
2 changed files with 19 additions and 2 deletions
+16
View File
@@ -14738,6 +14738,22 @@ async def cache_flushall():
)
@router.get(
"/get/litellm_model_cost_map",
include_in_schema=False,
dependencies=[Depends(user_api_key_auth)],
)
async def get_litellm_model_cost_map():
try:
_model_cost_map = litellm.model_cost
return _model_cost_map
except Exception as e:
raise HTTPException(
status_code=500,
detail=f"Internal Server Error ({str(e)})",
)
@router.get("/", dependencies=[Depends(user_api_key_auth)])
async def home(request: Request):
return "LiteLLM: RUNNING"
@@ -14,11 +14,12 @@ export interface Model {
export const modelCostMap = async () => {
try {
const url = proxyBaseUrl ? `${proxyBaseUrl}/get/litellm_model_cost_map` : `/get/litellm_model_cost_map`;
const response = await fetch(
"https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"
url
);
const jsonData = await response.json();
console.log(`received data: ${jsonData}`);
console.log(`received litellm model cost data: ${jsonData}`);
return jsonData;
} catch (error) {
console.error("Failed to get model cost map:", error);