import React, { useEffect, useState } from "react"; import System from "@/models/system"; import { OLLAMA_COMMON_URLS } from "@/utils/constants"; import { CaretDown, CaretUp, Info, CircleNotch } from "@phosphor-icons/react"; import useProviderEndpointAutoDiscovery from "@/hooks/useProviderEndpointAutoDiscovery"; import { Tooltip } from "react-tooltip"; import { Link } from "react-router-dom"; export default function OllamaLLMOptions({ settings }) { const { autoDetecting: loading, basePath, basePathValue, authToken, authTokenValue, showAdvancedControls, setShowAdvancedControls, handleAutoDetectClick, } = useProviderEndpointAutoDiscovery({ provider: "ollama", initialBasePath: settings?.OllamaLLMBasePath, ENDPOINTS: OLLAMA_COMMON_URLS, }); const [maxTokens, setMaxTokens] = useState( settings?.OllamaLLMTokenLimit || "" ); return (
); } function OllamaLLMModelSelection({ settings, basePath = null, authToken = null, }) { const [customModels, setCustomModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!basePath) { setCustomModels([]); setLoading(false); return; } setLoading(true); try { const { models } = await System.customModels( "ollama", authToken, basePath ); setCustomModels(models || []); } catch (error) { console.error("Failed to fetch custom models:", error); setCustomModels([]); } setLoading(false); } findCustomModels(); }, [basePath, authToken]); if (loading || customModels.length === 0) { return (

Select the Ollama model you want to use. Models will load after entering a valid Ollama URL.

); } return (

Choose the Ollama model you want to use for your conversations.

); }