From 96b6ea9568e53c307e154c83f68e4ed5e90d2ea1 Mon Sep 17 00:00:00 2001 From: nai-degen Date: Sat, 9 Mar 2024 13:25:50 -0600 Subject: [PATCH] adds azure-image endpoint to service info; hides unavailable endpoints --- src/service-info.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/service-info.ts b/src/service-info.ts index 9aaef2f..7e8d04c 100644 --- a/src/service-info.ts +++ b/src/service-info.ts @@ -90,13 +90,14 @@ export type ServiceInfo = { endpoints: { openai?: string; openai2?: string; - "openai-image"?: string; anthropic?: string; "anthropic-claude-3"?: string; "google-ai"?: string; "mistral-ai"?: string; aws?: string; azure?: string; + "openai-image"?: string; + "azure-image"?: string; }; proompts?: number; tookens?: string; @@ -149,6 +150,7 @@ const SERVICE_ENDPOINTS: { [s in LLMService]: Record } = { }, azure: { azure: `%BASE%/azure/openai`, + "azure-image": `%BASE%/azure/openai`, }, }; @@ -216,7 +218,12 @@ function getStatus() { function getEndpoints(baseUrl: string, accessibleFamilies: Set) { const endpoints: Record = {}; + const keys = keyPool.list(); for (const service of LLM_SERVICES) { + if (!keys.some((k) => k.service === service)) { + continue; + } + for (const [name, url] of Object.entries(SERVICE_ENDPOINTS[service])) { endpoints[name] = url.replace("%BASE%", baseUrl); } @@ -224,6 +231,10 @@ function getEndpoints(baseUrl: string, accessibleFamilies: Set) { if (service === "openai" && !accessibleFamilies.has("dall-e")) { delete endpoints["openai-image"]; } + + if (service === "azure" && !accessibleFamilies.has("azure-dall-e")) { + delete endpoints["azure-image"]; + } } return endpoints; }