fix: use exponential backoff when checking ollama

This commit is contained in:
Test 2024-09-20 13:46:26 -07:00
parent bc9ab73951
commit ebbc2fd55d

View file

@ -1,6 +1,7 @@
import { useContext, useEffect } from "react";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
import { ONBOARDING_LOCAL_MODEL_TITLE } from "core/config/onboarding";
import { withExponentialBackoff } from "core/util/withExponentialBackoff";
const CHECK_OLLAMA_CONNECTION_INTERVAL = 1000;
@ -11,9 +12,11 @@ export const useCheckOllamaModels = (
useEffect(() => {
const fetchDownloadedModels = async () => {
const result = (await ideMessenger.request("llm/listModels", {
title: ONBOARDING_LOCAL_MODEL_TITLE,
})) as any;
const result = await withExponentialBackoff(() =>
ideMessenger.request("llm/listModels", {
title: ONBOARDING_LOCAL_MODEL_TITLE,
})
);
if (result.status === "success") {
const models = result.content;