import { useQuery } from "@tanstack/react-query" import { RotateCcw } from "lucide-react" import { useEffect, useState } from "react" import { useTranslation } from "react-i18next" import { getOllamaURL, isOllamaRunning, setOllamaURL as saveOllamaURL } from "~/services/ollama" export const PlaygroundEmpty = () => { const [ollamaURL, setOllamaURL] = useState("") const { t } = useTranslation(["playground", "common"]) const { data: ollamaInfo, status: ollamaStatus, refetch, isRefetching } = useQuery({ queryKey: ["ollamaStatus"], queryFn: async () => { const ollamaURL = await getOllamaURL() const isOk = await isOllamaRunning() return { isOk, ollamaURL } } }) useEffect(() => { if (ollamaInfo?.ollamaURL) { setOllamaURL(ollamaInfo.ollamaURL) } }, [ollamaInfo]) return (
{(ollamaStatus === "pending" || isRefetching) && (

{t("ollamaState.searching")}

)} {!isRefetching && ollamaStatus === "success" ? ( ollamaInfo.isOk ? (

{t("ollamaState.running")}

) : (

{t("ollamaState.notRunning")}

setOllamaURL(e.target.value)} />
) ) : null}
) }