From 70f05ec763579ba75ff30b6fe984ee40ba48dfc5 Mon Sep 17 00:00:00 2001 From: andrepat0 Date: Wed, 9 Oct 2024 12:20:20 +0200 Subject: [PATCH] feat: added mistral and anthropic to completion provider status --- .../CompletionProviderStatus.tsx | 36 +++++++++++++++++-- .../CompletionProviderStatus.test.tsx.snap | 18 ++++++++++ src/components/MemoriWidget/MemoriWidget.tsx | 3 +- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx b/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx index 487c80d4..7fed63de 100644 --- a/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx +++ b/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx @@ -22,7 +22,6 @@ const initProviderStatus = ( statusPage: string; } => { switch (provider) { - case 'DEFAULT': case 'OpenAI': return { getStatus: async () => { @@ -37,6 +36,34 @@ const initProviderStatus = ( }, statusPage: 'https://status.openai.com/', }; + case 'Mistral': + return { + getStatus: async () => { + const res = await fetch( + 'https://status.mistral-data.com/api/v2/summary.json' + ); + const data = await res.json(); + const status = data.components.find( + (component: { name: string }) => component.name === 'API' + )?.status as Status; + return status ?? 'operational'; + }, + statusPage: 'https://status.mistral-data.com/', + }; + case 'Anthropic': + return { + getStatus: async () => { + const res = await fetch( + 'https://status.anthropic.com/api/v2/summary.json' + ); + const data = await res.json(); + const status = data.components.find( + (component: { name: string }) => component.name === 'API' + )?.status as Status; + return status ?? 'operational'; + }, + statusPage: 'https://status.anthropic.com/', + }; default: return { getStatus: async () => 'operational', @@ -45,7 +72,10 @@ const initProviderStatus = ( } }; -const CompletionProviderStatus = ({ forceStatus, provider }: Props) => { +const CompletionProviderStatus = ({ + forceStatus, + provider = 'OpenAI', +}: Props) => { const { t } = useTranslation(); const [status, setStatus] = useState(forceStatus ?? 'operational'); @@ -58,7 +88,7 @@ const CompletionProviderStatus = ({ forceStatus, provider }: Props) => { .getStatus() .then(status => setStatus(status)) .catch(console.log); - }, [forceStatus, provider]); + }, [forceStatus, providerStatus]); return status !== 'operational' ? ( completionProviderDown

+

+ + completionProviderCheckStatusPage + +

completionProviderDown

+

+ + completionProviderCheckStatusPage + +

${replaceTextWithPhonemes( + )}">${replaceTextWithPhonemes( escapeHTML(stripMarkdown(stripEmojis(stripOutputTags(text)))), userLang.toLowerCase() )}`,