repo
stringlengths
5
106
file_url
stringlengths
78
301
file_path
stringlengths
4
211
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:56:49
2026-01-05 02:23:25
truncated
bool
2 classes
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/VectorDatabase/DocumentSimilarityThreshold/index.jsx
frontend/src/pages/WorkspaceSettings/VectorDatabase/DocumentSimilarityThreshold/index.jsx
import { useTranslation } from "react-i18next"; export default function DocumentSimilarityThreshold({ workspace, setHasChanges, }) { const { t } = useTranslation(); return ( <div> <div className="flex flex-col"> <label htmlFor="name" className="block input-label"> {t("vector-workspace.doc.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("vector-workspace.doc.description")} </p> </div> <select name="similarityThreshold" defaultValue={workspace?.similarityThreshold ?? 0.25} className="border-none bg-theme-settings-input-bg text-white text-sm mt-2 rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" onChange={() => setHasChanges(true)} required={true} > <option value={0.0}>{t("vector-workspace.doc.zero")}</option> <option value={0.25}>{t("vector-workspace.doc.low")}</option> <option value={0.5}>{t("vector-workspace.doc.medium")}</option> <option value={0.75}>{t("vector-workspace.doc.high")}</option> </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/VectorDatabase/ResetDatabase/index.jsx
frontend/src/pages/WorkspaceSettings/VectorDatabase/ResetDatabase/index.jsx
import { useState } from "react"; import Workspace from "@/models/workspace"; import showToast from "@/utils/toast"; import { useTranslation } from "react-i18next"; export default function ResetDatabase({ workspace }) { const [deleting, setDeleting] = useState(false); const { t } = useTranslation(); const resetVectorDatabase = async () => { if (!window.confirm(`${t("vector-workspace.reset.confirm")}`)) return false; setDeleting(true); const success = await Workspace.wipeVectorDb(workspace.slug); if (!success) { showToast( t("vector-workspace.reset.error"), t("vector-workspace.common.error"), { clear: true, } ); setDeleting(false); return; } showToast( t("vector-workspace.reset.success"), t("vector-workspace.common.success"), { clear: true, } ); setDeleting(false); }; return ( <button disabled={deleting} onClick={resetVectorDatabase} type="button" className="w-60 transition-all duration-300 border border-transparent rounded-lg whitespace-nowrap text-sm px-5 py-2.5 focus:z-10 bg-red-500/25 text-red-200 light:text-red-500 hover:light:text-[#FFFFFF] hover:text-[#FFFFFF] hover:bg-red-600 disabled:bg-red-600 disabled:text-red-200 disabled:animate-pulse" > {deleting ? t("vector-workspace.reset.resetting") : t("vector-workspace.reset.reset")} </button> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/VectorDatabase/VectorCount/index.jsx
frontend/src/pages/WorkspaceSettings/VectorDatabase/VectorCount/index.jsx
import PreLoader from "@/components/Preloader"; import System from "@/models/system"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; export default function VectorCount({ reload, workspace }) { const [totalVectors, setTotalVectors] = useState(null); const { t } = useTranslation(); useEffect(() => { async function fetchVectorCount() { const totalVectors = await System.totalIndexes(workspace.slug); setTotalVectors(totalVectors); } fetchVectorCount(); }, [workspace?.slug, reload]); if (totalVectors === null) return ( <div> <h3 className="input-label">{t("general.vector.title")}</h3> <p className="text-white text-opacity-60 text-xs font-medium py-1"> {t("general.vector.description")} </p> <div className="text-white text-opacity-60 text-sm font-medium"> <PreLoader size="4" /> </div> </div> ); return ( <div> <h3 className="input-label">{t("general.vector.title")}</h3> <p className="text-white text-opacity-60 text-sm font-medium"> {totalVectors} </p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/AgentConfig/index.jsx
frontend/src/pages/WorkspaceSettings/AgentConfig/index.jsx
import System from "@/models/system"; import Workspace from "@/models/workspace"; import showToast from "@/utils/toast"; import { castToType } from "@/utils/types"; import { useEffect, useRef, useState } from "react"; import AgentLLMSelection from "./AgentLLMSelection"; import Admin from "@/models/admin"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; import paths from "@/utils/paths"; import useUser from "@/hooks/useUser"; export default function WorkspaceAgentConfiguration({ workspace }) { const { user } = useUser(); const [settings, setSettings] = useState({}); const [hasChanges, setHasChanges] = useState(false); const [saving, setSaving] = useState(false); const [loading, setLoading] = useState(true); const formEl = useRef(null); useEffect(() => { async function fetchSettings() { const _settings = await System.keys(); const _preferences = await Admin.systemPreferences(); setSettings({ ..._settings, preferences: _preferences.settings } ?? {}); setLoading(false); } fetchSettings(); }, []); const handleUpdate = async (e) => { setSaving(true); e.preventDefault(); const data = { workspace: {}, system: {}, env: {}, }; const form = new FormData(formEl.current); for (var [key, value] of form.entries()) { if (key.startsWith("system::")) { const [_, label] = key.split("system::"); data.system[label] = String(value); continue; } if (key.startsWith("env::")) { const [_, label] = key.split("env::"); data.env[label] = String(value); continue; } data.workspace[key] = castToType(key, value); } const { workspace: updatedWorkspace, message } = await Workspace.update( workspace.slug, data.workspace ); await Admin.updateSystemPreferences(data.system); await System.updateSystem(data.env); if (!!updatedWorkspace) { showToast("Workspace updated!", "success", { clear: true }); } else { showToast(`Error: ${message}`, "error", { clear: true }); } setSaving(false); setHasChanges(false); }; if (!workspace || loading) return <LoadingSkeleton />; return ( <div id="workspace-agent-settings-container"> <form ref={formEl} onSubmit={handleUpdate} onChange={() => setHasChanges(true)} id="agent-settings-form" className="w-1/2 flex flex-col gap-y-6" > <AgentLLMSelection settings={settings} workspace={workspace} setHasChanges={setHasChanges} /> {(!user || user?.role === "admin") && ( <> {!hasChanges && ( <div className="flex flex-col gap-y-4"> <a className="w-fit transition-all duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800" href={paths.settings.agentSkills()} > Configure Agent Skills </a> <p className="text-white text-opacity-60 text-xs font-medium"> Customize and enhance the default agent's capabilities by enabling or disabling specific skills. These settings will be applied across all workspaces. </p> </div> )} </> )} {hasChanges && ( <button type="submit" form="agent-settings-form" className="w-fit transition-all duration-300 border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800" > {saving ? "Updating agent..." : "Update workspace agent"} </button> )} </form> </div> ); } function LoadingSkeleton() { return ( <div id="workspace-agent-settings-container"> <div className="w-1/2 flex flex-col gap-y-6"> <Skeleton.default height={100} width="100%" count={2} highlightColor="var(--theme-bg-primary)" baseColor="var(--theme-bg-secondary)" enableAnimation={true} containerClassName="flex flex-col gap-y-1" /> <div className="bg-white/10 h-[1px] w-full" /> <Skeleton.default height={100} width="100%" count={2} highlightColor="var(--theme-bg-primary)" baseColor="var(--theme-bg-secondary)" enableAnimation={true} containerClassName="flex flex-col gap-y-1 mt-4" /> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/AgentConfig/AgentModelSelection/index.jsx
frontend/src/pages/WorkspaceSettings/AgentConfig/AgentModelSelection/index.jsx
import useGetProviderModels, { DISABLED_PROVIDERS, } from "@/hooks/useGetProvidersModels"; import paths from "@/utils/paths"; import { useTranslation } from "react-i18next"; import { Link, useParams } from "react-router-dom"; /** * These models do NOT support function calling * or do not support system prompts * and therefore are not supported for agents. * @param {string} provider - The AI provider. * @param {string} model - The model name. * @returns {boolean} Whether the model is supported for agents. */ function supportedModel(provider, model = "") { if (provider === "openai") { return ( [ "gpt-3.5-turbo-0301", "gpt-4-turbo-2024-04-09", "gpt-4-turbo", "o1-preview", "o1-preview-2024-09-12", "o1-mini", "o1-mini-2024-09-12", "o3-mini", "o3-mini-2025-01-31", ].includes(model) === false ); } return true; } export default function AgentModelSelection({ provider, workspace, setHasChanges, }) { const { slug } = useParams(); const { defaultModels, customModels, loading } = useGetProviderModels(provider); const { t } = useTranslation(); if (DISABLED_PROVIDERS.includes(provider)) { return ( <div className="w-full h-10 justify-center items-center flex"> <p className="text-sm font-base text-white text-opacity-60 text-center"> Multi-model support is not supported for this provider yet. <br /> Agent's will use{" "} <Link to={paths.workspace.settings.chatSettings(slug)} className="underline" > the model set for the workspace </Link>{" "} or{" "} <Link to={paths.settings.llmPreference()} className="underline"> the model set for the system. </Link> </p> </div> ); } if (loading) { return ( <div> <div className="flex flex-col"> <label htmlFor="name" className="block input-label"> {t("agent.mode.chat.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("agent.mode.chat.description")} </p> </div> <select name="agentModel" required={true} disabled={true} className="border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" > <option disabled={true} selected={true}> {t("agent.mode.wait")} </option> </select> </div> ); } return ( <div> <div className="flex flex-col"> <label htmlFor="name" className="block input-label"> {t("agent.mode.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("agent.mode.description")} </p> </div> <select name="agentModel" required={true} onChange={() => { setHasChanges(true); }} className="border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" > {defaultModels.length > 0 && ( <optgroup label="General models"> {defaultModels.map((model) => { if (!supportedModel(provider, model)) return null; return ( <option key={model} value={model} selected={workspace?.agentModel === model} > {model} </option> ); })} </optgroup> )} {Array.isArray(customModels) && customModels.length > 0 && ( <optgroup label="Custom models"> {customModels.map((model) => { if (!supportedModel(provider, model.id)) return null; return ( <option key={model.id} value={model.id} selected={workspace?.agentModel === model.id} > {model.id} </option> ); })} </optgroup> )} {/* For providers like TogetherAi where we partition model by creator entity. */} {!Array.isArray(customModels) && Object.keys(customModels).length > 0 && ( <> {Object.entries(customModels).map(([organization, models]) => ( <optgroup key={organization} label={organization}> {models.map((model) => { if (!supportedModel(provider, model.id)) return null; return ( <option key={model.id} value={model.id} selected={workspace?.agentModel === model.id} > {model.name} </option> ); })} </optgroup> ))} </> )} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/AgentConfig/AgentLLMSelection/index.jsx
frontend/src/pages/WorkspaceSettings/AgentConfig/AgentLLMSelection/index.jsx
import React, { useEffect, useRef, useState } from "react"; import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png"; import AgentLLMItem from "./AgentLLMItem"; import { AVAILABLE_LLM_PROVIDERS } from "@/pages/GeneralSettings/LLMPreference"; import { CaretUpDown, Gauge, MagnifyingGlass, X } from "@phosphor-icons/react"; import AgentModelSelection from "../AgentModelSelection"; import { useTranslation } from "react-i18next"; const ENABLED_PROVIDERS = [ "openai", "anthropic", "lmstudio", "ollama", "localai", "groq", "azure", "koboldcpp", "togetherai", "openrouter", "novita", "mistral", "perplexity", "textgenwebui", "generic-openai", "bedrock", "fireworksai", "deepseek", "ppio", "litellm", "apipie", "xai", "nvidia-nim", "gemini", "moonshotai", "cometapi", "foundry", "zai", "giteeai", "cohere", // TODO: More agent support. // "huggingface" // Can be done but already has issues with no-chat templated. Needs to be tested. ]; const WARN_PERFORMANCE = [ "lmstudio", "koboldcpp", "ollama", "localai", "textgenwebui", ]; const LLM_DEFAULT = { name: "System Default", value: "none", logo: AnythingLLMIcon, options: () => <React.Fragment />, description: "Agents will use the workspace or system LLM unless otherwise specified.", requiredConfig: [], }; const LLMS = [ LLM_DEFAULT, ...AVAILABLE_LLM_PROVIDERS.filter((llm) => ENABLED_PROVIDERS.includes(llm.value) ), ]; export default function AgentLLMSelection({ settings, workspace, setHasChanges, }) { const [filteredLLMs, setFilteredLLMs] = useState([]); const [selectedLLM, setSelectedLLM] = useState( workspace?.agentProvider ?? "none" ); const [searchQuery, setSearchQuery] = useState(""); const [searchMenuOpen, setSearchMenuOpen] = useState(false); const searchInputRef = useRef(null); const { t } = useTranslation(); function updateLLMChoice(selection) { setSearchQuery(""); setSelectedLLM(selection); setSearchMenuOpen(false); setHasChanges(true); } function handleXButton() { if (searchQuery.length > 0) { setSearchQuery(""); if (searchInputRef.current) searchInputRef.current.value = ""; } else { setSearchMenuOpen(!searchMenuOpen); } } useEffect(() => { const filtered = LLMS.filter((llm) => llm.name.toLowerCase().includes(searchQuery.toLowerCase()) ); setFilteredLLMs(filtered); }, [searchQuery, selectedLLM]); const selectedLLMObject = LLMS.find((llm) => llm.value === selectedLLM); return ( <div className="border-b border-white/40 pb-8"> {WARN_PERFORMANCE.includes(selectedLLM) && ( <div className="flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-4 bg-blue-800/30 w-fit rounded-lg px-4 py-2"> <div className="gap-x-2 flex items-center"> <Gauge className="shrink-0" size={25} /> <p className="text-sm">{t("agent.performance-warning")}</p> </div> </div> )} <div className="flex flex-col"> <label htmlFor="name" className="block input-label"> {t("agent.provider.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("agent.provider.description")} </p> </div> <div className="relative"> <input type="hidden" name="agentProvider" value={selectedLLM} /> {searchMenuOpen && ( <div className="fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10" onClick={() => setSearchMenuOpen(false)} /> )} {searchMenuOpen ? ( <div className="absolute top-0 left-0 w-full max-w-[640px] max-h-[310px] min-h-[64px] bg-theme-settings-input-bg rounded-lg flex flex-col justify-between cursor-pointer border-2 border-primary-button z-20"> <div className="w-full flex flex-col gap-y-1"> <div className="flex items-center sticky top-0 z-10 border-b border-[#9CA3AF] mx-4 bg-theme-settings-input-bg"> <MagnifyingGlass size={20} weight="bold" className="absolute left-4 z-30 text-theme-text-primary -ml-4 my-2" /> <input type="text" name="llm-search" autoComplete="off" placeholder="Search available LLM providers" className="border-none -ml-4 my-2 bg-transparent z-20 pl-12 h-[38px] w-full px-4 py-1 text-sm outline-none text-theme-text-primary placeholder:text-theme-text-primary placeholder:font-medium" onChange={(e) => setSearchQuery(e.target.value)} ref={searchInputRef} onKeyDown={(e) => { if (e.key === "Enter") e.preventDefault(); }} /> <X size={20} weight="bold" className="cursor-pointer text-theme-text-primary hover:text-x-button" onClick={handleXButton} /> </div> <div className="flex-1 pl-4 pr-2 flex flex-col gap-y-1 overflow-y-auto white-scrollbar pb-4 max-h-[245px]"> {filteredLLMs.map((llm) => { return ( <AgentLLMItem llm={llm} key={llm.name} availableLLMs={LLMS} settings={settings} checked={selectedLLM === llm.value} onClick={() => updateLLMChoice(llm.value)} /> ); })} </div> </div> </div> ) : ( <button className="w-full max-w-[640px] h-[64px] bg-theme-settings-input-bg rounded-lg flex items-center p-[14px] justify-between cursor-pointer border-2 border-transparent hover:border-primary-button transition-all duration-300" type="button" onClick={() => setSearchMenuOpen(true)} > <div className="flex gap-x-4 items-center"> <img src={selectedLLMObject.logo} alt={`${selectedLLMObject.name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col text-left"> <div className="text-sm font-semibold text-white"> {selectedLLMObject.name} </div> <div className="mt-1 text-xs text-description"> {selectedLLMObject.description} </div> </div> </div> <CaretUpDown size={24} weight="bold" className="text-white" /> </button> )} </div> {selectedLLM !== "none" && ( <div className="mt-4 flex flex-col gap-y-1"> <AgentModelSelection provider={selectedLLM} workspace={workspace} setHasChanges={setHasChanges} /> </div> )} </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/AgentConfig/AgentLLMSelection/AgentLLMItem/index.jsx
frontend/src/pages/WorkspaceSettings/AgentConfig/AgentLLMSelection/AgentLLMItem/index.jsx
// This component differs from the main LLMItem in that it shows if a provider is // "ready for use" and if not - will then highjack the click handler to show a modal // of the provider options that must be saved to continue. import { createPortal } from "react-dom"; import ModalWrapper from "@/components/ModalWrapper"; import { useModal } from "@/hooks/useModal"; import { X, Gear } from "@phosphor-icons/react"; import System from "@/models/system"; import showToast from "@/utils/toast"; import { useEffect, useState } from "react"; const NO_SETTINGS_NEEDED = ["default", "none"]; export default function AgentLLMItem({ llm, availableLLMs, settings, checked, onClick, }) { const { isOpen, openModal, closeModal } = useModal(); const { name, value, logo, description } = llm; const [currentSettings, setCurrentSettings] = useState(settings); useEffect(() => { async function getSettings() { if (isOpen) { const _settings = await System.keys(); setCurrentSettings(_settings ?? {}); } } getSettings(); }, [isOpen]); function handleProviderSelection() { // Determine if provider needs additional setup because its minimum required keys are // not yet set in settings. if (!checked) { const requiresAdditionalSetup = (llm.requiredConfig || []).some( (key) => !currentSettings[key] ); if (requiresAdditionalSetup) { openModal(); return; } onClick(value); } } return ( <> <div onClick={handleProviderSelection} className={`w-full p-2 rounded-md hover:cursor-pointer hover:bg-theme-bg-secondary ${ checked ? "bg-theme-bg-secondary" : "" }`} > <input type="checkbox" value={value} className="peer hidden" checked={checked} readOnly={true} formNoValidate={true} /> <div className="flex gap-x-4 items-center justify-between"> <div className="flex gap-x-4 items-center"> <img src={logo} alt={`${name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col"> <div className="text-sm font-semibold text-white">{name}</div> <div className="mt-1 text-xs text-white/60">{description}</div> </div> </div> {checked && value !== "none" && !NO_SETTINGS_NEEDED.includes(value) && ( <button onClick={(e) => { e.preventDefault(); openModal(); }} className="border-none p-2 text-white/60 hover:text-white hover:bg-theme-bg-hover rounded-md transition-all duration-300" title="Edit Settings" > <Gear size={20} weight="bold" /> </button> )} </div> </div> <SetupProvider availableLLMs={availableLLMs} isOpen={isOpen} provider={value} closeModal={closeModal} postSubmit={onClick} settings={currentSettings} /> </> ); } function SetupProvider({ availableLLMs, isOpen, provider, closeModal, postSubmit, settings, }) { if (!isOpen) return null; const LLMOption = availableLLMs.find((llm) => llm.value === provider); if (!LLMOption) return null; async function handleUpdate(e) { e.preventDefault(); e.stopPropagation(); const data = {}; const form = new FormData(e.target); for (var [key, value] of form.entries()) data[key] = value; const { error } = await System.updateSystem(data); if (error) { showToast(`Failed to save ${LLMOption.name} settings: ${error}`, "error"); return; } closeModal(); postSubmit(); return false; } // Cannot do nested forms, it will cause all sorts of issues, so we portal this out // to the parent container form so we don't have nested forms. return createPortal( <ModalWrapper isOpen={isOpen}> <div className="fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center"> <div className="relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border"> <div className="relative p-6 border-b rounded-t border-theme-modal-border"> <div className="w-full flex gap-x-2 items-center"> <h3 className="text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap"> {LLMOption.name} Settings </h3> </div> <button onClick={closeModal} type="button" className="absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border" > <X size={24} weight="bold" className="text-white" /> </button> </div> <form id="provider-form" onSubmit={handleUpdate}> <div className="px-7 py-6"> <div className="space-y-6 max-h-[60vh] overflow-y-auto p-1"> <p className="text-sm text-white/60"> To use {LLMOption.name} as this workspace's agent LLM you need to set it up first. </p> <div> {LLMOption.options(settings, { credentialsOnly: true })} </div> </div> </div> <div className="flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border px-7 pb-6"> <button type="button" onClick={closeModal} className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > Cancel </button> <button type="submit" form="provider-form" className="transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm" > Save {LLMOption.name} settings </button> </div> </form> </div> </div> </ModalWrapper>, document.getElementById("workspace-agent-settings-container") ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/Members/index.jsx
frontend/src/pages/WorkspaceSettings/Members/index.jsx
import ModalWrapper from "@/components/ModalWrapper"; import { useModal } from "@/hooks/useModal"; import Admin from "@/models/admin"; import { useEffect, useState } from "react"; import * as Skeleton from "react-loading-skeleton"; import AddMemberModal from "./AddMemberModal"; import WorkspaceMemberRow from "./WorkspaceMemberRow"; import CTAButton from "@/components/lib/CTAButton"; export default function Members({ workspace }) { const [loading, setLoading] = useState(true); const [users, setUsers] = useState([]); const [workspaceUsers, setWorkspaceUsers] = useState([]); const [adminWorkspace, setAdminWorkspace] = useState(null); const { isOpen, openModal, closeModal } = useModal(); useEffect(() => { async function fetchData() { const _users = await Admin.users(); const workspaceUsers = await Admin.workspaceUsers(workspace.id); const adminWorkspaces = await Admin.workspaces(); setAdminWorkspace( adminWorkspaces.find( (adminWorkspace) => adminWorkspace.id === workspace.id ) ); setWorkspaceUsers(workspaceUsers); setUsers(_users); setLoading(false); } fetchData(); }, [workspace]); if (loading) { return ( <Skeleton.default height="80vh" width="100%" highlightColor="var(--theme-bg-primary)" baseColor="var(--theme-bg-secondary)" count={1} className="w-full p-4 rounded-b-2xl rounded-tr-2xl rounded-tl-sm mt-6" containerClassName="flex w-full" /> ); } return ( <div className="flex justify-between -mt-3"> <table className="w-full max-w-[700px] text-sm text-left rounded-lg"> <thead className="text-white text-opacity-80 text-xs leading-[18px] font-bold uppercase border-white/10 border-b border-opacity-60"> <tr> <th scope="col" className="px-6 py-3 rounded-tl-lg"> Username </th> <th scope="col" className="px-6 py-3"> Role </th> <th scope="col" className="px-6 py-3"> Date Added </th> <th scope="col" className="px-6 py-3 rounded-tr-lg"> {" "} </th> </tr> </thead> <tbody> {workspaceUsers.length > 0 ? ( workspaceUsers.map((user, index) => ( <WorkspaceMemberRow key={index} user={user} /> )) ) : ( <tr> <td className="text-center py-4 text-white/80" colSpan="4"> No workspace members </td> </tr> )} </tbody> </table> <CTAButton onClick={openModal}>Manage Users</CTAButton> <ModalWrapper isOpen={isOpen}> <AddMemberModal closeModal={closeModal} users={users} workspace={adminWorkspace} /> </ModalWrapper> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/Members/AddMemberModal/index.jsx
frontend/src/pages/WorkspaceSettings/Members/AddMemberModal/index.jsx
import React, { useState } from "react"; import { MagnifyingGlass, X } from "@phosphor-icons/react"; import Admin from "@/models/admin"; import showToast from "@/utils/toast"; export default function AddMemberModal({ closeModal, workspace, users }) { const [searchTerm, setSearchTerm] = useState(""); const [selectedUsers, setSelectedUsers] = useState(workspace?.userIds || []); const handleUpdate = async (e) => { e.preventDefault(); const { success, error } = await Admin.updateUsersInWorkspace( workspace.id, selectedUsers ); if (success) { showToast("Users updated successfully.", "success"); setTimeout(() => { window.location.reload(); }, 1000); } showToast(error, "error"); }; const handleUserSelect = (userId) => { setSelectedUsers((prevSelectedUsers) => { if (prevSelectedUsers.includes(userId)) { return prevSelectedUsers.filter((id) => id !== userId); } else { return [...prevSelectedUsers, userId]; } }); }; const handleSelectAll = () => { if (selectedUsers.length === filteredUsers.length) { setSelectedUsers([]); } else { setSelectedUsers(filteredUsers.map((user) => user.id)); } }; const handleUnselect = () => { setSelectedUsers([]); }; const isUserSelected = (userId) => { return selectedUsers.includes(userId); }; const handleSearch = (event) => { setSearchTerm(event.target.value); }; const filteredUsers = users .filter((user) => user.username.toLowerCase().includes(searchTerm.toLowerCase()) ) .filter((user) => user.role !== "admin") .filter((user) => user.role !== "manager"); return ( <div className="relative w-full max-w-[550px] max-h-full"> <div className="w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border overflow-hidden"> <div className="flex items-center justify-between p-6 border-b rounded-t border-theme-modal-border"> <div className="flex items-center gap-x-4"> <h3 className="text-base font-semibold text-white">Users</h3> <div className="relative"> <input onChange={handleSearch} className="w-[400px] h-[34px] bg-theme-bg-primary rounded-[100px] text-white placeholder:text-theme-text-secondary text-sm px-10 pl-10" placeholder="Search for a user" /> <MagnifyingGlass size={16} weight="bold" className="text-white text-lg absolute left-3 top-1/2 transform -translate-y-1/2" /> </div> </div> <button onClick={closeModal} type="button" className="border-none bg-transparent rounded-lg text-sm p-1.5 ml-auto inline-flex items-center bg-sidebar-button hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border" > <X className="text-white text-lg" /> </button> </div> <form onSubmit={handleUpdate}> <div className="py-[17px] px-[20px]"> <table className="gap-y-[8px] flex flex-col max-h-[385px] overflow-y-auto no-scroll"> {filteredUsers.length > 0 ? ( filteredUsers.map((user) => ( <tr key={user.id} className="flex items-center gap-x-2 cursor-pointer" onClick={() => handleUserSelect(user.id)} > <div className="shrink-0 w-3 h-3 rounded border-[1px] border-solid border-white light:border-black flex justify-center items-center" role="checkbox" aria-checked={isUserSelected(user.id)} tabIndex={0} > {isUserSelected(user.id) && ( <div className="w-2 h-2 bg-white light:bg-black rounded-[2px]" /> )} </div> <p className="text-theme-text-primary text-sm font-medium"> {user.username} </p> </tr> )) ) : ( <p className="text-theme-text-secondary text-sm font-medium "> No users found </p> )} </table> </div> <div className="flex w-full justify-between items-center p-3 space-x-2 border-t rounded-b border-gray-500/50"> <div className="flex items-center gap-x-2"> <button type="button" onClick={handleSelectAll} className="flex items-center gap-x-2 ml-2" > <div className="shrink-0 w-3 h-3 rounded border-[1px] border-white flex justify-center items-center cursor-pointer" role="checkbox" aria-checked={selectedUsers.length === filteredUsers.length} tabIndex={0} > {selectedUsers.length === filteredUsers.length && ( <div className="w-2 h-2 bg-white rounded-[2px]" /> )} </div> <p className="text-white text-sm font-medium">Select All</p> </button> {selectedUsers.length > 0 && ( <button type="button" onClick={handleUnselect} className="flex items-center gap-x-2 ml-2" > <p className="text-theme-text-secondary text-sm font-medium hover:text-theme-text-primary"> Unselect </p> </button> )} </div> <button type="submit" className="transition-all duration-300 text-xs px-2 py-1 font-semibold rounded-lg bg-primary-button hover:bg-secondary border-2 border-transparent hover:border-primary-button hover:text-white h-[32px] w-[68px] -mr-8 whitespace-nowrap shadow-[0_4px_14px_rgba(0,0,0,0.25)]" > Save </button> </div> </form> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/Members/WorkspaceMemberRow/index.jsx
frontend/src/pages/WorkspaceSettings/Members/WorkspaceMemberRow/index.jsx
import { titleCase } from "text-case"; export default function WorkspaceMemberRow({ user }) { return ( <> <tr className="bg-transparent text-theme-text-primary text-sm font-medium"> <th scope="row" className="px-6 py-4 whitespace-nowrap"> {user.username} </th> <td className="px-6 py-4">{titleCase(user.role)}</td> <td className="px-6 py-4">{user.lastUpdatedAt}</td> </tr> </> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/GeneralAppearance/index.jsx
frontend/src/pages/WorkspaceSettings/GeneralAppearance/index.jsx
import Workspace from "@/models/workspace"; import { castToType } from "@/utils/types"; import showToast from "@/utils/toast"; import { useEffect, useRef, useState } from "react"; import WorkspaceName from "./WorkspaceName"; import SuggestedChatMessages from "./SuggestedChatMessages"; import DeleteWorkspace from "./DeleteWorkspace"; import WorkspacePfp from "./WorkspacePfp"; import CTAButton from "@/components/lib/CTAButton"; export default function GeneralInfo({ slug }) { const [workspace, setWorkspace] = useState(null); const [hasChanges, setHasChanges] = useState(false); const [saving, setSaving] = useState(false); const [loading, setLoading] = useState(true); const formEl = useRef(null); useEffect(() => { async function fetchWorkspace() { const workspace = await Workspace.bySlug(slug); setWorkspace(workspace); setLoading(false); } fetchWorkspace(); }, [slug]); const handleUpdate = async (e) => { setSaving(true); e.preventDefault(); const data = {}; const form = new FormData(formEl.current); for (var [key, value] of form.entries()) data[key] = castToType(key, value); const { workspace: updatedWorkspace, message } = await Workspace.update( workspace.slug, data ); if (!!updatedWorkspace) { showToast("Workspace updated!", "success", { clear: true }); } else { showToast(`Error: ${message}`, "error", { clear: true }); } setSaving(false); setHasChanges(false); }; if (!workspace || loading) return null; return ( <div className="w-full relative"> <form ref={formEl} onSubmit={handleUpdate} className="w-1/2 flex flex-col gap-y-6" > {hasChanges && ( <div className="absolute top-0 right-0"> <CTAButton type="submit"> {saving ? "Updating..." : "Update Workspace"} </CTAButton> </div> )} <WorkspaceName key={workspace.slug} workspace={workspace} setHasChanges={setHasChanges} /> </form> <SuggestedChatMessages slug={workspace.slug} /> <WorkspacePfp workspace={workspace} slug={slug} /> <DeleteWorkspace workspace={workspace} /> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/GeneralAppearance/SuggestedChatMessages/index.jsx
frontend/src/pages/WorkspaceSettings/GeneralAppearance/SuggestedChatMessages/index.jsx
import PreLoader from "@/components/Preloader"; import Workspace from "@/models/workspace"; import showToast from "@/utils/toast"; import { useEffect, useState } from "react"; import { Plus, X } from "@phosphor-icons/react"; import { useTranslation } from "react-i18next"; export default function SuggestedChatMessages({ slug }) { const [suggestedMessages, setSuggestedMessages] = useState([]); const [editingIndex, setEditingIndex] = useState(-1); const [newMessage, setNewMessage] = useState({ heading: "", message: "" }); const [hasChanges, setHasChanges] = useState(false); const [loading, setLoading] = useState(true); const { t } = useTranslation(); useEffect(() => { async function fetchWorkspace() { if (!slug) return; const suggestedMessages = await Workspace.getSuggestedMessages(slug); setSuggestedMessages(suggestedMessages); setLoading(false); } fetchWorkspace(); }, [slug]); const handleSaveSuggestedMessages = async () => { const validMessages = suggestedMessages.filter( (msg) => msg?.heading?.trim()?.length > 0 || msg?.message?.trim()?.length > 0 ); const { success, error } = await Workspace.setSuggestedMessages( slug, validMessages ); if (!success) { showToast(`Failed to update welcome messages: ${error}`, "error"); return; } showToast("Successfully updated welcome messages.", "success"); setHasChanges(false); }; const addMessage = () => { setEditingIndex(-1); if (suggestedMessages.length >= 4) { showToast("Maximum of 4 messages allowed.", "warning"); return; } const defaultMessage = { heading: t("general.message.heading"), message: t("general.message.body"), }; setNewMessage(defaultMessage); setSuggestedMessages([...suggestedMessages, { ...defaultMessage }]); setHasChanges(true); }; const removeMessage = (index) => { const messages = [...suggestedMessages]; messages.splice(index, 1); setSuggestedMessages(messages); setHasChanges(true); }; const startEditing = (e, index) => { e.preventDefault(); setEditingIndex(index); setNewMessage({ ...suggestedMessages[index] }); }; const handleRemoveMessage = (index) => { removeMessage(index); setEditingIndex(-1); }; const onEditChange = (e) => { const updatedNewMessage = { ...newMessage, [e.target.name]: e.target.value, }; setNewMessage(updatedNewMessage); const updatedMessages = suggestedMessages.map((message, index) => { if (index === editingIndex) { return { ...message, [e.target.name]: e.target.value }; } return message; }); setSuggestedMessages(updatedMessages); setHasChanges(true); }; if (loading) return ( <div className="flex flex-col"> <label className="block input-label"> {t("general.message.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("general.message.description")} </p> <div className="text-white text-opacity-60 text-sm font-medium mt-6"> <PreLoader size="4" /> </div> </div> ); return ( <div className="w-full mt-6"> <div className="flex flex-col"> <label className="block input-label"> {t("general.message.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("general.message.description")} </p> </div> <div className="grid grid-cols-1 md:grid-cols-2 gap-6 text-white/60 text-xs mt-2 w-full justify-center max-w-[600px]"> {suggestedMessages.map((suggestion, index) => ( <div key={index} className="relative w-full"> <button className="transition-all duration-300 absolute z-10 text-neutral-700 bg-white rounded-full hover:bg-zinc-600 hover:border-zinc-600 hover:text-white border-transparent border shadow-lg ml-2" style={{ top: -8, left: 265, }} onClick={() => handleRemoveMessage(index)} > <X className="m-[1px]" size={20} /> </button> <button key={index} onClick={(e) => startEditing(e, index)} className={`text-left p-2.5 border rounded-xl w-full border-white/20 bg-theme-settings-input-bg hover:bg-theme-sidebar-item-selected-gradient ${ editingIndex === index ? "border-sky-400" : "" }`} > <p className="font-semibold">{suggestion.heading}</p> <p>{suggestion.message}</p> </button> </div> ))} </div> {editingIndex >= 0 && ( <div className="flex flex-col gap-y-4 mr-2 mt-8"> <div className="w-1/2"> <label className="text-white text-sm font-semibold block mb-2"> Heading </label> <input placeholder="Message heading" className="border-none bg-theme-settings-input-bg text-white placeholder:text-white/20 text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block p-2.5 w-full" value={newMessage.heading} name="heading" onChange={onEditChange} /> </div> <div className="w-1/2"> <label className="text-white text-sm font-semibold block mb-2"> Message </label> <input placeholder="Message" className="border-none bg-theme-settings-input-bg text-white placeholder:text-white/20 text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block p-2.5 w-full" value={newMessage.message} name="message" onChange={onEditChange} /> </div> </div> )} {suggestedMessages.length < 4 && ( <button type="button" onClick={addMessage} className="flex gap-x-2 items-center justify-center mt-6 text-white text-sm hover:text-sky-400 transition-all duration-300" > {t("general.message.add")}{" "} <Plus className="" size={24} weight="fill" /> </button> )} {hasChanges && ( <div className="flex justify-start py-6"> <button type="button" className="transition-all duration-300 border border-slate-200 px-4 py-2 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800" onClick={handleSaveSuggestedMessages} > {t("general.message.save")} </button> </div> )} </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/GeneralAppearance/WorkspacePfp/index.jsx
frontend/src/pages/WorkspaceSettings/GeneralAppearance/WorkspacePfp/index.jsx
import Workspace from "@/models/workspace"; import showToast from "@/utils/toast"; import { Plus } from "@phosphor-icons/react"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; export default function WorkspacePfp({ workspace, slug }) { const [pfp, setPfp] = useState(null); const { t } = useTranslation(); useEffect(() => { async function fetchWorkspace() { const pfpUrl = await Workspace.fetchPfp(slug); setPfp(pfpUrl); } fetchWorkspace(); }, [slug]); const handleFileUpload = async (event) => { const file = event.target.files[0]; if (!file) return false; const formData = new FormData(); formData.append("file", file); const { success, error } = await Workspace.uploadPfp( formData, workspace.slug ); if (!success) { showToast(`Failed to upload profile picture: ${error}`, "error"); return; } const pfpUrl = await Workspace.fetchPfp(workspace.slug); setPfp(pfpUrl); showToast("Profile picture uploaded.", "success"); }; const handleRemovePfp = async () => { const { success, error } = await Workspace.removePfp(workspace.slug); if (!success) { showToast(`Failed to remove profile picture: ${error}`, "error"); return; } setPfp(null); }; return ( <div className="mt-6"> <div className="flex flex-col"> <label className="block input-label">{t("general.pfp.title")}</label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("general.pfp.description")} </p> </div> <div className="flex flex-col md:flex-row items-center gap-8"> <div className="flex flex-col items-center"> <label className="w-36 h-36 flex flex-col items-center justify-center bg-theme-settings-input-bg transition-all duration-300 rounded-full mt-8 border-2 border-dashed border-white border-opacity-60 cursor-pointer hover:opacity-60"> <input id="workspace-pfp-upload" type="file" accept="image/*" className="hidden" onChange={handleFileUpload} /> {pfp ? ( <img src={pfp} alt="User profile picture" className="w-36 h-36 rounded-full object-cover bg-theme-bg-secondary" /> ) : ( <div className="flex flex-col items-center justify-center p-3"> <Plus className="w-8 h-8 text-theme-text-secondary m-2" /> <span className="text-theme-text-secondary text-opacity-80 text-xs font-semibold"> {t("general.pfp.image")} </span> <span className="text-theme-text-secondary text-opacity-60 text-xs"> 800 x 800 </span> </div> )} </label> {pfp && ( <button type="button" onClick={handleRemovePfp} className="mt-3 text-theme-text-secondary text-opacity-60 text-sm font-medium hover:underline" > {t("general.pfp.remove")} </button> )} </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/GeneralAppearance/WorkspaceName/index.jsx
frontend/src/pages/WorkspaceSettings/GeneralAppearance/WorkspaceName/index.jsx
import { useTranslation } from "react-i18next"; export default function WorkspaceName({ workspace, setHasChanges }) { const { t } = useTranslation(); return ( <div> <div className="flex flex-col"> <label htmlFor="name" className="block input-label"> {t("common.workspaces-name")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("general.names.description")} </p> </div> <input name="name" type="text" minLength={2} maxLength={80} defaultValue={workspace?.name} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="My Workspace" required={true} autoComplete="off" onChange={() => setHasChanges(true)} /> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/GeneralAppearance/DeleteWorkspace/index.jsx
frontend/src/pages/WorkspaceSettings/GeneralAppearance/DeleteWorkspace/index.jsx
import { useState } from "react"; import { useParams } from "react-router-dom"; import Workspace from "@/models/workspace"; import paths from "@/utils/paths"; import { useTranslation } from "react-i18next"; import showToast from "@/utils/toast"; export default function DeleteWorkspace({ workspace }) { const { slug } = useParams(); const [deleting, setDeleting] = useState(false); const { t } = useTranslation(); const deleteWorkspace = async () => { if ( !window.confirm( `${t("general.delete.confirm-start")} ${workspace.name} ${t( "general.delete.confirm-end" )}` ) ) return false; setDeleting(true); const success = await Workspace.delete(workspace.slug); if (!success) { showToast("Workspace could not be deleted!", "error", { clear: true }); setDeleting(false); return; } workspace.slug === slug ? (window.location = paths.home()) : window.location.reload(); }; return ( <div className="flex flex-col mt-10"> <label className="block input-label">{t("general.delete.title")}</label> <p className="text-theme-text-secondary text-xs font-medium py-1.5"> {t("general.delete.description")} </p> <button disabled={deleting} onClick={deleteWorkspace} type="button" className="w-60 mt-4 transition-all duration-300 border border-transparent rounded-lg whitespace-nowrap text-sm px-5 py-2.5 focus:z-10 bg-red-500/25 text-red-200 light:text-red-500 hover:light:text-[#FFFFFF] hover:text-[#FFFFFF] hover:bg-red-600 disabled:bg-red-600 disabled:text-red-200 disabled:animate-pulse" > {deleting ? t("general.delete.deleting") : t("general.delete.delete")} </button> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/index.jsx
import System from "@/models/system"; import Workspace from "@/models/workspace"; import showToast from "@/utils/toast"; import { castToType } from "@/utils/types"; import { useEffect, useRef, useState } from "react"; import ChatHistorySettings from "./ChatHistorySettings"; import ChatPromptSettings from "./ChatPromptSettings"; import ChatTemperatureSettings from "./ChatTemperatureSettings"; import ChatModeSelection from "./ChatModeSelection"; import WorkspaceLLMSelection from "./WorkspaceLLMSelection"; import ChatQueryRefusalResponse from "./ChatQueryRefusalResponse"; import CTAButton from "@/components/lib/CTAButton"; export default function ChatSettings({ workspace }) { const [settings, setSettings] = useState({}); const [hasChanges, setHasChanges] = useState(false); const [saving, setSaving] = useState(false); const formEl = useRef(null); useEffect(() => { async function fetchSettings() { const _settings = await System.keys(); setSettings(_settings ?? {}); } fetchSettings(); }, []); const handleUpdate = async (e) => { e.preventDefault(); setSaving(true); const data = {}; const form = new FormData(formEl.current); for (var [key, value] of form.entries()) data[key] = castToType(key, value); const { workspace: updatedWorkspace, message } = await Workspace.update( workspace.slug, data ); if (updatedWorkspace) { showToast("Workspace updated!", "success", { clear: true }); setHasChanges(false); } else { showToast(`Error: ${message}`, "error", { clear: true }); // Keep hasChanges true on error so user can retry } setSaving(false); }; if (!workspace) return null; return ( <div id="workspace-chat-settings-container" className="relative"> <form ref={formEl} onSubmit={handleUpdate} id="chat-settings-form" className="w-1/2 flex flex-col gap-y-6" > {hasChanges && ( <div className="absolute top-0 right-0"> <CTAButton type="submit"> {saving ? "Updating..." : "Update Workspace"} </CTAButton> </div> )} <WorkspaceLLMSelection settings={settings} workspace={workspace} setHasChanges={setHasChanges} /> <ChatModeSelection workspace={workspace} setHasChanges={setHasChanges} /> <ChatHistorySettings workspace={workspace} setHasChanges={setHasChanges} /> <ChatPromptSettings workspace={workspace} setHasChanges={setHasChanges} hasChanges={hasChanges} /> <ChatQueryRefusalResponse workspace={workspace} setHasChanges={setHasChanges} /> <ChatTemperatureSettings settings={settings} workspace={workspace} setHasChanges={setHasChanges} /> </form> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/ChatHistorySettings/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/ChatHistorySettings/index.jsx
import { useTranslation } from "react-i18next"; export default function ChatHistorySettings({ workspace, setHasChanges }) { const { t } = useTranslation(); return ( <div> <div className="flex flex-col gap-y-1 mb-4"> <label htmlFor="name" className="block mb-2 input-label"> {t("chat.history.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium"> {t("chat.history.desc-start")} <i> {t("chat.history.recommend")} </i> {t("chat.history.desc-end")} </p> </div> <input name="openAiHistory" type="number" min={1} max={45} step={1} onWheel={(e) => e.target.blur()} defaultValue={workspace?.openAiHistory ?? 20} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="20" required={true} autoComplete="off" onChange={() => setHasChanges(true)} /> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/ChatModeSelection/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/ChatModeSelection/index.jsx
import { useState } from "react"; import { useTranslation } from "react-i18next"; export default function ChatModeSelection({ workspace, setHasChanges }) { const [chatMode, setChatMode] = useState(workspace?.chatMode || "chat"); const { t } = useTranslation(); return ( <div> <div className="flex flex-col"> <label htmlFor="chatMode" className="block input-label"> {t("chat.mode.title")} </label> </div> <div className="flex flex-col gap-y-1 mt-2"> <div className="w-fit flex gap-x-1 items-center p-1 rounded-lg bg-theme-settings-input-bg "> <input type="hidden" name="chatMode" value={chatMode} /> <button type="button" disabled={chatMode === "chat"} onClick={() => { setChatMode("chat"); setHasChanges(true); }} className="transition-bg duration-200 px-6 py-1 text-md text-white/60 disabled:text-white bg-transparent disabled:bg-[#687280] rounded-md" > {t("chat.mode.chat.title")} </button> <button type="button" disabled={chatMode === "query"} onClick={() => { setChatMode("query"); setHasChanges(true); }} className="transition-bg duration-200 px-6 py-1 text-md text-white/60 disabled:text-white bg-transparent disabled:bg-[#687280] rounded-md" > {t("chat.mode.query.title")} </button> </div> <p className="text-sm text-white/60"> {chatMode === "chat" ? ( <> <b>{t("chat.mode.chat.title")}</b>{" "} {t("chat.mode.chat.desc-start")}{" "} <i className="font-semibold">{t("chat.mode.chat.and")}</i>{" "} {t("chat.mode.chat.desc-end")} </> ) : ( <> <b>{t("chat.mode.query.title")}</b>{" "} {t("chat.mode.query.desc-start")}{" "} <i className="font-semibold">{t("chat.mode.query.only")}</i>{" "} {t("chat.mode.query.desc-end")} </> )} </p> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/ChatPromptSettings/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/ChatPromptSettings/index.jsx
import { useEffect, useState, useRef, Fragment } from "react"; import { getWorkspaceSystemPrompt } from "@/utils/chat"; import { useTranslation } from "react-i18next"; import SystemPromptVariable from "@/models/systemPromptVariable"; import Highlighter from "react-highlight-words"; import { Link, useSearchParams } from "react-router-dom"; import paths from "@/utils/paths"; import ChatPromptHistory from "./ChatPromptHistory"; import PublishEntityModal from "@/components/CommunityHub/PublishEntityModal"; import { useModal } from "@/hooks/useModal"; import System from "@/models/system"; export default function ChatPromptSettings({ workspace, setHasChanges, hasChanges, }) { const { t } = useTranslation(); const [searchParams] = useSearchParams(); // Prompt state const initialPrompt = getWorkspaceSystemPrompt(workspace); const [prompt, setPrompt] = useState(initialPrompt); const [savedPrompt, setSavedPrompt] = useState(initialPrompt); const [defaultSystemPrompt, setDefaultSystemPrompt] = useState(""); // UI state const [isEditing, setIsEditing] = useState(false); const [showPromptHistory, setShowPromptHistory] = useState(false); const [availableVariables, setAvailableVariables] = useState([]); // Refs const promptRef = useRef(null); const promptHistoryRef = useRef(null); const historyButtonRef = useRef(null); // Modals const { isOpen: showPublishModal, closeModal: closePublishModal, openModal: openPublishModal, } = useModal(); // Derived state const isDirty = prompt !== savedPrompt; const hasBeenModified = savedPrompt?.trim() !== initialPrompt?.trim(); const showPublishButton = !isEditing && prompt?.trim().length >= 10 && (isDirty || hasBeenModified); // Load variables and handle focus on mount useEffect(() => { async function setupVariableHighlighting() { const { variables } = await SystemPromptVariable.getAll(); setAvailableVariables(variables); } setupVariableHighlighting(); if (searchParams.get("action") === "focus-system-prompt") setIsEditing(true); }, [searchParams]); // Update saved prompt when parent clears hasChanges useEffect(() => { if (!hasChanges) setSavedPrompt(prompt); }, [hasChanges, prompt]); // Auto-focus textarea when editing useEffect(() => { if (isEditing && promptRef.current) { promptRef.current.focus(); } }, [isEditing]); useEffect(() => { System.fetchDefaultSystemPrompt().then(({ defaultSystemPrompt }) => setDefaultSystemPrompt(defaultSystemPrompt) ); }, []); // Handle click outside for history panel useEffect(() => { const handleClickOutside = (event) => { if ( promptHistoryRef.current && !promptHistoryRef.current.contains(event.target) && historyButtonRef.current && !historyButtonRef.current.contains(event.target) ) { setShowPromptHistory(false); } }; document.addEventListener("mousedown", handleClickOutside); return () => document.removeEventListener("mousedown", handleClickOutside); }, []); const handleRestoreFromHistory = (historicalPrompt) => { setPrompt(historicalPrompt); setShowPromptHistory(false); setHasChanges(true); }; const handlePublishFromHistory = (historicalPrompt) => { openPublishModal(); setShowPromptHistory(false); setTimeout(() => setPrompt(historicalPrompt), 0); }; // Restore to default system prompt, if no default system prompt is set const handleRestoreToDefaultSystemPrompt = () => { System.fetchDefaultSystemPrompt().then(({ defaultSystemPrompt }) => { setPrompt(defaultSystemPrompt); setHasChanges(true); }); }; return ( <> <ChatPromptHistory ref={promptHistoryRef} workspaceSlug={workspace.slug} show={showPromptHistory} onRestore={handleRestoreFromHistory} onPublishClick={handlePublishFromHistory} onClose={() => setShowPromptHistory(false)} /> <div> <div className="flex flex-col"> <div className="flex items-center justify-between"> <label htmlFor="name" className="block input-label"> {t("chat.prompt.title")} </label> </div> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("chat.prompt.description")} </p> <p className="text-white text-opacity-60 text-xs font-medium mb-2"> You can insert{" "} <Link to={paths.settings.systemPromptVariables()} className="text-primary-button" > prompt variables </Link>{" "} like:{" "} {availableVariables.slice(0, 3).map((v, i) => ( <Fragment key={v.key}> <span className="bg-theme-settings-input-bg px-1 py-0.5 rounded"> {`{${v.key}}`} </span> {i < availableVariables.length - 1 && ", "} </Fragment> ))} {availableVariables.length > 3 && ( <Link to={paths.settings.systemPromptVariables()} className="text-primary-button" > +{availableVariables.length - 3} more... </Link> )} </p> </div> <input type="hidden" name="openAiPrompt" value={prompt} /> <div className="relative w-full flex flex-col items-end"> <button ref={historyButtonRef} type="button" className="text-theme-text-secondary hover:text-white light:hover:text-black text-xs font-medium" onClick={(e) => { e.preventDefault(); setShowPromptHistory(!showPromptHistory); }} > {showPromptHistory ? "Hide History" : "View History"} </button> <div className="relative w-full"> {isEditing ? ( <textarea ref={promptRef} autoFocus={true} rows={5} onFocus={(e) => { const length = e.target.value.length; e.target.setSelectionRange(length, length); }} onBlur={(e) => { setIsEditing(false); setPrompt(e.target.value); }} onChange={(e) => { setPrompt(e.target.value); setHasChanges(true); }} onPaste={(e) => { setPrompt(e.target.value); setHasChanges(true); }} style={{ resize: "vertical", overflowY: "scroll", minHeight: "150px", }} defaultValue={prompt} className="border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2" /> ) : ( <div onClick={() => setIsEditing(true)} style={{ resize: "vertical", overflowY: "scroll", minHeight: "150px", }} className="border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2" > <Highlighter className="whitespace-pre-wrap" highlightClassName="bg-cta-button p-0.5 rounded-md" searchWords={availableVariables.map((v) => `{${v.key}}`)} autoEscape={true} caseSensitive={true} textToHighlight={prompt} /> </div> )} </div> <div className="w-full flex flex-row items-center justify-between pt-2"> {prompt !== defaultSystemPrompt && ( <button type="button" onClick={handleRestoreToDefaultSystemPrompt} className="text-theme-text-primary hover:text-white light:hover:text-black text-xs font-medium" > Restore to Default </button> )} <PublishPromptCTA hidden={!showPublishButton} onClick={openPublishModal} /> </div> </div> </div> <PublishEntityModal show={showPublishModal} onClose={closePublishModal} entityType="system-prompt" entity={prompt} /> </> ); } function PublishPromptCTA({ hidden = false, onClick }) { if (hidden) return null; return ( <button type="button" onClick={onClick} className="border-none text-primary-button hover:text-white light:hover:text-black text-xs font-medium" > Publish to Community Hub </button> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/ChatPromptSettings/ChatPromptHistory/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/ChatPromptSettings/ChatPromptHistory/index.jsx
import { useEffect, useState, forwardRef } from "react"; import { useTranslation } from "react-i18next"; import { X } from "@phosphor-icons/react"; import PromptHistory from "@/models/promptHistory"; import PromptHistoryItem from "./PromptHistoryItem"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; export default forwardRef(function ChatPromptHistory( { show, workspaceSlug, onRestore, onClose, onPublishClick }, ref ) { const { t } = useTranslation(); const [history, setHistory] = useState([]); const [loading, setLoading] = useState(true); function loadHistory() { if (!workspaceSlug) return; setLoading(true); PromptHistory.forWorkspace(workspaceSlug) .then((historyData) => { setHistory(historyData); }) .catch((error) => { console.error(error); }) .finally(() => { setLoading(false); }); } function handleClearAll() { if (!workspaceSlug) return; if (window.confirm(t("chat.prompt.history.clearAllConfirm"))) { PromptHistory.clearAll(workspaceSlug) .then(({ success }) => { if (success) setHistory([]); }) .catch((error) => { console.error(error); }); } } useEffect(() => { if (show && workspaceSlug) loadHistory(); }, [show, workspaceSlug]); return ( <div ref={ref} className={`fixed right-3 top-3 bottom-3 w-[375px] bg-theme-action-menu-bg light:bg-theme-home-update-card-bg rounded-xl py-4 px-4 z-[9999] overflow-y-hidden ${ show ? "translate-x-0 opacity-100 visible" : "translate-x-full opacity-0 invisible" } transition-all duration-300`} > <div className="sticky flex items-center justify-between"> <div className="text-theme-text-primary text-sm font-semibold"> {t("chat.prompt.history.title")} </div> <div className="flex items-center gap-2"> {history.length > 0 && ( <button type="button" className="text-sm font-medium text-theme-text-secondary cursor-pointer hover:text-primary-button border-none" onClick={handleClearAll} > {t("chat.prompt.history.clearAll")} </button> )} <button type="button" className="text-theme-text-secondary cursor-pointer hover:text-primary-button border-none" onClick={onClose} > <X size={16} weight="bold" /> </button> </div> </div> <div className="mt-4 flex flex-col gap-y-[14px] h-full overflow-y-scroll pb-[50px]"> {loading ? ( <LoaderSkeleton /> ) : history.length === 0 ? ( <div className="flex text-theme-text-secondary text-sm text-center w-full h-full flex items-center justify-center"> {t("chat.prompt.history.noHistory")} </div> ) : ( history.map((item) => ( <PromptHistoryItem key={item.id} id={item.id} {...item} onRestore={() => onRestore(item.prompt)} onPublishClick={onPublishClick} setHistory={setHistory} /> )) )} </div> </div> ); }); function LoaderSkeleton() { const highlightColor = "var(--theme-bg-primary)"; const baseColor = "var(--theme-bg-secondary)"; return ( <Skeleton.default height="85px" width="100%" highlightColor={highlightColor} baseColor={baseColor} count={8} /> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/ChatPromptSettings/ChatPromptHistory/PromptHistoryItem/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/ChatPromptSettings/ChatPromptHistory/PromptHistoryItem/index.jsx
import { DotsThreeVertical } from "@phosphor-icons/react"; import { useRef, useState, useEffect } from "react"; import PromptHistory from "@/models/promptHistory"; import { useTranslation } from "react-i18next"; import moment from "moment"; import truncate from "truncate"; const MAX_PROMPT_LENGTH = 200; // chars export default function PromptHistoryItem({ id, prompt, modifiedAt, user, onRestore, setHistory, onPublishClick, }) { const { t } = useTranslation(); const [showMenu, setShowMenu] = useState(false); const menuRef = useRef(null); const menuButtonRef = useRef(null); const [expanded, setExpanded] = useState(false); const deleteHistory = async (id) => { if (window.confirm(t("chat.prompt.history.deleteConfirm"))) { const { success } = await PromptHistory.delete(id); if (success) { setHistory((prevHistory) => prevHistory.filter((item) => item.id !== id) ); } } }; useEffect(() => { const handleClickOutside = (event) => { if ( showMenu && !menuRef.current.contains(event.target) && !menuButtonRef.current.contains(event.target) ) { setShowMenu(false); } }; document.addEventListener("mousedown", handleClickOutside); return () => { document.removeEventListener("mousedown", handleClickOutside); }; }, [showMenu]); return ( <div className="text-white"> <div className="flex items-center justify-between"> <div className="text-xs"> {user && ( <> <span className="text-primary-button">{user.username}</span>{" "} <span className="mx-1 text-white">•</span> </> )} <span className="text-white opacity-50 light:opacity-100"> {moment(modifiedAt).fromNow()} </span> </div> <div className="flex items-center gap-2"> <button type="button" className="border-none text-sm cursor-pointer text-theme-text-primary hover:text-primary-button" onClick={onRestore} > {t("chat.prompt.history.restore")} </button> <div className="relative"> <button type="button" ref={menuButtonRef} className="border-none text-theme-text-secondary cursor-pointer hover:text-primary-button flex items-center justify-center" onClick={() => setShowMenu(!showMenu)} > <DotsThreeVertical size={16} weight="bold" /> </button> {showMenu && ( <div ref={menuRef} className="absolute right-0 top-6 bg-theme-bg-popup-menu rounded-lg z-50 min-w-[200px]" > <button type="button" className="px-[10px] py-[6px] text-sm text-white hover:bg-theme-sidebar-item-hover rounded-t-lg cursor-pointer border-none w-full text-left whitespace-nowrap" onClick={() => { setShowMenu(false); onPublishClick(prompt); }} > {t("chat.prompt.history.publish")} </button> <button type="button" className="px-[10px] py-[6px] text-sm text-white hover:bg-red-500/60 light:hover:bg-red-300/80 rounded-b-lg cursor-pointer border-none w-full text-left whitespace-nowrap" onClick={() => { setShowMenu(false); deleteHistory(id); }} > {t("chat.prompt.history.delete")} </button> </div> )} </div> </div> </div> <div className="flex items-center mt-1"> <div className="text-theme-text-primary text-sm font-medium break-all whitespace-pre-wrap"> {prompt.length > MAX_PROMPT_LENGTH && !expanded ? ( <> {truncate(prompt, MAX_PROMPT_LENGTH)}{" "} <button type="button" className="text-theme-text-secondary hover:text-primary-button border-none" onClick={() => setExpanded(!expanded)} > {t("chat.prompt.history.expand")} </button> </> ) : ( prompt )} </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/ChatQueryRefusalResponse/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/ChatQueryRefusalResponse/index.jsx
import { chatQueryRefusalResponse } from "@/utils/chat"; import { useTranslation } from "react-i18next"; export default function ChatQueryRefusalResponse({ workspace, setHasChanges }) { const { t } = useTranslation(); return ( <div> <div className="flex flex-col"> <label htmlFor="name" className="block input-label"> {t("chat.refusal.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("chat.refusal.desc-start")}{" "} <code className="border-none bg-theme-settings-input-bg p-0.5 rounded-sm"> {t("chat.refusal.query")} </code>{" "} {t("chat.refusal.desc-end")} </p> </div> <textarea name="queryRefusalResponse" rows={2} defaultValue={chatQueryRefusalResponse(workspace)} className="border-none bg-theme-settings-input-bg placeholder:text-theme-settings-input-placeholder text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 mt-2" placeholder="The text returned in query mode when there is no relevant context found for a response." required={true} wrap="soft" autoComplete="off" onChange={() => setHasChanges(true)} /> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/ChatTemperatureSettings/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/ChatTemperatureSettings/index.jsx
import { useTranslation } from "react-i18next"; function recommendedSettings(provider = null) { switch (provider) { case "mistral": return { temp: 0 }; default: return { temp: 0.7 }; } } export default function ChatTemperatureSettings({ settings, workspace, setHasChanges, }) { const defaults = recommendedSettings(settings?.LLMProvider); const { t } = useTranslation(); return ( <div> <div className="flex flex-col"> <label htmlFor="name" className="block input-label"> {t("chat.temperature.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("chat.temperature.desc-start")} <br /> {t("chat.temperature.desc-end")} <br /> <br /> <i>{t("chat.temperature.hint")}</i> </p> </div> <input name="openAiTemp" type="number" min={0.0} step={0.1} onWheel={(e) => e.target.blur()} defaultValue={workspace?.openAiTemp ?? defaults.temp} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="0.7" required={true} autoComplete="off" onChange={() => setHasChanges(true)} /> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/WorkspaceLLMSelection/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/WorkspaceLLMSelection/index.jsx
import React, { useEffect, useRef, useState } from "react"; import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png"; import WorkspaceLLMItem from "./WorkspaceLLMItem"; import { AVAILABLE_LLM_PROVIDERS } from "@/pages/GeneralSettings/LLMPreference"; import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react"; import ChatModelSelection from "./ChatModelSelection"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import paths from "@/utils/paths"; // Some providers do not support model selection via /models. // In that case we allow the user to enter the model name manually and hope they // type it correctly. const FREE_FORM_LLM_SELECTION = ["bedrock", "azure", "generic-openai"]; // Some providers do not support model selection via /models // and only have a fixed single-model they can use. const NO_MODEL_SELECTION = ["default", "huggingface"]; // Some providers we just fully disable for ease of use. const DISABLED_PROVIDERS = []; const LLM_DEFAULT = { name: "System default", value: "default", logo: AnythingLLMIcon, options: () => <React.Fragment />, description: "Use the system LLM preference for this workspace.", requiredConfig: [], }; const LLMS = [LLM_DEFAULT, ...AVAILABLE_LLM_PROVIDERS].filter( (llm) => !DISABLED_PROVIDERS.includes(llm.value) ); export default function WorkspaceLLMSelection({ settings, workspace, setHasChanges, }) { const [filteredLLMs, setFilteredLLMs] = useState([]); const [selectedLLM, setSelectedLLM] = useState( workspace?.chatProvider ?? "default" ); const [searchQuery, setSearchQuery] = useState(""); const [searchMenuOpen, setSearchMenuOpen] = useState(false); const searchInputRef = useRef(null); const { t } = useTranslation(); function updateLLMChoice(selection) { setSearchQuery(""); setSelectedLLM(selection); setSearchMenuOpen(false); setHasChanges(true); } function handleXButton() { if (searchQuery.length > 0) { setSearchQuery(""); if (searchInputRef.current) searchInputRef.current.value = ""; } else { setSearchMenuOpen(!searchMenuOpen); } } useEffect(() => { const filtered = LLMS.filter((llm) => llm.name.toLowerCase().includes(searchQuery.toLowerCase()) ); setFilteredLLMs(filtered); }, [LLMS, searchQuery, selectedLLM]); const selectedLLMObject = LLMS.find((llm) => llm.value === selectedLLM); return ( <div className="border-b border-white/40 pb-8"> <div className="flex flex-col"> <label htmlFor="name" className="block input-label"> {t("chat.llm.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("chat.llm.description")} </p> </div> <div className="relative"> <input type="hidden" name="chatProvider" value={selectedLLM} /> {searchMenuOpen && ( <div className="fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10" onClick={() => setSearchMenuOpen(false)} /> )} {searchMenuOpen ? ( <div className="absolute top-0 left-0 w-full max-w-[640px] max-h-[310px] min-h-[64px] bg-theme-settings-input-bg rounded-lg flex flex-col justify-between cursor-pointer border-2 border-primary-button z-20"> <div className="w-full flex flex-col gap-y-1"> <div className="flex items-center sticky top-0 z-10 border-b border-[#9CA3AF] mx-4 bg-theme-settings-input-bg"> <MagnifyingGlass size={20} weight="bold" className="absolute left-4 z-30 text-theme-text-primary -ml-4 my-2" /> <input type="text" name="llm-search" autoComplete="off" placeholder={t("chat.llm.search")} className="border-none -ml-4 my-2 bg-transparent z-20 pl-12 h-[38px] w-full px-4 py-1 text-sm outline-none focus:outline-primary-button active:outline-primary-button outline-none text-theme-text-primary placeholder:text-theme-text-primary placeholder:font-medium" onChange={(e) => setSearchQuery(e.target.value)} ref={searchInputRef} onKeyDown={(e) => { if (e.key === "Enter") e.preventDefault(); }} /> <X size={20} weight="bold" className="cursor-pointer text-theme-text-primary hover:text-x-button" onClick={handleXButton} /> </div> <div className="flex-1 pl-4 pr-2 flex flex-col gap-y-1 overflow-y-auto white-scrollbar pb-4 max-h-[245px]"> {filteredLLMs.map((llm) => { return ( <WorkspaceLLMItem llm={llm} key={llm.name} availableLLMs={LLMS} settings={settings} checked={selectedLLM === llm.value} onClick={() => updateLLMChoice(llm.value)} /> ); })} </div> </div> </div> ) : ( <button className="w-full max-w-[640px] h-[64px] bg-theme-settings-input-bg rounded-lg flex items-center p-[14px] justify-between cursor-pointer border-2 border-transparent hover:border-primary-button transition-all duration-300" type="button" onClick={() => setSearchMenuOpen(true)} > <div className="flex gap-x-4 items-center"> <img src={selectedLLMObject.logo} alt={`${selectedLLMObject.name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col text-left"> <div className="text-sm font-semibold text-white"> {selectedLLMObject.name} </div> <div className="mt-1 text-xs text-description"> {selectedLLMObject.description} </div> </div> </div> <CaretUpDown size={24} weight="bold" className="text-white" /> </button> )} </div> <ModelSelector selectedLLM={selectedLLM} workspace={workspace} setHasChanges={setHasChanges} /> </div> ); } // TODO: Add this to agent selector as well as make generic component. function ModelSelector({ selectedLLM, workspace, setHasChanges }) { if (NO_MODEL_SELECTION.includes(selectedLLM)) { if (selectedLLM !== "default") { return ( <div className="w-full h-10 justify-center items-center flex mt-4"> <p className="text-sm font-base text-white text-opacity-60 text-center"> Multi-model support is not supported for this provider yet. <br /> This workspace will use{" "} <Link to={paths.settings.llmPreference()} className="underline"> the model set for the system. </Link> </p> </div> ); } return null; } if (FREE_FORM_LLM_SELECTION.includes(selectedLLM)) { return ( <FreeFormLLMInput workspace={workspace} setHasChanges={setHasChanges} /> ); } return ( <ChatModelSelection provider={selectedLLM} workspace={workspace} setHasChanges={setHasChanges} /> ); } function FreeFormLLMInput({ workspace, setHasChanges }) { const { t } = useTranslation(); return ( <div className="mt-4 flex flex-col gap-y-1"> <label className="block input-label">{t("chat.model.title")}</label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("chat.model.description")} </p> <input type="text" name="chatModel" defaultValue={workspace?.chatModel || ""} onChange={() => setHasChanges(true)} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Enter model name exactly as referenced in the API (e.g., gpt-3.5-turbo)" /> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/WorkspaceLLMSelection/ChatModelSelection/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/WorkspaceLLMSelection/ChatModelSelection/index.jsx
import useGetProviderModels, { DISABLED_PROVIDERS, } from "@/hooks/useGetProvidersModels"; import { useTranslation } from "react-i18next"; export default function ChatModelSelection({ provider, workspace, setHasChanges, }) { const { defaultModels, customModels, loading } = useGetProviderModels(provider); const { t } = useTranslation(); if (DISABLED_PROVIDERS.includes(provider)) return null; if (loading) { return ( <div> <div className="flex flex-col mt-6"> <label htmlFor="name" className="block input-label"> {t("chat.model.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("chat.model.description")} </p> </div> <select name="chatModel" required={true} disabled={true} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" > <option disabled={true} selected={true}> -- waiting for models -- </option> </select> </div> ); } return ( <div> <div className="flex flex-col mt-6"> <label htmlFor="name" className="block input-label"> {t("chat.model.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("chat.model.description")} </p> </div> <select name="chatModel" required={true} onChange={() => { setHasChanges(true); }} className="border-none bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" > {defaultModels.length > 0 && ( <optgroup label="General models"> {defaultModels.map((model) => { return ( <option key={model} value={model} selected={workspace?.chatModel === model} > {model} </option> ); })} </optgroup> )} {Array.isArray(customModels) && customModels.length > 0 && ( <optgroup label="Discovered models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={workspace?.chatModel === model.id} > {model.id} </option> ); })} </optgroup> )} {/* For providers like TogetherAi where we partition model by creator entity. */} {!Array.isArray(customModels) && Object.keys(customModels).length > 0 && ( <> {Object.entries(customModels).map(([organization, models]) => ( <optgroup key={organization} label={organization}> {models.map((model) => ( <option key={model.id} value={model.id} selected={workspace?.chatModel === model.id} > {model.name} </option> ))} </optgroup> ))} </> )} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/pages/WorkspaceSettings/ChatSettings/WorkspaceLLMSelection/WorkspaceLLMItem/index.jsx
frontend/src/pages/WorkspaceSettings/ChatSettings/WorkspaceLLMSelection/WorkspaceLLMItem/index.jsx
// This component differs from the main LLMItem in that it shows if a provider is // "ready for use" and if not - will then highjack the click handler to show a modal // of the provider options that must be saved to continue. import { createPortal } from "react-dom"; import ModalWrapper from "@/components/ModalWrapper"; import { useModal } from "@/hooks/useModal"; import { X, Gear } from "@phosphor-icons/react"; import System from "@/models/system"; import showToast from "@/utils/toast"; import { useEffect, useState } from "react"; const NO_SETTINGS_NEEDED = ["default"]; export default function WorkspaceLLM({ llm, availableLLMs, settings, checked, onClick, }) { const { isOpen, openModal, closeModal } = useModal(); const { name, value, logo, description } = llm; const [currentSettings, setCurrentSettings] = useState(settings); useEffect(() => { async function getSettings() { if (isOpen) { const _settings = await System.keys(); setCurrentSettings(_settings ?? {}); } } getSettings(); }, [isOpen]); function handleProviderSelection() { // Determine if provider needs additional setup because its minimum required keys are // not yet set in settings. if (!checked) { const requiresAdditionalSetup = (llm.requiredConfig || []).some( (key) => !currentSettings[key] ); if (requiresAdditionalSetup) { openModal(); return; } onClick(value); } } return ( <> <div onClick={handleProviderSelection} className={`w-full p-2 rounded-md hover:cursor-pointer hover:bg-theme-bg-secondary ${ checked ? "bg-theme-bg-secondary" : "" }`} > <input type="checkbox" value={value} className="peer hidden" checked={checked} readOnly={true} formNoValidate={true} /> <div className="flex gap-x-4 items-center justify-between"> <div className="flex gap-x-4 items-center"> <img src={logo} alt={`${name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col"> <div className="text-sm font-semibold text-white">{name}</div> <div className="mt-1 text-xs text-white/60">{description}</div> </div> </div> {checked && !NO_SETTINGS_NEEDED.includes(value) && ( <button onClick={(e) => { e.preventDefault(); openModal(); }} className="p-2 text-white/60 hover:text-white hover:bg-theme-bg-hover rounded-md transition-all duration-300" title="Edit Settings" > <Gear size={20} weight="bold" /> </button> )} </div> </div> <SetupProvider availableLLMs={availableLLMs} isOpen={isOpen} provider={value} closeModal={closeModal} postSubmit={onClick} settings={currentSettings} /> </> ); } function SetupProvider({ availableLLMs, isOpen, provider, closeModal, postSubmit, settings, }) { if (!isOpen) return null; const LLMOption = availableLLMs.find((llm) => llm.value === provider); if (!LLMOption) return null; async function handleUpdate(e) { e.preventDefault(); e.stopPropagation(); const data = {}; const form = new FormData(e.target); for (var [key, value] of form.entries()) data[key] = value; const { error } = await System.updateSystem(data); if (error) { showToast(`Failed to save ${LLMOption.name} settings: ${error}`, "error"); return; } closeModal(); postSubmit(); return false; } // Cannot do nested forms, it will cause all sorts of issues, so we portal this out // to the parent container form so we don't have nested forms. return createPortal( <ModalWrapper isOpen={isOpen}> <div className="fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center"> <div className="relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border"> <div className="relative p-6 border-b rounded-t border-theme-modal-border"> <div className="w-full flex gap-x-2 items-center"> <h3 className="text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap"> {LLMOption.name} Settings </h3> </div> <button onClick={closeModal} type="button" className="absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border" > <X size={24} weight="bold" className="text-white" /> </button> </div> <form id="provider-form" onSubmit={handleUpdate}> <div className="px-7 py-6"> <div className="space-y-6 max-h-[60vh] overflow-y-auto p-1"> <p className="text-sm text-white/60"> To use {LLMOption.name} as this workspace's LLM you need to set it up first. </p> <div> {LLMOption.options(settings, { credentialsOnly: true })} </div> </div> </div> <div className="flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border px-7 pb-6"> <button type="button" onClick={closeModal} className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > Cancel </button> <button type="submit" form="provider-form" className="transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm" > Save settings </button> </div> </form> </div> </div> </ModalWrapper>, document.getElementById("workspace-chat-settings-container") ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/Preloader.jsx
frontend/src/components/Preloader.jsx
export default function PreLoader({ size = "16" }) { return ( <div className={`h-${size} w-${size} animate-spin rounded-full border-4 border-solid border-primary border-t-transparent`} ></div> ); } export function FullScreenLoader() { return ( <div id="preloader" className="fixed left-0 top-0 z-999999 flex h-screen w-screen items-center justify-center bg-theme-bg-primary" > <div className="h-16 w-16 animate-spin rounded-full border-4 border-solid border-[var(--theme-loader)] border-t-transparent"></div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/UserMenu/index.jsx
frontend/src/components/UserMenu/index.jsx
import UserButton from "./UserButton"; export default function UserMenu({ children }) { return ( <div className="w-auto h-auto"> <UserButton /> {children} </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/UserMenu/AccountModal/index.jsx
frontend/src/components/UserMenu/AccountModal/index.jsx
import { useLanguageOptions } from "@/hooks/useLanguageOptions"; import usePfp from "@/hooks/usePfp"; import System from "@/models/system"; import Appearance from "@/models/appearance"; import { AUTH_USER } from "@/utils/constants"; import showToast from "@/utils/toast"; import { Info, Plus, X } from "@phosphor-icons/react"; import ModalWrapper from "@/components/ModalWrapper"; import { useTheme } from "@/hooks/useTheme"; import { useTranslation } from "react-i18next"; import { useState, useEffect } from "react"; import { Tooltip } from "react-tooltip"; import { safeJsonParse } from "@/utils/request"; export default function AccountModal({ user, hideModal }) { const { pfp, setPfp } = usePfp(); const { t } = useTranslation(); const handleFileUpload = async (event) => { const file = event.target.files[0]; if (!file) return false; const formData = new FormData(); formData.append("file", file); const { success, error } = await System.uploadPfp(formData); if (!success) { showToast(t("profile_settings.failed_upload", { error }), "error"); return; } const pfpUrl = await System.fetchPfp(user.id); setPfp(pfpUrl); showToast(t("profile_settings.upload_success"), "success"); }; const handleRemovePfp = async () => { const { success, error } = await System.removePfp(); if (!success) { showToast(t("profile_settings.failed_remove", { error }), "error"); return; } setPfp(null); }; const handleUpdate = async (e) => { e.preventDefault(); const data = {}; const form = new FormData(e.target); for (var [key, value] of form.entries()) { if (!value || value === null) continue; data[key] = value; } const { success, error } = await System.updateUser(data); if (success) { let storedUser = safeJsonParse(localStorage.getItem(AUTH_USER), null); if (storedUser) { storedUser.username = data.username; storedUser.bio = data.bio; localStorage.setItem(AUTH_USER, JSON.stringify(storedUser)); } showToast(t("profile_settings.profile_updated"), "success", { clear: true, }); hideModal(); } else { showToast(t("profile_settings.failed_update_user", { error }), "error"); } }; return ( <ModalWrapper isOpen={true}> <div className="w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border overflow-hidden"> <div className="relative p-6 border-b rounded-t border-theme-modal-border"> <div className="w-full flex gap-x-2 items-center"> <h3 className="text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap"> {t("profile_settings.edit_account")} </h3> </div> <button onClick={hideModal} type="button" className="absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border" > <X size={24} weight="bold" className="text-white" /> </button> </div> <div className="h-full w-full overflow-y-auto" style={{ maxHeight: "calc(100vh - 200px)" }} > <form onSubmit={handleUpdate} className="space-y-6"> <div className="flex flex-col md:flex-row items-center justify-center gap-8"> <div className="flex flex-col items-center"> <label className="group w-48 h-48 flex flex-col items-center justify-center bg-theme-bg-primary hover:bg-theme-bg-secondary transition-colors duration-300 rounded-full mt-8 border-2 border-dashed border-white light:border-[#686C6F] light:bg-[#E0F2FE] light:hover:bg-transparent cursor-pointer hover:opacity-60"> <input id="logo-upload" type="file" accept="image/*" className="hidden" onChange={handleFileUpload} /> {pfp ? ( <img src={pfp} alt="User profile picture" className="w-48 h-48 rounded-full object-cover bg-white" /> ) : ( <div className="flex flex-col items-center justify-center p-3"> <Plus className="w-8 h-8 text-theme-text-secondary m-2" /> <span className="text-theme-text-secondary text-opacity-80 text-sm font-semibold"> {t("profile_settings.profile_picture")} </span> <span className="text-theme-text-secondary text-opacity-60 text-xs"> 800 x 800 </span> </div> )} </label> {pfp && ( <button type="button" onClick={handleRemovePfp} className="mt-3 text-theme-text-secondary text-opacity-60 text-sm font-medium hover:underline" > {t("profile_settings.remove_profile_picture")} </button> )} </div> </div> <div className="flex flex-col gap-y-4 px-6"> <div> <label htmlFor="username" className="block mb-2 text-sm font-medium text-theme-text-primary" > {t("profile_settings.username")} </label> <input name="username" type="text" className="border-none bg-theme-settings-input-bg placeholder:text-theme-settings-input-placeholder border-gray-500 text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="User's username" minLength={2} defaultValue={user.username} required autoComplete="off" /> <p className="mt-2 text-xs text-white/60"> {t("profile_settings.username_description")} </p> </div> <div> <label htmlFor="password" className="block mb-2 text-sm font-medium text-white" > {t("profile_settings.new_password")} </label> <input name="password" type="text" className="border-none bg-theme-settings-input-bg placeholder:text-theme-settings-input-placeholder border-gray-500 text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder={`${user.username}'s new password`} minLength={8} /> <p className="mt-2 text-xs text-white/60"> {t("profile_settings.password_description")} </p> </div> <div> <label htmlFor="bio" className="block mb-2 text-sm font-medium text-white" > Bio </label> <textarea name="bio" className="border-none bg-theme-settings-input-bg placeholder:text-theme-settings-input-placeholder border-gray-500 text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5 min-h-[100px] resize-y" placeholder="Tell us about yourself..." defaultValue={user.bio} /> </div> <div className="flex gap-x-16"> <div className="flex flex-col gap-y-6"> <ThemePreference /> <LanguagePreference /> </div> <div className="flex flex-col gap-y-6"> <AutoSubmitPreference /> <AutoSpeakPreference /> </div> </div> </div> <div className="flex justify-between items-center border-t border-theme-modal-border pt-4 p-6"> <button onClick={hideModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > {t("profile_settings.cancel")} </button> <button type="submit" className="transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm" > {t("profile_settings.update_account")} </button> </div> </form> </div> </div> </ModalWrapper> ); } function LanguagePreference() { const { currentLanguage, supportedLanguages, getLanguageName, changeLanguage, } = useLanguageOptions(); const { t } = useTranslation(); return ( <div> <label htmlFor="userLang" className="block mb-2 text-sm font-medium text-white" > {t("profile_settings.language")} </label> <select name="userLang" className="border-none bg-theme-settings-input-bg w-fit mt-2 px-4 focus:outline-primary-button active:outline-primary-button outline-none text-white text-sm rounded-lg block py-2" defaultValue={currentLanguage || "en"} onChange={(e) => changeLanguage(e.target.value)} > {supportedLanguages.map((lang) => { return ( <option key={lang} value={lang}> {getLanguageName(lang)} </option> ); })} </select> </div> ); } function ThemePreference() { const { theme, setTheme, availableThemes } = useTheme(); const { t } = useTranslation(); return ( <div> <label htmlFor="theme" className="block mb-2 text-sm font-medium text-white" > {t("profile_settings.theme")} </label> <select name="theme" value={theme} onChange={(e) => setTheme(e.target.value)} className="border-none bg-theme-settings-input-bg w-fit px-4 focus:outline-primary-button active:outline-primary-button outline-none text-white text-sm rounded-lg block py-2" > {Object.entries(availableThemes).map(([key, value]) => ( <option key={key} value={key}> {value} </option> ))} </select> </div> ); } function AutoSubmitPreference() { const [autoSubmitSttInput, setAutoSubmitSttInput] = useState(true); const { t } = useTranslation(); useEffect(() => { const settings = Appearance.getSettings(); setAutoSubmitSttInput(settings.autoSubmitSttInput ?? true); }, []); const handleChange = (e) => { const newValue = e.target.checked; setAutoSubmitSttInput(newValue); Appearance.updateSettings({ autoSubmitSttInput: newValue }); }; return ( <div> <div className="flex items-center gap-x-1 mb-2"> <label htmlFor="autoSubmit" className="block text-sm font-medium text-white" > {t("customization.chat.auto_submit.title")} </label> <div data-tooltip-id="auto-submit-info" data-tooltip-content={t("customization.chat.auto_submit.description")} className="cursor-pointer h-fit" > <Info size={16} weight="bold" className="text-white" /> </div> </div> <div className="flex items-center gap-x-4"> <label className="relative inline-flex cursor-pointer items-center"> <input id="autoSubmit" type="checkbox" name="autoSubmit" checked={autoSubmitSttInput} onChange={handleChange} className="peer sr-only" /> <div className="pointer-events-none peer h-6 w-11 rounded-full bg-[#CFCFD0] after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:shadow-xl after:border-none after:bg-white after:box-shadow-md after:transition-all after:content-[''] peer-checked:bg-[#32D583] peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-transparent"></div> </label> </div> <Tooltip id="auto-submit-info" place="bottom" delayShow={300} className="allm-tooltip !allm-text-xs" /> </div> ); } function AutoSpeakPreference() { const [autoPlayAssistantTtsResponse, setAutoPlayAssistantTtsResponse] = useState(false); const { t } = useTranslation(); useEffect(() => { const settings = Appearance.getSettings(); setAutoPlayAssistantTtsResponse( settings.autoPlayAssistantTtsResponse ?? false ); }, []); const handleChange = (e) => { const newValue = e.target.checked; setAutoPlayAssistantTtsResponse(newValue); Appearance.updateSettings({ autoPlayAssistantTtsResponse: newValue }); }; return ( <div> <div className="flex items-center gap-x-1 mb-2"> <label htmlFor="autoSpeak" className="block text-sm font-medium text-white" > {t("customization.chat.auto_speak.title")} </label> <div data-tooltip-id="auto-speak-info" data-tooltip-content={t("customization.chat.auto_speak.description")} className="cursor-pointer h-fit" > <Info size={16} weight="bold" className="text-white" /> </div> </div> <div className="flex items-center gap-x-4"> <label className="relative inline-flex cursor-pointer items-center"> <input id="autoSpeak" type="checkbox" name="autoSpeak" checked={autoPlayAssistantTtsResponse} onChange={handleChange} className="peer sr-only" /> <div className="pointer-events-none peer h-6 w-11 rounded-full bg-[#CFCFD0] after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:shadow-xl after:border-none after:bg-white after:box-shadow-md after:transition-all after:content-[''] peer-checked:bg-[#32D583] peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-transparent"></div> </label> </div> <Tooltip id="auto-speak-info" place="bottom" delayShow={300} className="allm-tooltip !allm-text-xs" /> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/UserMenu/UserButton/index.jsx
frontend/src/components/UserMenu/UserButton/index.jsx
import useLoginMode from "@/hooks/useLoginMode"; import usePfp from "@/hooks/usePfp"; import useUser from "@/hooks/useUser"; import System from "@/models/system"; import paths from "@/utils/paths"; import { userFromStorage } from "@/utils/request"; import { Person } from "@phosphor-icons/react"; import { useEffect, useRef, useState } from "react"; import AccountModal from "../AccountModal"; import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER, LAST_VISITED_WORKSPACE, USER_PROMPT_INPUT_MAP, } from "@/utils/constants"; import { useTranslation } from "react-i18next"; export default function UserButton() { const { t } = useTranslation(); const mode = useLoginMode(); const { user } = useUser(); const menuRef = useRef(); const buttonRef = useRef(); const [showMenu, setShowMenu] = useState(false); const [showAccountSettings, setShowAccountSettings] = useState(false); const [supportEmail, setSupportEmail] = useState(""); const handleClose = (event) => { if ( menuRef.current && !menuRef.current.contains(event.target) && !buttonRef.current.contains(event.target) ) { setShowMenu(false); } }; const handleOpenAccountModal = () => { setShowAccountSettings(true); setShowMenu(false); }; useEffect(() => { if (showMenu) { document.addEventListener("mousedown", handleClose); } return () => document.removeEventListener("mousedown", handleClose); }, [showMenu]); useEffect(() => { const fetchSupportEmail = async () => { const supportEmail = await System.fetchSupportEmail(); setSupportEmail( supportEmail?.email ? `mailto:${supportEmail.email}` : paths.mailToMintplex() ); }; fetchSupportEmail(); }, []); if (mode === null) return null; return ( <div className="absolute top-3 right-4 md:top-9 md:right-10 w-fit h-fit z-40"> <button ref={buttonRef} onClick={() => setShowMenu(!showMenu)} type="button" className="uppercase transition-all duration-300 w-[35px] h-[35px] text-base font-semibold rounded-full flex items-center bg-theme-action-menu-bg hover:bg-theme-action-menu-item-hover justify-center text-white p-2 hover:border-slate-100 hover:border-opacity-50 border-transparent border" > {mode === "multi" ? <UserDisplay /> : <Person size={14} />} </button> {showMenu && ( <div ref={menuRef} className="w-fit rounded-lg absolute top-12 right-0 bg-theme-action-menu-bg p-2 flex items-center-justify-center" > <div className="flex flex-col gap-y-2"> {mode === "multi" && !!user && ( <button onClick={handleOpenAccountModal} className="border-none text-white hover:bg-theme-action-menu-item-hover w-full text-left px-4 py-1.5 rounded-md" > {t("profile_settings.account")} </button> )} <a href={supportEmail} className="text-white hover:bg-theme-action-menu-item-hover w-full text-left px-4 py-1.5 rounded-md" > {t("profile_settings.support")} </a> <button onClick={() => { window.localStorage.removeItem(AUTH_USER); window.localStorage.removeItem(AUTH_TOKEN); window.localStorage.removeItem(AUTH_TIMESTAMP); window.localStorage.removeItem(LAST_VISITED_WORKSPACE); window.localStorage.removeItem(USER_PROMPT_INPUT_MAP); window.location.replace(paths.home()); }} type="button" className="text-white hover:bg-theme-action-menu-item-hover w-full text-left px-4 py-1.5 rounded-md" > {t("profile_settings.signout")} </button> </div> </div> )} {user && showAccountSettings && ( <AccountModal user={user} hideModal={() => setShowAccountSettings(false)} /> )} </div> ); } function UserDisplay() { const { pfp } = usePfp(); const user = userFromStorage(); if (pfp) { return ( <div className="w-[35px] h-[35px] rounded-full flex-shrink-0 overflow-hidden transition-all duration-300 bg-gray-100 hover:border-slate-100 hover:border-opacity-50 border-transparent border hover:opacity-60"> <img src={pfp} alt="User profile picture" className="w-full h-full object-cover" /> </div> ); } return user?.username?.slice(0, 2) || "AA"; }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/OpenRouterOptions/index.jsx
frontend/src/components/LLMSelection/OpenRouterOptions/index.jsx
import System from "@/models/system"; import { CaretDown, CaretUp } from "@phosphor-icons/react"; import { useState, useEffect } from "react"; export default function OpenRouterOptions({ settings }) { return ( <div className="flex flex-col gap-y-4 mt-1.5"> <div className="flex gap-[36px]"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> OpenRouter API Key </label> <input type="password" name="OpenRouterApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="OpenRouter API Key" defaultValue={settings?.OpenRouterApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> {!settings?.credentialsOnly && ( <OpenRouterModelSelection settings={settings} /> )} </div> <AdvancedControls settings={settings} /> </div> ); } function AdvancedControls({ settings }) { const [showAdvancedControls, setShowAdvancedControls] = useState(false); return ( <div className="flex flex-col gap-y-4"> <button type="button" onClick={() => setShowAdvancedControls(!showAdvancedControls)} className="border-none text-white hover:text-white/70 flex items-center text-sm" > {showAdvancedControls ? "Hide" : "Show"} advanced controls {showAdvancedControls ? ( <CaretUp size={14} className="ml-1" /> ) : ( <CaretDown size={14} className="ml-1" /> )} </button> <div hidden={!showAdvancedControls}> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Stream Timeout (ms) </label> <input type="number" name="OpenRouterTimeout" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Timeout value between token responses to auto-timeout the stream" defaultValue={settings?.OpenRouterTimeout ?? 3_000} autoComplete="off" onScroll={(e) => e.target.blur()} min={500} step={1} /> </div> </div> </div> ); } function OpenRouterModelSelection({ settings }) { const [groupedModels, setGroupedModels] = useState({}); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models } = await System.customModels("openrouter"); if (models?.length > 0) { const modelsByOrganization = models.reduce((acc, model) => { acc[model.organization] = acc[model.organization] || []; acc[model.organization].push(model); return acc; }, {}); setGroupedModels(modelsByOrganization); } setLoading(false); } findCustomModels(); }, []); if (loading || Object.keys(groupedModels).length === 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="OpenRouterModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="OpenRouterModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {Object.keys(groupedModels) .sort() .map((organization) => ( <optgroup key={organization} label={organization}> {groupedModels[organization].map((model) => ( <option key={model.id} value={model.id} selected={settings?.OpenRouterModelPref === model.id} > {model.name} </option> ))} </optgroup> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/DeepSeekOptions/index.jsx
frontend/src/components/LLMSelection/DeepSeekOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; export default function DeepSeekOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.DeepSeekApiKey); const [deepSeekApiKey, setDeepSeekApiKey] = useState( settings?.DeepSeekApiKey ); return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="DeepSeekApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="DeepSeek API Key" defaultValue={settings?.DeepSeekApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setDeepSeekApiKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <DeepSeekModelSelection settings={settings} apiKey={deepSeekApiKey} /> )} </div> ); } function DeepSeekModelSelection({ apiKey, settings }) { const [models, setModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!apiKey) { setModels([]); setLoading(true); return; } setLoading(true); const { models } = await System.customModels( "deepseek", typeof apiKey === "boolean" ? null : apiKey ); setModels(models || []); setLoading(false); } findCustomModels(); }, [apiKey]); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="DeepSeekModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="DeepSeekModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {models.map((model) => ( <option key={model.id} value={model.id} selected={settings?.DeepSeekModelPref === model.id} > {model.name} </option> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/ZAiLLMOptions/index.jsx
frontend/src/components/LLMSelection/ZAiLLMOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; export default function ZAiLLMOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.ZAiApiKey); const [apiKey, setApiKey] = useState(settings?.ZAiApiKey); return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Z.AI API Key </label> <input type="password" name="ZAiApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Z.AI API Key" defaultValue={settings?.ZAiApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setApiKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <ZAiModelSelection settings={settings} apiKey={apiKey} /> )} </div> ); } function ZAiModelSelection({ apiKey, settings }) { const [customModels, setCustomModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!apiKey) { setCustomModels([]); setLoading(true); return; } try { setLoading(true); const { models } = await System.customModels("zai", apiKey); setCustomModels(models || []); } catch (error) { console.error("Failed to fetch custom models:", error); setCustomModels([]); } finally { setLoading(false); } } findCustomModels(); }, [apiKey]); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="ZAiModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> --loading available models-- </option> </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Enter a valid API key to view all available models for your account. </p> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="ZAiModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {customModels.length > 0 && ( <optgroup label="Available models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={settings?.ZAiModelPref === model.id} > {model.id} </option> ); })} </optgroup> )} </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Select the Z.AI model you want to use for your conversations. </p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/TogetherAiOptions/index.jsx
frontend/src/components/LLMSelection/TogetherAiOptions/index.jsx
import System from "@/models/system"; import { useState, useEffect } from "react"; export default function TogetherAiOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.TogetherAiApiKey); const [apiKey, setApiKey] = useState(settings?.TogetherAiApiKey); return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Together AI API Key </label> <input type="password" name="TogetherAiApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Together AI API Key" defaultValue={settings?.TogetherAiApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setApiKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <TogetherAiModelSelection settings={settings} apiKey={apiKey} /> )} </div> ); } function TogetherAiModelSelection({ settings, apiKey }) { const [groupedModels, setGroupedModels] = useState({}); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); try { const key = apiKey === "*".repeat(20) ? null : apiKey; const { models } = await System.customModels("togetherai", key); if (models?.length > 0) { const modelsByOrganization = models.reduce((acc, model) => { if (model.type !== "chat") return acc; // Only show chat models in dropdown const org = model.organization || "Unknown"; acc[org] = acc[org] || []; acc[org].push({ id: model.id, name: model.name || model.id, organization: org, maxLength: model.maxLength, }); return acc; }, {}); setGroupedModels(modelsByOrganization); } } catch (error) { console.error("Error fetching Together AI models:", error); } setLoading(false); } findCustomModels(); }, [apiKey]); if (loading || Object.keys(groupedModels).length === 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="TogetherAiModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="TogetherAiModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {Object.keys(groupedModels) .sort() .map((organization) => ( <optgroup key={organization} label={organization}> {groupedModels[organization].map((model) => ( <option key={model.id} value={model.id} selected={settings?.TogetherAiModelPref === model.id} > {model.name} </option> ))} </optgroup> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/GeminiLLMOptions/index.jsx
frontend/src/components/LLMSelection/GeminiLLMOptions/index.jsx
import System from "@/models/system"; import { useEffect, useState } from "react"; export default function GeminiLLMOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.GeminiLLMApiKey); const [geminiApiKey, setGeminiApiKey] = useState(settings?.GeminiLLMApiKey); return ( <div className="w-full flex flex-col"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Google AI API Key </label> <input type="password" name="GeminiLLMApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Google Gemini API Key" defaultValue={settings?.GeminiLLMApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setGeminiApiKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <> <GeminiModelSelection apiKey={geminiApiKey} settings={settings} /> {/* Safety setting is not supported for Gemini yet due to the openai compatible Gemini API. We are not using the generativeAPI endpoint and therefore cannot set the safety threshold. <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Safety Setting </label> <select name="GeminiSafetySetting" defaultValue={ settings?.GeminiSafetySetting || "BLOCK_MEDIUM_AND_ABOVE" } required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option value="BLOCK_NONE">None</option> <option value="BLOCK_ONLY_HIGH">Block few</option> <option value="BLOCK_MEDIUM_AND_ABOVE"> Block some (default) </option> <option value="BLOCK_LOW_AND_ABOVE">Block most</option> </select> </div> */} </> )} </div> </div> ); } function GeminiModelSelection({ apiKey, settings }) { const [groupedModels, setGroupedModels] = useState({}); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models } = await System.customModels("gemini", apiKey); if (models?.length > 0) { const modelsByOrganization = models.reduce((acc, model) => { acc[model.experimental ? "Experimental" : "Stable"] = acc[model.experimental ? "Experimental" : "Stable"] || []; acc[model.experimental ? "Experimental" : "Stable"].push(model); return acc; }, {}); setGroupedModels(modelsByOrganization); } setLoading(false); } findCustomModels(); }, [apiKey]); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="GeminiLLMModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="GeminiLLMModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {Object.keys(groupedModels) .sort((a, b) => { if (a === "Stable") return -1; if (b === "Stable") return 1; return a.localeCompare(b); }) .map((organization) => ( <optgroup key={organization} label={organization}> {groupedModels[organization].map((model) => ( <option key={model.id} value={model.id} selected={settings?.GeminiLLMModelPref === model.id} > {model.id} </option> ))} </optgroup> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/HuggingFaceOptions/index.jsx
frontend/src/components/LLMSelection/HuggingFaceOptions/index.jsx
export default function HuggingFaceOptions({ settings }) { return ( <div className="w-full flex flex-col"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> HuggingFace Inference Endpoint </label> <input type="url" name="HuggingFaceLLMEndpoint" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="https://example.endpoints.huggingface.cloud" defaultValue={settings?.HuggingFaceLLMEndpoint} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> HuggingFace Access Token </label> <input type="password" name="HuggingFaceLLMAccessToken" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="HuggingFace Access Token" defaultValue={ settings?.HuggingFaceLLMAccessToken ? "*".repeat(20) : "" } required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Model Token Limit </label> <input type="number" name="HuggingFaceLLMTokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="4096" min={1} onScroll={(e) => e.target.blur()} defaultValue={settings?.HuggingFaceLLMTokenLimit} required={true} autoComplete="off" /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/PPIOLLMOptions/index.jsx
frontend/src/components/LLMSelection/PPIOLLMOptions/index.jsx
import System from "@/models/system"; import { useState, useEffect } from "react"; export default function PPIOLLMOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-start gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> PPIO API Key </label> <input type="password" name="PPIOApiKey" className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="PPIO API Key" defaultValue={settings?.PPIOApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> {!settings?.credentialsOnly && ( <PPIOModelSelection settings={settings} /> )} </div> </div> ); } function PPIOModelSelection({ settings }) { const [groupedModels, setGroupedModels] = useState({}); const [loading, setLoading] = useState(true); useEffect(() => { async function fetchModels() { setLoading(true); const { models } = await System.customModels("ppio"); if (models?.length > 0) { const modelsByOrganization = models.reduce((acc, model) => { acc[model.organization] = acc[model.organization] || []; acc[model.organization].push(model); return acc; }, {}); setGroupedModels(modelsByOrganization); } setLoading(false); } fetchModels(); }, []); if (loading || Object.keys(groupedModels).length === 0) { return ( <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="PPIOModelPref" required={true} disabled={true} className="bg-theme-settings-input-bg text-theme-text-primary text-sm rounded-lg focus:ring-primary-button focus:border-primary-button block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="PPIOModelPref" required={true} className="border-none bg-theme-settings-input-bg text-theme-text-primary border-theme-border text-sm rounded-lg block w-full p-2.5" > {Object.keys(groupedModels) .sort() .map((organization) => ( <optgroup key={organization} label={organization}> {groupedModels[organization].map((model) => ( <option key={model.id} value={model.id} selected={settings?.PPIOModelPref === model.id} > {model.name} </option> ))} </optgroup> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/AwsBedrockLLMOptions/index.jsx
frontend/src/components/LLMSelection/AwsBedrockLLMOptions/index.jsx
import { ArrowSquareOut, Info } from "@phosphor-icons/react"; import { AWS_REGIONS } from "./regions"; import { useState } from "react"; export default function AwsBedrockLLMOptions({ settings }) { const [connectionMethod, setConnectionMethod] = useState( settings?.AwsBedrockLLMConnectionMethod ?? "iam" ); return ( <div className="w-full flex flex-col"> {!settings?.credentialsOnly && connectionMethod !== "apiKey" && ( <div className="flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-4 bg-blue-800/30 w-fit rounded-lg px-4 py-2"> <div className="gap-x-2 flex items-center"> <Info size={40} /> <p className="text-base"> You should use a properly defined IAM user for inferencing. <br /> <a href="https://docs.anythingllm.com/setup/llm-configuration/cloud/aws-bedrock" target="_blank" className="underline flex gap-x-1 items-center" rel="noreferrer" > Read more on how to use AWS Bedrock in AnythingLLM <ArrowSquareOut size={14} /> </a> </p> </div> </div> )} <div className="flex flex-col gap-y-2 mb-2"> <input type="hidden" name="AwsBedrockLLMConnectionMethod" value={connectionMethod} /> <div className="flex flex-col w-full"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Authentication Method </label> <p className="text-theme-text-secondary text-sm"> Select the method to authenticate with AWS Bedrock. </p> </div> <select name="AwsBedrockLLMConnectionMethod" value={connectionMethod} required={true} onChange={(e) => setConnectionMethod(e.target.value)} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-fit p-2.5" > <option value="iam">IAM (Explicit Credentials)</option> <option value="sessionToken"> Session Token (Temporary Credentials) </option> <option value="iam_role">IAM Role (Implied Credentials)</option> <option value="apiKey">Bedrock API Key</option> </select> </div> <div className="w-full flex items-center gap-[36px] my-1.5"> {["iam", "sessionToken"].includes(connectionMethod) && ( <> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> AWS Bedrock IAM Access ID </label> <input type="password" name="AwsBedrockLLMAccessKeyId" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="AWS Bedrock IAM User Access ID" defaultValue={ settings?.AwsBedrockLLMAccessKeyId ? "*".repeat(20) : "" } required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> AWS Bedrock IAM Access Key </label> <input type="password" name="AwsBedrockLLMAccessKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="AWS Bedrock IAM User Access Key" defaultValue={ settings?.AwsBedrockLLMAccessKey ? "*".repeat(20) : "" } required={true} autoComplete="off" spellCheck={false} /> </div> </> )} {connectionMethod === "sessionToken" && ( <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> AWS Bedrock Session Token </label> <input type="password" name="AwsBedrockLLMSessionToken" className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="AWS Bedrock Session Token" defaultValue={ settings?.AwsBedrockLLMSessionToken ? "*".repeat(20) : "" } required={true} autoComplete="off" spellCheck={false} /> </div> )} {connectionMethod === "apiKey" && ( <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> AWS Bedrock API Key </label> <input type="password" name="AwsBedrockLLMAPIKey" className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="AWS Bedrock API Key" defaultValue={settings?.AwsBedrockLLMAPIKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> )} <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> AWS region </label> <select name="AwsBedrockLLMRegion" defaultValue={settings?.AwsBedrockLLMRegion || "us-west-2"} required={true} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" > {AWS_REGIONS.map((region) => { return ( <option key={region.code} value={region.code}> {region.name} ({region.code}) </option> ); })} </select> </div> </div> <div className="w-full flex items-center gap-[36px] my-1.5"> {!settings?.credentialsOnly && ( <> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Model ID </label> <input type="text" name="AwsBedrockLLMModel" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Model id from AWS eg: meta.llama3.1-v0.1" defaultValue={settings?.AwsBedrockLLMModel} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Model context window </label> <input type="number" name="AwsBedrockLLMTokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Content window limit (eg: 8192)" min={1} onScroll={(e) => e.target.blur()} defaultValue={settings?.AwsBedrockLLMTokenLimit} required={true} autoComplete="off" /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Model max output tokens </label> <input type="number" name="AwsBedrockLLMMaxOutputTokens" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Max output tokens (eg: 4096)" min={1} onScroll={(e) => e.target.blur()} defaultValue={settings?.AwsBedrockLLMMaxOutputTokens} required={true} autoComplete="off" /> </div> </> )} </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/AwsBedrockLLMOptions/regions.js
frontend/src/components/LLMSelection/AwsBedrockLLMOptions/regions.js
export const AWS_REGIONS = [ { name: "N. Virginia", full_name: "US East (N. Virginia)", code: "us-east-1", public: true, zones: [ "us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e", "us-east-1f", ], }, { name: "Ohio", full_name: "US East (Ohio)", code: "us-east-2", public: true, zones: ["us-east-2a", "us-east-2b", "us-east-2c"], }, { name: "N. California", full_name: "US West (N. California)", code: "us-west-1", public: true, zone_limit: 2, zones: ["us-west-1a", "us-west-1b", "us-west-1c"], }, { name: "Oregon", full_name: "US West (Oregon)", code: "us-west-2", public: true, zones: ["us-west-2a", "us-west-2b", "us-west-2c", "us-west-2d"], }, { name: "GovCloud West", full_name: "AWS GovCloud (US)", code: "us-gov-west-1", public: false, zones: ["us-gov-west-1a", "us-gov-west-1b", "us-gov-west-1c"], }, { name: "GovCloud East", full_name: "AWS GovCloud (US-East)", code: "us-gov-east-1", public: false, zones: ["us-gov-east-1a", "us-gov-east-1b", "us-gov-east-1c"], }, { name: "Canada", full_name: "Canada (Central)", code: "ca-central-1", public: true, zones: ["ca-central-1a", "ca-central-1b", "ca-central-1c", "ca-central-1d"], }, { name: "Stockholm", full_name: "EU (Stockholm)", code: "eu-north-1", public: true, zones: ["eu-north-1a", "eu-north-1b", "eu-north-1c"], }, { name: "Ireland", full_name: "EU (Ireland)", code: "eu-west-1", public: true, zones: ["eu-west-1a", "eu-west-1b", "eu-west-1c"], }, { name: "London", full_name: "EU (London)", code: "eu-west-2", public: true, zones: ["eu-west-2a", "eu-west-2b", "eu-west-2c"], }, { name: "Paris", full_name: "EU (Paris)", code: "eu-west-3", public: true, zones: ["eu-west-3a", "eu-west-3b", "eu-west-3c"], }, { name: "Frankfurt", full_name: "EU (Frankfurt)", code: "eu-central-1", public: true, zones: ["eu-central-1a", "eu-central-1b", "eu-central-1c"], }, { name: "Milan", full_name: "EU (Milan)", code: "eu-south-1", public: true, zones: ["eu-south-1a", "eu-south-1b", "eu-south-1c"], }, { name: "Cape Town", full_name: "Africa (Cape Town)", code: "af-south-1", public: true, zones: ["af-south-1a", "af-south-1b", "af-south-1c"], }, { name: "Tokyo", full_name: "Asia Pacific (Tokyo)", code: "ap-northeast-1", public: true, zone_limit: 3, zones: [ "ap-northeast-1a", "ap-northeast-1b", "ap-northeast-1c", "ap-northeast-1d", ], }, { name: "Seoul", full_name: "Asia Pacific (Seoul)", code: "ap-northeast-2", public: true, zones: [ "ap-northeast-2a", "ap-northeast-2b", "ap-northeast-2c", "ap-northeast-2d", ], }, { name: "Osaka", full_name: "Asia Pacific (Osaka-Local)", code: "ap-northeast-3", public: true, zones: ["ap-northeast-3a", "ap-northeast-3b", "ap-northeast-3c"], }, { name: "Singapore", full_name: "Asia Pacific (Singapore)", code: "ap-southeast-1", public: true, zones: ["ap-southeast-1a", "ap-southeast-1b", "ap-southeast-1c"], }, { name: "Sydney", full_name: "Asia Pacific (Sydney)", code: "ap-southeast-2", public: true, zones: ["ap-southeast-2a", "ap-southeast-2b", "ap-southeast-2c"], }, { name: "Jakarta", full_name: "Asia Pacific (Jakarta)", code: "ap-southeast-3", public: true, zones: ["ap-southeast-3a", "ap-southeast-3b", "ap-southeast-3c"], }, { name: "Hong Kong", full_name: "Asia Pacific (Hong Kong)", code: "ap-east-1", public: true, zones: ["ap-east-1a", "ap-east-1b", "ap-east-1c"], }, { name: "Mumbai", full_name: "Asia Pacific (Mumbai)", code: "ap-south-1", public: true, zones: ["ap-south-1a", "ap-south-1b", "ap-south-1c"], }, { name: "São Paulo", full_name: "South America (São Paulo)", code: "sa-east-1", public: true, zone_limit: 2, zones: ["sa-east-1a", "sa-east-1b", "sa-east-1c"], }, { name: "Bahrain", full_name: "Middle East (Bahrain)", code: "me-south-1", public: true, zones: ["me-south-1a", "me-south-1b", "me-south-1c"], }, { name: "Beijing", full_name: "China (Beijing)", code: "cn-north-1", public: false, zones: ["cn-north-1a", "cn-north-1b", "cn-north-1c"], }, { name: "Ningxia", full_name: "China (Ningxia)", code: "cn-northwest-1", public: false, zones: ["cn-northwest-1a", "cn-northwest-1b", "cn-northwest-1c"], }, ];
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/ApiPieOptions/index.jsx
frontend/src/components/LLMSelection/ApiPieOptions/index.jsx
import System from "@/models/system"; import { useState, useEffect } from "react"; export default function ApiPieLLMOptions({ settings }) { return ( <div className="flex flex-col gap-y-4 mt-1.5"> <div className="flex gap-[36px]"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> APIpie API Key </label> <input type="password" name="ApipieLLMApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="APIpie API Key" defaultValue={settings?.ApipieLLMApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> {!settings?.credentialsOnly && ( <APIPieModelSelection settings={settings} /> )} </div> </div> ); } function APIPieModelSelection({ settings }) { const [groupedModels, setGroupedModels] = useState({}); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models } = await System.customModels("apipie"); if (models?.length > 0) { const modelsByOrganization = models.reduce((acc, model) => { acc[model.organization] = acc[model.organization] || []; acc[model.organization].push(model); return acc; }, {}); setGroupedModels(modelsByOrganization); } setLoading(false); } findCustomModels(); }, []); if (loading || Object.keys(groupedModels).length === 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="ApipieLLMModelPref" disabled={true} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="ApipieLLMModelPref" required={true} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" > {Object.keys(groupedModels) .sort() .map((organization) => ( <optgroup key={organization} label={organization}> {groupedModels[organization].map((model) => ( <option key={model.id} value={model.id} selected={settings?.ApipieLLMModelPref === model.id} > {model.name} </option> ))} </optgroup> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/LMStudioOptions/index.jsx
frontend/src/components/LLMSelection/LMStudioOptions/index.jsx
import { useEffect, useState } from "react"; import { Info, CaretDown, CaretUp } from "@phosphor-icons/react"; import paths from "@/utils/paths"; import System from "@/models/system"; import PreLoader from "@/components/Preloader"; import { LMSTUDIO_COMMON_URLS } from "@/utils/constants"; import useProviderEndpointAutoDiscovery from "@/hooks/useProviderEndpointAutoDiscovery"; export default function LMStudioOptions({ settings, showAlert = false }) { const { autoDetecting: loading, basePath, basePathValue, showAdvancedControls, setShowAdvancedControls, handleAutoDetectClick, } = useProviderEndpointAutoDiscovery({ provider: "lmstudio", initialBasePath: settings?.LMStudioBasePath, ENDPOINTS: LMSTUDIO_COMMON_URLS, }); const [maxTokens, setMaxTokens] = useState( settings?.LMStudioTokenLimit || "" ); const handleMaxTokensChange = (e) => { setMaxTokens(e.target.value ? Number(e.target.value) : ""); }; return ( <div className="w-full flex flex-col gap-y-7"> {showAlert && ( <div className="flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-6 bg-blue-800/30 w-fit rounded-lg px-4 py-2"> <div className="gap-x-2 flex items-center"> <Info size={12} className="hidden md:visible" /> <p className="text-sm md:text-base"> LMStudio as your LLM requires you to set an embedding service to use. </p> </div> <a href={paths.settings.embedder.modelPreference()} className="text-sm md:text-base my-2 underline" > Manage embedding &rarr; </a> </div> )} <div className="w-full flex items-start gap-[36px] mt-1.5"> <LMStudioModelSelection settings={settings} basePath={basePath.value} /> </div> <div className="flex justify-start mt-4"> <button onClick={(e) => { e.preventDefault(); setShowAdvancedControls(!showAdvancedControls); }} className="border-none text-theme-text-primary hover:text-theme-text-secondary flex items-center text-sm" > {showAdvancedControls ? "Hide" : "Show"} advanced settings {showAdvancedControls ? ( <CaretUp size={14} className="ml-1" /> ) : ( <CaretDown size={14} className="ml-1" /> )} </button> </div> <div hidden={!showAdvancedControls}> <div className="w-full flex items-start gap-4"> <div className="flex flex-col w-60"> <div className="flex justify-between items-center mb-2"> <label className="text-white text-sm font-semibold"> LM Studio Base URL </label> {loading ? ( <PreLoader size="6" /> ) : ( <> {!basePathValue.value && ( <button onClick={handleAutoDetectClick} className="bg-primary-button text-xs font-medium px-2 py-1 rounded-lg hover:bg-secondary hover:text-white shadow-[0_4px_14px_rgba(0,0,0,0.25)]" > Auto-Detect </button> )} </> )} </div> <input type="url" name="LMStudioBasePath" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://localhost:1234/v1" value={basePathValue.value} required={true} autoComplete="off" spellCheck={false} onChange={basePath.onChange} onBlur={basePath.onBlur} /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Enter the URL where LM Studio is running. </p> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Max Tokens (Optional) </label> <input type="number" name="LMStudioTokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Auto-detected from model" min={1} value={maxTokens} onChange={handleMaxTokensChange} onScroll={(e) => e.target.blur()} required={false} autoComplete="off" /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Override the context window limit. Leave empty to auto-detect from the model (defaults to 4096 if detection fails). </p> </div> </div> </div> </div> ); } function LMStudioModelSelection({ settings, basePath = 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( "lmstudio", null, basePath ); setCustomModels(models || []); } catch (error) { console.error("Failed to fetch custom models:", error); setCustomModels([]); } setLoading(false); } findCustomModels(); }, [basePath]); if (loading || customModels.length === 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> LM Studio Model </label> <select name="LMStudioModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> {!!basePath ? "--loading available models--" : "Enter LM Studio URL first"} </option> </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Select the LM Studio model you want to use. Models will load after entering a valid LM Studio URL. </p> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> LM Studio Model </label> <select name="LMStudioModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {customModels.length > 0 && ( <optgroup label="Your loaded models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={settings.LMStudioModelPref === model.id} > {model.id} </option> ); })} </optgroup> )} </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Choose the LM Studio model you want to use for your conversations. </p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/NvidiaNimOptions/managed.jsx
frontend/src/components/LLMSelection/NvidiaNimOptions/managed.jsx
/** * This component is used to select, start, and manage NVIDIA NIM * containers and images via docker management tools. */ export default function ManagedNvidiaNimOptions({ settings }) { return null; }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/NvidiaNimOptions/index.jsx
frontend/src/components/LLMSelection/NvidiaNimOptions/index.jsx
import RemoteNvidiaNimOptions from "./remote"; import ManagedNvidiaNimOptions from "./managed"; export default function NvidiaNimOptions({ settings }) { const version = "remote"; // static to "remote" when in docker version. return version === "remote" ? ( <RemoteNvidiaNimOptions settings={settings} /> ) : ( <ManagedNvidiaNimOptions settings={settings} /> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/NvidiaNimOptions/remote.jsx
frontend/src/components/LLMSelection/NvidiaNimOptions/remote.jsx
import PreLoader from "@/components/Preloader"; import useProviderEndpointAutoDiscovery from "@/hooks/useProviderEndpointAutoDiscovery"; import System from "@/models/system"; import { NVIDIA_NIM_COMMON_URLS } from "@/utils/constants"; import { useState, useEffect } from "react"; /** * This component is used to select a remote NVIDIA NIM model endpoint * This is the default component and way to connect to NVIDIA NIM * as the "managed" provider can only work in the Desktop context. */ export default function RemoteNvidiaNimOptions({ settings }) { const { autoDetecting: loading, basePath, basePathValue, handleAutoDetectClick, } = useProviderEndpointAutoDiscovery({ provider: "nvidia-nim", initialBasePath: settings?.NvidiaNimLLMBasePath, ENDPOINTS: NVIDIA_NIM_COMMON_URLS, }); return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <div className="flex justify-between items-center mb-2"> <label className="text-white text-sm font-semibold"> NVIDIA Nim Base URL </label> {loading ? ( <PreLoader size="6" /> ) : ( <> {!basePathValue.value && ( <button onClick={handleAutoDetectClick} className="bg-primary-button text-xs font-medium px-2 py-1 rounded-lg hover:bg-secondary hover:text-white shadow-[0_4px_14px_rgba(0,0,0,0.25)]" > Auto-Detect </button> )} </> )} </div> <input type="url" name="NvidiaNimLLMBasePath" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://localhost:8000/v1" value={basePathValue.value} required={true} autoComplete="off" spellCheck={false} onChange={basePath.onChange} onBlur={basePath.onBlur} /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Enter the URL where NVIDIA NIM is running. </p> </div> {!settings?.credentialsOnly && ( <NvidiaNimModelSelection settings={settings} basePath={basePath.value} /> )} </div> ); } function NvidiaNimModelSelection({ settings, basePath }) { const [models, setModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models } = await System.customModels( "nvidia-nim", null, basePath ); setModels(models); setLoading(false); } findCustomModels(); }, [basePath]); if (loading || models.length === 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="NvidiaNimLLMModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="NvidiaNimLLMModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {models.map((model) => ( <option key={model.id} value={model.id} selected={settings?.NvidiaNimLLMModelPref === model.id} > {model.name} </option> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/PerplexityOptions/index.jsx
frontend/src/components/LLMSelection/PerplexityOptions/index.jsx
import System from "@/models/system"; import { useState, useEffect } from "react"; export default function PerplexityOptions({ settings }) { return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Perplexity API Key </label> <input type="password" name="PerplexityApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Perplexity API Key" defaultValue={settings?.PerplexityApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> {!settings?.credentialsOnly && ( <PerplexityModelSelection settings={settings} /> )} </div> ); } function PerplexityModelSelection({ settings }) { const [customModels, setCustomModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models } = await System.customModels("perplexity"); setCustomModels(models || []); setLoading(false); } findCustomModels(); }, []); if (loading || customModels.length == 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="PerplexityModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="PerplexityModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {customModels.length > 0 && ( <optgroup label="Available Perplexity Models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={settings?.PerplexityModelPref === model.id} > {model.id} </option> ); })} </optgroup> )} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/GiteeAIOptions/index.jsx
frontend/src/components/LLMSelection/GiteeAIOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; export default function GiteeAIOptions({ settings }) { return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="GiteeAIApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="GiteeAI API Key" defaultValue={settings?.GiteeAIApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> {!settings?.credentialsOnly && ( <> <GiteeAIModelSelection settings={settings} /> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Token context window </label> <input type="number" name="GiteeAITokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Content window limit (eg: 8192)" min={1} onScroll={(e) => e.target.blur()} defaultValue={settings?.GiteeAITokenLimit} required={true} autoComplete="off" /> </div> </> )} </div> ); } function GiteeAIModelSelection({ settings }) { const [groupedModels, setGroupedModels] = useState({}); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models = [] } = await System.customModels("giteeai"); if (models?.length > 0) { const modelsByOrganization = models.reduce((acc, model) => { acc[model.organization] = acc[model.organization] || []; acc[model.organization].push(model); return acc; }, {}); setGroupedModels(modelsByOrganization); } setLoading(false); } findCustomModels(); }, []); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="GiteeAIModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="GiteeAIModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {Object.keys(groupedModels) .sort() .map((organization) => ( <optgroup key={organization} label={organization}> {groupedModels[organization].map((model) => ( <option key={model.id} value={model.id} selected={settings?.GiteeAIModelPref === model.id} > {model.name} </option> ))} </optgroup> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/AnthropicAiOptions/index.jsx
frontend/src/components/LLMSelection/AnthropicAiOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; import { CaretDown, CaretUp } from "@phosphor-icons/react"; export default function AnthropicAiOptions({ settings }) { const [showAdvancedControls, setShowAdvancedControls] = useState(false); const [inputValue, setInputValue] = useState(settings?.AnthropicApiKey); const [anthropicApiKey, setAnthropicApiKey] = useState( settings?.AnthropicApiKey ); return ( <div className="w-full flex flex-col"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Anthropic API Key </label> <input type="password" name="AnthropicApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Anthropic Claude-2 API Key" defaultValue={settings?.AnthropicApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setAnthropicApiKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <AnthropicModelSelection apiKey={anthropicApiKey} settings={settings} /> )} </div> <div className="flex justify-start mt-4"> <button onClick={(e) => { e.preventDefault(); setShowAdvancedControls(!showAdvancedControls); }} className="border-none text-theme-text-primary hover:text-theme-text-secondary flex items-center text-sm" > {showAdvancedControls ? "Hide" : "Show"} advanced settings {showAdvancedControls ? ( <CaretUp size={14} className="ml-1" /> ) : ( <CaretDown size={14} className="ml-1" /> )} </button> </div> <div hidden={!showAdvancedControls}> <div className="w-full flex items-start gap-4 mt-1.5"> <div className="flex flex-col w-60"> <div className="flex justify-between items-center mb-2"> <label className="text-white text-sm font-semibold"> Prompt Caching </label> </div> <select name="AnthropicCacheControl" className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option value="none" selected={settings?.AnthropicCacheControl === "none"} > No caching </option> <option value="5m" selected={settings?.AnthropicCacheControl === "5m"} > 5 minutes </option> <option value="1h" selected={settings?.AnthropicCacheControl === "1h"} > 1 hour </option> </select> </div> </div> </div> </div> ); } const DEFAULT_MODELS = [ { id: "claude-3-7-sonnet-20250219", name: "Claude 3.7 Sonnet", }, { id: "claude-3-5-sonnet-20241022", name: "Claude 3.5 Sonnet (New)", }, { id: "claude-3-5-haiku-20241022", name: "Claude 3.5 Haiku", }, { id: "claude-3-5-sonnet-20240620", name: "Claude 3.5 Sonnet (Old)", }, { id: "claude-3-haiku-20240307", name: "Claude 3 Haiku", }, { id: "claude-3-opus-20240229", name: "Claude 3 Opus", }, { id: "claude-3-sonnet-20240229", name: "Claude 3 Sonnet", }, { id: "claude-2.1", name: "Claude 2.1", }, { id: "claude-2.0", name: "Claude 2.0", }, ]; function AnthropicModelSelection({ apiKey, settings }) { const [models, setModels] = useState(DEFAULT_MODELS); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models } = await System.customModels( "anthropic", typeof apiKey === "boolean" ? null : apiKey ); if (models.length > 0) setModels(models); setLoading(false); } findCustomModels(); }, [apiKey]); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="AnthropicModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="AnthropicModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {models.map((model) => ( <option key={model.id} value={model.id} selected={settings?.AnthropicModelPref === model.id} > {model.name} </option> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/FireworksAiOptions/index.jsx
frontend/src/components/LLMSelection/FireworksAiOptions/index.jsx
import System from "@/models/system"; import { useState, useEffect } from "react"; export default function FireworksAiOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.FireworksAiLLMApiKey); const [fireworksAiApiKey, setFireworksAiApiKey] = useState( settings?.FireworksAiLLMApiKey ); return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Fireworks AI API Key </label> <input type="password" name="FireworksAiLLMApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Fireworks AI API Key" defaultValue={settings?.FireworksAiLLMApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setFireworksAiApiKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <FireworksAiModelSelection apiKey={fireworksAiApiKey} settings={settings} /> )} </div> ); } function FireworksAiModelSelection({ apiKey, settings }) { const [groupedModels, setGroupedModels] = useState({}); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models } = await System.customModels("fireworksai", apiKey); if (models?.length > 0) { const modelsByOrganization = models.reduce((acc, model) => { acc[model.organization] = acc[model.organization] || []; acc[model.organization].push(model); return acc; }, {}); setGroupedModels(modelsByOrganization); } setLoading(false); } findCustomModels(); }, [apiKey]); if (loading || Object.keys(groupedModels).length === 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="FireworksAiLLMModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="FireworksAiLLMModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {Object.keys(groupedModels) .sort() .map((organization) => ( <optgroup key={organization} label={organization}> {groupedModels[organization].map((model) => ( <option key={model.id} value={model.id} selected={settings?.FireworksAiLLMModelPref === model.id} > {model.name} </option> ))} </optgroup> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/AzureAiOptions/index.jsx
frontend/src/components/LLMSelection/AzureAiOptions/index.jsx
import { Info } from "@phosphor-icons/react"; import { useTranslation } from "react-i18next"; import { Tooltip } from "react-tooltip"; export default function AzureAiOptions({ settings }) { const { t } = useTranslation(); return ( <div className="w-full flex flex-col gap-y-7 mt-1.5"> <div className="w-full flex items-center gap-[36px]"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> {t("llm.providers.azure_openai.azure_service_endpoint")} </label> <input type="url" name="AzureOpenAiEndpoint" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="https://my-azure.openai.azure.com" defaultValue={settings?.AzureOpenAiEndpoint} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> {t("llm.providers.azure_openai.api_key")} </label> <input type="password" name="AzureOpenAiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Azure OpenAI API Key" defaultValue={settings?.AzureOpenAiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> {t("llm.providers.azure_openai.chat_deployment_name")} </label> <input type="text" name="AzureOpenAiModelPref" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Azure OpenAI chat model deployment name" defaultValue={settings?.AzureOpenAiModelPref} required={true} autoComplete="off" spellCheck={false} /> </div> </div> <div className="w-full flex items-center gap-[36px]"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> {t("llm.providers.azure_openai.chat_model_token_limit")} </label> <select name="AzureOpenAiTokenLimit" defaultValue={settings?.AzureOpenAiTokenLimit || 4096} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" required={true} > <option value={4096}>4,096 (gpt-3.5-turbo)</option> <option value={16384}>16,384 (gpt-3.5-16k)</option> <option value={8192}>8,192 (gpt-4)</option> <option value={32768}>32,768 (gpt-4-32k)</option> <option value={128000}> 128,000 (gpt-4-turbo,gpt-4o,gpt-4o-mini,o1-mini) </option> <option value={200000}>200,000 (o1,o1-pro,o3-mini)</option> <option value={1047576}>1,047,576 (gpt-4.1)</option> </select> </div> <div className="flex flex-col w-60"> <div className="flex items-center gap-1 mb-3"> <label className="text-white text-sm font-semibold block"> {t("llm.providers.azure_openai.model_type")} </label> <Tooltip id="azure-openai-model-type" place="top" delayShow={300} className="tooltip !text-xs !opacity-100" style={{ maxWidth: "250px", whiteSpace: "normal", wordWrap: "break-word", }} /> <div type="button" className="text-theme-text-secondary cursor-pointer hover:bg-theme-bg-primary flex items-center justify-center rounded-full" data-tooltip-id="azure-openai-model-type" data-tooltip-place="top" data-tooltip-content={t( "llm.providers.azure_openai.model_type_tooltip" )} > <Info size={18} className="text-theme-text-secondary" /> </div> </div> <select name="AzureOpenAiModelType" defaultValue={settings?.AzureOpenAiModelType || "default"} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" required={true} > <option value="default"> {t("llm.providers.azure_openai.default")} </option> <option value="reasoning"> {t("llm.providers.azure_openai.reasoning")} </option> </select> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/GroqAiOptions/index.jsx
frontend/src/components/LLMSelection/GroqAiOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; export default function GroqAiOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.GroqApiKey); const [apiKey, setApiKey] = useState(settings?.GroqApiKey); return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Groq API Key </label> <input type="password" name="GroqApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Groq API Key" defaultValue={settings?.GroqApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setApiKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <GroqAIModelSelection settings={settings} apiKey={apiKey} /> )} </div> ); } function GroqAIModelSelection({ apiKey, settings }) { const [customModels, setCustomModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!apiKey) { setCustomModels([]); setLoading(true); return; } try { setLoading(true); const { models } = await System.customModels("groq", apiKey); setCustomModels(models || []); } catch (error) { console.error("Failed to fetch custom models:", error); setCustomModels([]); } finally { setLoading(false); } } findCustomModels(); }, [apiKey]); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="GroqModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> --loading available models-- </option> </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Enter a valid API key to view all available models for your account. </p> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="GroqModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {customModels.length > 0 && ( <optgroup label="Available models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={settings?.GroqModelPref === model.id} > {model.id} </option> ); })} </optgroup> )} </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Select the GroqAI model you want to use for your conversations. </p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/LocalAiOptions/index.jsx
frontend/src/components/LLMSelection/LocalAiOptions/index.jsx
import React, { useEffect, useState } from "react"; import { Info, CaretDown, CaretUp } from "@phosphor-icons/react"; import paths from "@/utils/paths"; import System from "@/models/system"; import PreLoader from "@/components/Preloader"; import { LOCALAI_COMMON_URLS } from "@/utils/constants"; import useProviderEndpointAutoDiscovery from "@/hooks/useProviderEndpointAutoDiscovery"; export default function LocalAiOptions({ settings, showAlert = false }) { const { autoDetecting: loading, basePath, basePathValue, showAdvancedControls, setShowAdvancedControls, handleAutoDetectClick, } = useProviderEndpointAutoDiscovery({ provider: "localai", initialBasePath: settings?.LocalAiBasePath, ENDPOINTS: LOCALAI_COMMON_URLS, }); const [apiKeyValue, setApiKeyValue] = useState(settings?.LocalAiApiKey); const [apiKey, setApiKey] = useState(settings?.LocalAiApiKey); return ( <div className="w-full flex flex-col gap-y-7"> {showAlert && ( <div className="flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-6 bg-blue-800/30 w-fit rounded-lg px-4 py-2"> <div className="gap-x-2 flex items-center"> <Info size={12} className="hidden md:visible" /> <p className="text-sm md:text-base"> LocalAI as your LLM requires you to set an embedding service to use. </p> </div> <a href={paths.settings.embedder.modelPreference()} className="text-sm md:text-base my-2 underline" > Manage embedding &rarr; </a> </div> )} <div className="w-full flex items-center gap-[36px] mt-1.5"> {!settings?.credentialsOnly && ( <> <LocalAIModelSelection settings={settings} basePath={basePath.value} apiKey={apiKey} /> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Token context window </label> <input type="number" name="LocalAiTokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="4096" min={1} onScroll={(e) => e.target.blur()} defaultValue={settings?.LocalAiTokenLimit} required={true} autoComplete="off" /> </div> </> )} <div className="flex flex-col w-60"> <div className="flex flex-col gap-y-1 mb-2"> <label className="text-white text-sm font-semibold flex items-center gap-x-2"> Local AI API Key{" "} <p className="!text-xs !italic !font-thin">optional</p> </label> </div> <input type="password" name="LocalAiApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="sk-mysecretkey" defaultValue={settings?.LocalAiApiKey ? "*".repeat(20) : ""} autoComplete="off" spellCheck={false} onChange={(e) => setApiKeyValue(e.target.value)} onBlur={() => setApiKey(apiKeyValue)} /> </div> </div> <div className="flex justify-start mt-4"> <button onClick={(e) => { e.preventDefault(); setShowAdvancedControls(!showAdvancedControls); }} className="border-none text-theme-text-primary hover:text-theme-text-secondary flex items-center text-sm" > {showAdvancedControls ? "Hide" : "Show"} advanced settings {showAdvancedControls ? ( <CaretUp size={14} className="ml-1" /> ) : ( <CaretDown size={14} className="ml-1" /> )} </button> </div> <div hidden={!showAdvancedControls}> <div className="w-full flex items-center gap-4"> <div className="flex flex-col w-60"> <div className="flex justify-between items-center mb-2"> <label className="text-white text-sm font-semibold"> Local AI Base URL </label> {loading ? ( <PreLoader size="6" /> ) : ( <> {!basePathValue.value && ( <button onClick={handleAutoDetectClick} className="bg-primary-button text-xs font-medium px-2 py-1 rounded-lg hover:bg-secondary hover:text-white shadow-[0_4px_14px_rgba(0,0,0,0.25)]" > Auto-Detect </button> )} </> )} </div> <input type="url" name="LocalAiBasePath" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://localhost:8080/v1" value={basePathValue.value} required={true} autoComplete="off" spellCheck={false} onChange={basePath.onChange} onBlur={basePath.onBlur} /> </div> </div> </div> </div> ); } function LocalAIModelSelection({ settings, basePath = null, apiKey = null }) { const [customModels, setCustomModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!basePath || !basePath.includes("/v1")) { setCustomModels([]); setLoading(false); return; } setLoading(true); const { models } = await System.customModels( "localai", typeof apiKey === "boolean" ? null : apiKey, basePath ); setCustomModels(models || []); setLoading(false); } findCustomModels(); }, [basePath, apiKey]); if (loading || customModels.length == 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Chat Model Selection </label> <select name="LocalAiModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> {basePath?.includes("/v1") ? "-- loading available models --" : "-- waiting for URL --"} </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Chat Model Selection </label> <select name="LocalAiModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {customModels.length > 0 && ( <optgroup label="Your loaded models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={settings.LocalAiModelPref === model.id} > {model.id} </option> ); })} </optgroup> )} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/CometApiLLMOptions/index.jsx
frontend/src/components/LLMSelection/CometApiLLMOptions/index.jsx
import System from "@/models/system"; import { CaretDown, CaretUp } from "@phosphor-icons/react"; import { useState, useEffect } from "react"; export default function CometApiLLMOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-start gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> CometAPI API Key </label> <input type="password" name="CometApiLLMApiKey" className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="CometAPI API Key" defaultValue={settings?.CometApiLLMApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> {!settings?.credentialsOnly && ( <CometApiModelSelection settings={settings} /> )} </div> <AdvancedControls settings={settings} /> </div> ); } function AdvancedControls({ settings }) { const [showAdvancedControls, setShowAdvancedControls] = useState(false); return ( <div className="flex flex-col gap-y-4"> <div className="flex justify-start"> <button type="button" onClick={() => setShowAdvancedControls(!showAdvancedControls)} className="border-none text-theme-text-primary hover:text-theme-text-secondary flex items-center text-sm" > {showAdvancedControls ? "Hide" : "Show"} advanced settings {showAdvancedControls ? ( <CaretUp size={14} className="ml-1" /> ) : ( <CaretDown size={14} className="ml-1" /> )} </button> </div> <div hidden={!showAdvancedControls}> <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Stream Timeout (ms) </label> <input type="number" name="CometApiLLMTimeout" className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Timeout value between token responses to auto-timeout the stream" defaultValue={settings?.CometApiLLMTimeout ?? 3_000} autoComplete="off" onScroll={(e) => e.target.blur()} min={500} step={1} /> <p className="text-xs leading-[18px] font-base text-theme-text-primary text-opacity-60 mt-2"> Timeout value between token responses to auto-timeout the stream. </p> </div> </div> </div> ); } function CometApiModelSelection({ settings }) { // TODO: For now, CometAPI models list is noisy; show a flat, deduped list without grouping. // Revisit after CometAPI model list API provides better categorization/metadata. const [models, setModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models: fetched = [] } = await System.customModels("cometapi"); if (fetched?.length > 0) { // De-duplicate by id (case-insensitive) and sort by name for readability const seen = new Set(); const unique = []; for (const m of fetched) { const key = String(m.id || m.name || "").toLowerCase(); if (!seen.has(key)) { seen.add(key); unique.push(m); } } unique.sort((a, b) => String(a.name || a.id).localeCompare(String(b.name || b.id)) ); setModels(unique); } else { setModels([]); } setLoading(false); } findCustomModels(); }, []); if (loading || models.length === 0) { return ( <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Chat Model Selection </label> <input type="text" name="CometApiLLMModelPref" className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg block w-full p-2.5" placeholder="-- loading available models --" disabled /> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Chat Model Selection </label> <input type="text" name="CometApiLLMModelPref" list="cometapi-models-list" required className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg block w-full p-2.5" placeholder="Type or select a model" defaultValue={settings?.CometApiLLMModelPref || ""} autoComplete="off" spellCheck={false} /> <datalist id="cometapi-models-list"> {models.map((model) => ( <option key={model.id} value={model.id}> {model.name} </option> ))} </datalist> <p className="text-xs leading-[18px] font-base text-theme-text-primary text-opacity-60 mt-2"> You can type the model id directly or pick from suggestions. </p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/LiteLLMOptions/index.jsx
frontend/src/components/LLMSelection/LiteLLMOptions/index.jsx
import { useEffect, useState } from "react"; import System from "@/models/system"; export default function LiteLLMOptions({ settings }) { const [basePathValue, setBasePathValue] = useState(settings?.LiteLLMBasePath); const [basePath, setBasePath] = useState(settings?.LiteLLMBasePath); const [apiKeyValue, setApiKeyValue] = useState(settings?.LiteLLMAPIKey); const [apiKey, setApiKey] = useState(settings?.LiteLLMAPIKey); return ( <div className="w-full flex flex-col gap-y-7 mt-1.5"> <div className="w-full flex items-center gap-[36px]"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Base URL </label> <input type="url" name="LiteLLMBasePath" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://127.0.0.1:4000" defaultValue={settings?.LiteLLMBasePath} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setBasePathValue(e.target.value)} onBlur={() => setBasePath(basePathValue)} /> </div> <LiteLLMModelSelection settings={settings} basePath={basePath} apiKey={apiKey} /> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Token context window </label> <input type="number" name="LiteLLMTokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="4096" min={1} onScroll={(e) => e.target.blur()} defaultValue={settings?.LiteLLMTokenLimit} required={true} autoComplete="off" /> </div> </div> <div className="w-full flex items-center gap-[36px]"> <div className="flex flex-col w-60"> <div className="flex flex-col gap-y-1 mb-4"> <label className="text-white text-sm font-semibold flex items-center gap-x-2"> API Key <p className="!text-xs !italic !font-thin">optional</p> </label> </div> <input type="password" name="LiteLLMAPIKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="sk-mysecretkey" defaultValue={settings?.LiteLLMAPIKey ? "*".repeat(20) : ""} autoComplete="off" spellCheck={false} onChange={(e) => setApiKeyValue(e.target.value)} onBlur={() => setApiKey(apiKeyValue)} /> </div> </div> </div> ); } function LiteLLMModelSelection({ settings, basePath = null, apiKey = null }) { const [customModels, setCustomModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!basePath) { setCustomModels([]); setLoading(false); return; } setLoading(true); const { models } = await System.customModels( "litellm", typeof apiKey === "boolean" ? null : apiKey, basePath ); setCustomModels(models || []); setLoading(false); } findCustomModels(); }, [basePath, apiKey]); if (loading || customModels.length == 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="LiteLLMModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> {basePath?.includes("/v1") ? "-- loading available models --" : "-- waiting for URL --"} </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="LiteLLMModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {customModels.length > 0 && ( <optgroup label="Your loaded models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={settings.LiteLLMModelPref === model.id} > {model.id} </option> ); })} </optgroup> )} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/LLMItem/index.jsx
frontend/src/components/LLMSelection/LLMItem/index.jsx
export default function LLMItem({ name, value, image, description, checked, onClick, }) { return ( <div onClick={() => onClick(value)} className={`w-full p-2 rounded-md hover:cursor-pointer hover:bg-theme-bg-secondary ${ checked ? "bg-theme-bg-secondary" : "" }`} > <input type="checkbox" value={value} className="peer hidden" checked={checked} readOnly={true} formNoValidate={true} /> <div className="flex gap-x-4 items-center"> <img src={image} alt={`${name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col"> <div className="text-sm font-semibold text-white">{name}</div> <div className="mt-1 text-xs text-description">{description}</div> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/GenericOpenAiOptions/index.jsx
frontend/src/components/LLMSelection/GenericOpenAiOptions/index.jsx
export default function GenericOpenAiOptions({ settings }) { return ( <div className="flex flex-col gap-y-7"> <div className="flex gap-[36px] mt-1.5 flex-wrap"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Base URL </label> <input type="url" name="GenericOpenAiBasePath" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="eg: https://proxy.openai.com" defaultValue={settings?.GenericOpenAiBasePath} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="GenericOpenAiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Generic service API Key" defaultValue={settings?.GenericOpenAiKey ? "*".repeat(20) : ""} required={false} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Name </label> <input type="text" name="GenericOpenAiModelPref" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Model id used for chat requests" defaultValue={settings?.GenericOpenAiModelPref} required={true} autoComplete="off" /> </div> </div> <div className="flex gap-[36px] flex-wrap"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Token context window </label> <input type="number" name="GenericOpenAiTokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Content window limit (eg: 4096)" min={1} onScroll={(e) => e.target.blur()} defaultValue={settings?.GenericOpenAiTokenLimit} required={true} autoComplete="off" /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Max Tokens </label> <input type="number" name="GenericOpenAiMaxTokens" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Max tokens per request (eg: 1024)" min={1} defaultValue={settings?.GenericOpenAiMaxTokens || 1024} required={true} autoComplete="off" /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/FoundryOptions/index.jsx
frontend/src/components/LLMSelection/FoundryOptions/index.jsx
import { useEffect, useState } from "react"; import System from "@/models/system"; export default function FoundryOptions({ settings }) { const [models, setModels] = useState([]); const [loading, setLoading] = useState(!!settings?.FoundryBasePath); const [basePath, setBasePath] = useState(settings?.FoundryBasePath); const [model, setModel] = useState(settings?.FoundryModelPref || ""); useEffect(() => { setModel(settings?.FoundryModelPref || ""); }, [settings?.FoundryModelPref]); useEffect(() => { async function fetchModels() { try { setLoading(true); if (!basePath) throw new Error("Base path is required"); const { models, error } = await System.customModels( "foundry", null, basePath ); if (error) throw new Error(error); setModels(models); } catch (error) { console.error("Error fetching Foundry models:", error); setModels([]); } finally { setLoading(false); } } fetchModels(); }, [basePath]); return ( <div className="flex flex-col gap-y-7"> <div className="flex gap-[36px] mt-1.5 flex-wrap"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Base URL </label> <input type="url" name="FoundryBasePath" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="eg: http://127.0.0.1:8080" defaultValue={settings?.FoundryBasePath} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setBasePath(e.target.value)} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model </label> {loading ? ( <select name="FoundryModelPref" required={true} disabled={true} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" > <option>---- Loading ----</option> </select> ) : ( <select name="FoundryModelPref" value={model} onChange={(e) => setModel(e.target.value)} required={true} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" > {models.length > 0 ? ( <> <option value="">-- Select a model --</option> {models.map((model) => ( <option key={model.id} value={model.id}> {model.id} </option> ))} </> ) : ( <option disabled value=""> No models found </option> )} </select> )} </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Token Context Window </label> <input type="number" name="FoundryModelTokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="4096" defaultValue={settings?.FoundryModelTokenLimit} autoComplete="off" min={0} /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/TextGenWebUIOptions/index.jsx
frontend/src/components/LLMSelection/TextGenWebUIOptions/index.jsx
export default function TextGenWebUIOptions({ settings }) { return ( <div className="flex gap-[36px] mt-1.5 flex-wrap"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Base URL </label> <input type="url" name="TextGenWebUIBasePath" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://127.0.0.1:5000/v1" defaultValue={settings?.TextGenWebUIBasePath} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Token context window </label> <input type="number" name="TextGenWebUITokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Content window limit (eg: 4096)" min={1} onScroll={(e) => e.target.blur()} defaultValue={settings?.TextGenWebUITokenLimit} required={true} autoComplete="off" /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key (Optional) </label> <input type="password" name="TextGenWebUIAPIKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="TextGen Web UI API Key" defaultValue={settings?.TextGenWebUIAPIKey ? "*".repeat(20) : ""} autoComplete="off" spellCheck={false} /> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/DPAISOptions/index.jsx
frontend/src/components/LLMSelection/DPAISOptions/index.jsx
import React, { useEffect, useState } from "react"; import { CaretDown, CaretUp } from "@phosphor-icons/react"; import System from "@/models/system"; import PreLoader from "@/components/Preloader"; import { DPAIS_COMMON_URLS } from "@/utils/constants"; import useProviderEndpointAutoDiscovery from "@/hooks/useProviderEndpointAutoDiscovery"; export default function DellProAIStudioOptions({ settings, showAlert = false, }) { const { autoDetecting: loading, basePath, basePathValue, showAdvancedControls, setShowAdvancedControls, handleAutoDetectClick, } = useProviderEndpointAutoDiscovery({ provider: "dpais", initialBasePath: settings?.DellProAiStudioBasePath, ENDPOINTS: DPAIS_COMMON_URLS, }); return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-center gap-[36px] mt-1.5"> {!settings?.credentialsOnly && ( <> <DellProAiStudioModelSelection settings={settings} basePath={basePath.value} /> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Token context window </label> <input type="number" name="DellProAiStudioTokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="4096" min={1} onScroll={(e) => e.target.blur()} defaultValue={settings?.DellProAiStudioTokenLimit} required={true} autoComplete="off" /> </div> </> )} </div> <div className="flex justify-start mt-4"> <button onClick={(e) => { e.preventDefault(); setShowAdvancedControls(!showAdvancedControls); }} className="border-none text-theme-text-primary hover:text-theme-text-secondary flex items-center text-sm" > {showAdvancedControls ? "Hide" : "Show"} advanced settings {showAdvancedControls ? ( <CaretUp size={14} className="ml-1" /> ) : ( <CaretDown size={14} className="ml-1" /> )} </button> </div> <div hidden={!showAdvancedControls}> <div className="w-full flex items-center gap-4"> <div className="flex flex-col w-fit"> <div className="flex justify-between items-center mb-2 gap-x-2"> <label className="text-white text-sm font-semibold"> Dell Pro AI Studio Base URL </label> {loading ? ( <PreLoader size="6" /> ) : ( <> {!basePathValue.value && ( <button onClick={handleAutoDetectClick} className="bg-primary-button text-xs font-medium px-2 py-1 rounded-lg hover:bg-secondary hover:text-white shadow-[0_4px_14px_rgba(0,0,0,0.25)]" > Auto-Detect </button> )} </> )} </div> <input type="url" name="DellProAiStudioBasePath" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://localhost:8553/v1/openai" value={basePathValue.value} required={true} autoComplete="off" spellCheck={false} onChange={basePath.onChange} onBlur={basePath.onBlur} /> </div> </div> </div> </div> ); } function DellProAiStudioModelSelection({ settings, basePath = null }) { const [customModels, setCustomModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!basePath) { setCustomModels([]); setLoading(false); return; } setLoading(true); const { models } = await System.customModels( "dpais", null, basePath, 2_000 ); setCustomModels(models || []); setLoading(false); } findCustomModels(); }, [basePath]); if (loading || customModels.length == 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Chat Model Selection </label> <select name="DellProAiStudioModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Chat Model Selection </label> <select name="DellProAiStudioModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {customModels.length > 0 && ( <optgroup label="Your loaded models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={settings.DellProAiStudioModelPref === model.id} > {model.id} </option> ); })} </optgroup> )} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/NovitaLLMOptions/index.jsx
frontend/src/components/LLMSelection/NovitaLLMOptions/index.jsx
import System from "@/models/system"; import { CaretDown, CaretUp } from "@phosphor-icons/react"; import { useState, useEffect } from "react"; export default function NovitaLLMOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-start gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Novita API Key </label> <input type="password" name="NovitaLLMApiKey" className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Novita API Key" defaultValue={settings?.NovitaLLMApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> {!settings?.credentialsOnly && ( <NovitaModelSelection settings={settings} /> )} </div> <AdvancedControls settings={settings} /> </div> ); } function AdvancedControls({ settings }) { const [showAdvancedControls, setShowAdvancedControls] = useState(false); return ( <div className="flex flex-col gap-y-4"> <div className="flex justify-start"> <button type="button" onClick={() => setShowAdvancedControls(!showAdvancedControls)} className="border-none text-theme-text-primary hover:text-theme-text-secondary flex items-center text-sm" > {showAdvancedControls ? "Hide" : "Show"} advanced settings {showAdvancedControls ? ( <CaretUp size={14} className="ml-1" /> ) : ( <CaretDown size={14} className="ml-1" /> )} </button> </div> <div hidden={!showAdvancedControls}> <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Stream Timeout (ms) </label> <input type="number" name="NovitaLLMTimeout" className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Timeout value between token responses to auto-timeout the stream" defaultValue={settings?.NovitaLLMTimeout ?? 3_000} autoComplete="off" onScroll={(e) => e.target.blur()} min={500} step={1} /> <p className="text-xs leading-[18px] font-base text-theme-text-primary text-opacity-60 mt-2"> Timeout value between token responses to auto-timeout the stream. </p> </div> </div> </div> ); } function NovitaModelSelection({ settings }) { const [groupedModels, setGroupedModels] = useState({}); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models } = await System.customModels("novita"); if (models?.length > 0) { const modelsByOrganization = models.reduce((acc, model) => { acc[model.organization] = acc[model.organization] || []; acc[model.organization].push(model); return acc; }, {}); setGroupedModels(modelsByOrganization); } setLoading(false); } findCustomModels(); }, []); if (loading || Object.keys(groupedModels).length === 0) { return ( <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="NovitaLLMModelPref" disabled={true} className="border-none bg-theme-settings-input-bg text-theme-text-primary border-theme-border text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="NovitaLLMModelPref" required={true} className="border-none bg-theme-settings-input-bg text-theme-text-primary border-theme-border text-sm rounded-lg block w-full p-2.5" > {Object.keys(groupedModels) .sort() .map((organization) => ( <optgroup key={organization} label={organization}> {groupedModels[organization].map((model) => ( <option key={model.id} value={model.id} selected={settings?.NovitaLLMModelPref === model.id} > {model.name} </option> ))} </optgroup> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/CohereAiOptions/index.jsx
frontend/src/components/LLMSelection/CohereAiOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; export default function CohereAiOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.CohereApiKey); const [cohereApiKey, setCohereApiKey] = useState(settings?.CohereApiKey); return ( <div className="w-full flex flex-col"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Cohere API Key </label> <input type="password" name="CohereApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Cohere API Key" defaultValue={settings?.CohereApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setCohereApiKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <CohereModelSelection settings={settings} apiKey={cohereApiKey} /> )} </div> </div> ); } function CohereModelSelection({ apiKey, settings }) { const [models, setModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!apiKey) { setModels([]); setLoading(true); return; } setLoading(true); const { models } = await System.customModels( "cohere", typeof apiKey === "boolean" ? null : apiKey ); setModels(models || []); setLoading(false); } findCustomModels(); }, [apiKey]); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="CohereModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="CohereModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {models.map((model) => ( <option key={model.id} value={model.id} selected={settings?.CohereModelPref === model.id} > {model.name} </option> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/LLMProviderOption/index.jsx
frontend/src/components/LLMSelection/LLMProviderOption/index.jsx
export default function LLMProviderOption({ name, link, description, value, image, checked = false, onClick, }) { return ( <div onClick={() => onClick(value)}> <input type="checkbox" value={value} className="peer hidden" checked={checked} readOnly={true} formNoValidate={true} /> <label className="transition-all duration-300 inline-flex flex-col h-full w-60 cursor-pointer items-start justify-between rounded-2xl bg-preference-gradient border-2 border-transparent shadow-md px-5 py-4 text-white hover:bg-selected-preference-gradient hover:border-white/60 peer-checked:border-white peer-checked:border-opacity-90 peer-checked:bg-selected-preference-gradient"> <div className="flex items-center"> <img src={image} alt={name} className="h-10 w-10 rounded" /> <div className="ml-4 text-sm font-semibold">{name}</div> </div> <div className="mt-2 text-xs font-base text-white tracking-wide"> {description} </div> <a href={`https://${link}`} className="mt-2 text-xs text-white font-medium underline" > {link} </a> </label> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/MoonshotAiOptions/index.jsx
frontend/src/components/LLMSelection/MoonshotAiOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; export default function MoonshotAiOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.MoonshotAiApiKey); const [moonshotAiKey, setMoonshotAiKey] = useState( settings?.MoonshotAiApiKey ); return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="MoonshotAiApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Moonshot AI API Key" defaultValue={settings?.MoonshotAiApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setMoonshotAiKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <MoonshotAiModelSelection settings={settings} apiKey={moonshotAiKey} /> )} </div> ); } function MoonshotAiModelSelection({ apiKey, settings }) { const [models, setModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models: availableModels } = await System.customModels( "moonshotai", typeof apiKey === "boolean" ? null : apiKey ); if (availableModels?.length > 0) { setModels(availableModels); } setLoading(false); } findCustomModels(); }, [apiKey]); if (!apiKey) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="MoonshotAiModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- Enter API key -- </option> </select> </div> ); } if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="MoonshotAiModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="MoonshotAiModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {models.map((model) => ( <option key={model.id} value={model.id} selected={settings?.MoonshotAiModelPref === model.id} > {model.id} </option> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/XAiLLMOptions/index.jsx
frontend/src/components/LLMSelection/XAiLLMOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; export default function XAILLMOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.XAIApiKey); const [apiKey, setApiKey] = useState(settings?.XAIApiKey); return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> xAI API Key </label> <input type="password" name="XAIApiKey" className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="xAI API Key" defaultValue={settings?.XAIApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setApiKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <XAIModelSelection settings={settings} apiKey={apiKey} /> )} </div> ); } function XAIModelSelection({ apiKey, settings }) { const [customModels, setCustomModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!apiKey) { setCustomModels([]); setLoading(true); return; } try { setLoading(true); const { models } = await System.customModels("xai", apiKey); setCustomModels(models || []); } catch (error) { console.error("Failed to fetch custom models:", error); setCustomModels([]); } finally { setLoading(false); } } findCustomModels(); }, [apiKey]); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="XAIModelPref" disabled={true} className="border-none bg-theme-settings-input-bg text-theme-text-primary border-theme-border text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> --loading available models-- </option> </select> <p className="text-xs leading-[18px] font-base text-theme-text-primary opacity-60 mt-2"> Enter a valid API key to view all available models for your account. </p> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="XAIModelPref" required={true} className="border-none bg-theme-settings-input-bg text-theme-text-primary border-theme-border text-sm rounded-lg block w-full p-2.5" > {customModels.length > 0 && ( <optgroup label="Available models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={settings?.XAIModelPref === model.id} > {model.id} </option> ); })} </optgroup> )} </select> <p className="text-xs leading-[18px] font-base text-theme-text-primary opacity-60 mt-2"> Select the xAI model you want to use for your conversations. </p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/OpenAiOptions/index.jsx
frontend/src/components/LLMSelection/OpenAiOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; export default function OpenAiOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.OpenAiKey); const [openAIKey, setOpenAIKey] = useState(settings?.OpenAiKey); return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="OpenAiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="OpenAI API Key" defaultValue={settings?.OpenAiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setOpenAIKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <OpenAIModelSelection settings={settings} apiKey={openAIKey} /> )} </div> ); } function OpenAIModelSelection({ apiKey, settings }) { const [groupedModels, setGroupedModels] = useState({}); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models } = await System.customModels( "openai", typeof apiKey === "boolean" ? null : apiKey ); if (models?.length > 0) { const modelsByOrganization = models.reduce((acc, model) => { acc[model.organization] = acc[model.organization] || []; acc[model.organization].push(model); return acc; }, {}); setGroupedModels(modelsByOrganization); } setLoading(false); } findCustomModels(); }, [apiKey]); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="OpenAiModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="OpenAiModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {Object.keys(groupedModels) .sort() .map((organization) => ( <optgroup key={organization} label={organization}> {groupedModels[organization].map((model) => ( <option key={model.id} value={model.id} selected={settings?.OpenAiModelPref === model.id} > {model.name} </option> ))} </optgroup> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/OllamaLLMOptions/index.jsx
frontend/src/components/LLMSelection/OllamaLLMOptions/index.jsx
import React, { useEffect, useState } from "react"; import System from "@/models/system"; import PreLoader from "@/components/Preloader"; import { OLLAMA_COMMON_URLS } from "@/utils/constants"; import { CaretDown, CaretUp, Info } from "@phosphor-icons/react"; import useProviderEndpointAutoDiscovery from "@/hooks/useProviderEndpointAutoDiscovery"; import { Tooltip } from "react-tooltip"; 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 [performanceMode, setPerformanceMode] = useState( settings?.OllamaLLMPerformanceMode || "base" ); const [maxTokens, setMaxTokens] = useState( settings?.OllamaLLMTokenLimit || "" ); return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-start gap-[36px] mt-1.5"> <OllamaLLMModelSelection settings={settings} basePath={basePath.value} authToken={authToken.value} /> </div> <div className="flex justify-start mt-4"> <button onClick={(e) => { e.preventDefault(); setShowAdvancedControls(!showAdvancedControls); }} className="border-none text-theme-text-primary hover:text-theme-text-secondary flex items-center text-sm" > {showAdvancedControls ? "Hide" : "Show"} advanced settings {showAdvancedControls ? ( <CaretUp size={14} className="ml-1" /> ) : ( <CaretDown size={14} className="ml-1" /> )} </button> </div> <div hidden={!showAdvancedControls}> <div className="flex flex-col"> <div className="w-full flex items-start gap-4"> <div className="flex flex-col w-60"> <div className="flex justify-between items-center mb-2"> <label className="text-white text-sm font-semibold"> Ollama Base URL </label> {loading ? ( <PreLoader size="6" /> ) : ( <> {!basePathValue.value && ( <button onClick={handleAutoDetectClick} className="bg-primary-button text-xs font-medium px-2 py-1 rounded-lg hover:bg-secondary hover:text-white shadow-[0_4px_14px_rgba(0,0,0,0.25)]" > Auto-Detect </button> )} </> )} </div> <input type="url" name="OllamaLLMBasePath" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://127.0.0.1:11434" value={basePathValue.value} required={true} autoComplete="off" spellCheck={false} onChange={basePath.onChange} onBlur={basePath.onBlur} /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Enter the URL where Ollama is running. </p> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold mb-2 flex items-center"> Performance Mode <Info size={16} className="ml-2 text-white" data-tooltip-id="performance-mode-tooltip" /> </label> <select name="OllamaLLMPerformanceMode" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" value={performanceMode} onChange={(e) => setPerformanceMode(e.target.value)} > <option value="base">Base (Default)</option> <option value="maximum">Maximum</option> </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Choose the performance mode for the Ollama model. </p> <Tooltip id="performance-mode-tooltip" place="bottom" className="tooltip !text-xs max-w-xs" > <p className="text-red-500"> <strong>Note:</strong> Be careful with the Maximum mode. It may increase resource usage significantly. </p> <br /> <p> <strong>Base:</strong> Ollama automatically limits the context to 2048 tokens, keeping resources usage low while maintaining good performance. Suitable for most users and models. </p> <br /> <p> <strong>Maximum:</strong> Uses the full context window (up to Max Tokens). Will result in increased resource usage but allows for larger context conversations. <br /> <br /> This is not recommended for most users. </p> </Tooltip> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Ollama Keep Alive </label> <select name="OllamaLLMKeepAliveSeconds" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" defaultValue={settings?.OllamaLLMKeepAliveSeconds ?? "300"} > <option value="0">No cache</option> <option value="300">5 minutes</option> <option value="3600">1 hour</option> <option value="-1">Forever</option> </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Choose how long Ollama should keep your model in memory before unloading. <a className="underline text-blue-300" href="https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-keep-a-model-loaded-in-memory-or-make-it-unload-immediately" target="_blank" rel="noreferrer" > {" "} Learn more &rarr; </a> </p> </div> </div> <div className="w-full flex items-start gap-4"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Max Tokens (Optional) </label> <input type="number" name="OllamaLLMTokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Auto-detected from model" min={1} value={maxTokens} onChange={(e) => setMaxTokens(e.target.value ? Number(e.target.value) : "") } onScroll={(e) => e.target.blur()} required={false} autoComplete="off" /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Override the context window limit. Leave empty to auto-detect from the model (defaults to 4096 if detection fails). </p> </div> </div> <div className="w-full flex items-start gap-4 mt-4"> <div className="flex flex-col w-100"> <label className="text-white text-sm font-semibold"> Auth Token </label> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Enter a <code>Bearer</code> Auth Token for interacting with your Ollama server. <br /> Used <b>only</b> if running Ollama behind an authentication server. </p> <input type="password" name="OllamaLLMAuthToken" className="border-none bg-theme-settings-input-bg mt-2 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg outline-none block w-full p-2.5 focus:outline-primary-button active:outline-primary-button" placeholder="Ollama Auth Token" defaultValue={ settings?.OllamaLLMAuthToken ? "*".repeat(20) : "" } value={authTokenValue.value} onChange={authToken.onChange} onBlur={authToken.onBlur} required={false} autoComplete="off" spellCheck={false} /> </div> </div> </div> </div> </div> ); } 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 ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Ollama Model </label> <select name="OllamaLLMModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> {!!basePath ? "--loading available models--" : "Enter Ollama URL first"} </option> </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Select the Ollama model you want to use. Models will load after entering a valid Ollama URL. </p> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Ollama Model </label> <select name="OllamaLLMModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {customModels.length > 0 && ( <optgroup label="Your loaded models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={settings.OllamaLLMModelPref === model.id} > {model.id} </option> ); })} </optgroup> )} </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Choose the Ollama model you want to use for your conversations. </p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/MistralOptions/index.jsx
frontend/src/components/LLMSelection/MistralOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; export default function MistralOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.MistralApiKey); const [mistralKey, setMistralKey] = useState(settings?.MistralApiKey); return ( <div className="flex gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Mistral API Key </label> <input type="password" name="MistralApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Mistral API Key" defaultValue={settings?.MistralApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setMistralKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <MistralModelSelection settings={settings} apiKey={mistralKey} /> )} </div> ); } function MistralModelSelection({ apiKey, settings }) { const [customModels, setCustomModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!apiKey) { setCustomModels([]); setLoading(false); return; } setLoading(true); const { models } = await System.customModels( "mistral", typeof apiKey === "boolean" ? null : apiKey ); setCustomModels(models || []); setLoading(false); } findCustomModels(); }, [apiKey]); if (loading || customModels.length == 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="MistralModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> {!!apiKey ? "-- loading available models --" : "-- waiting for API key --"} </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="MistralModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {customModels.length > 0 && ( <optgroup label="Available Mistral Models"> {customModels.map((model) => { return ( <option key={model.id} value={model.id} selected={settings?.MistralModelPref === model.id} > {model.id} </option> ); })} </optgroup> )} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/LLMSelection/KoboldCPPOptions/index.jsx
frontend/src/components/LLMSelection/KoboldCPPOptions/index.jsx
import { useEffect, useState } from "react"; import System from "@/models/system"; import PreLoader from "@/components/Preloader"; import { KOBOLDCPP_COMMON_URLS } from "@/utils/constants"; import { CaretDown, CaretUp } from "@phosphor-icons/react"; import useProviderEndpointAutoDiscovery from "@/hooks/useProviderEndpointAutoDiscovery"; export default function KoboldCPPOptions({ settings }) { const { autoDetecting: loading, basePath, basePathValue, showAdvancedControls, setShowAdvancedControls, handleAutoDetectClick, } = useProviderEndpointAutoDiscovery({ provider: "koboldcpp", initialBasePath: settings?.KoboldCPPBasePath, ENDPOINTS: KOBOLDCPP_COMMON_URLS, }); const [tokenLimit, setTokenLimit] = useState( settings?.KoboldCPPTokenLimit || 4096 ); const [maxTokens, setMaxTokens] = useState( settings?.KoboldCPPMaxTokens || 2048 ); const handleTokenLimitChange = (e) => { setTokenLimit(Number(e.target.value)); }; const handleMaxTokensChange = (e) => { setMaxTokens(Number(e.target.value)); }; return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-start gap-[36px] mt-1.5"> <KoboldCPPModelSelection settings={settings} basePath={basePath.value} /> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Token context window </label> <input type="number" name="KoboldCPPTokenLimit" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="4096" min={1} value={tokenLimit} onChange={handleTokenLimitChange} onScroll={(e) => e.target.blur()} required={true} autoComplete="off" /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Maximum number of tokens for context and response. </p> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> Max response tokens </label> <input type="number" name="KoboldCPPMaxTokens" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="2048" min={1} value={maxTokens} onChange={handleMaxTokensChange} onScroll={(e) => e.target.blur()} required={true} autoComplete="off" /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Maximum number of tokens for the response. </p> </div> </div> <div className="flex justify-start mt-4"> <button onClick={(e) => { e.preventDefault(); setShowAdvancedControls(!showAdvancedControls); }} className="border-none text-theme-text-primary hover:text-theme-text-secondary flex items-center text-sm" > {showAdvancedControls ? "Hide" : "Show"} Manual Endpoint Input {showAdvancedControls ? ( <CaretUp size={14} className="ml-1" /> ) : ( <CaretDown size={14} className="ml-1" /> )} </button> </div> <div hidden={!showAdvancedControls}> <div className="w-full flex items-start gap-4"> <div className="flex flex-col w-60"> <div className="flex justify-between items-center mb-2"> <label className="text-white text-sm font-semibold"> KoboldCPP Base URL </label> {loading ? ( <PreLoader size="6" /> ) : ( <> {!basePathValue.value && ( <button onClick={handleAutoDetectClick} className="border-none bg-primary-button text-xs font-medium px-2 py-1 rounded-lg hover:bg-secondary hover:text-white shadow-[0_4px_14px_rgba(0,0,0,0.25)]" > Auto-Detect </button> )} </> )} </div> <input type="url" name="KoboldCPPBasePath" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://127.0.0.1:5000/v1" value={basePathValue.value} required={true} autoComplete="off" spellCheck={false} onChange={basePath.onChange} onBlur={basePath.onBlur} /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Enter the URL where KoboldCPP is running. </p> </div> </div> </div> </div> ); } function KoboldCPPModelSelection({ settings, basePath = null }) { const [customModels, setCustomModels] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { if (!basePath || !basePath.includes("/v1")) { setCustomModels([]); setLoading(false); return; } setLoading(true); try { const { models } = await System.customModels( "koboldcpp", null, basePath ); setCustomModels(models || []); } catch (error) { console.error("Failed to fetch custom models:", error); setCustomModels([]); } setLoading(false); } findCustomModels(); }, [basePath]); if (loading || customModels.length === 0) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> KoboldCPP Model </label> <select name="KoboldCPPModelPref" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> {basePath?.includes("/v1") ? "--loading available models--" : "Enter KoboldCPP URL first"} </option> </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Select the KoboldCPP model you want to use. Models will load after entering a valid KoboldCPP URL. </p> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> KoboldCPP Model </label> <select name="KoboldCPPModelPref" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {customModels.map((model) => ( <option key={model.id} value={model.id} selected={settings.KoboldCPPModelPref === model.id} > {model.id} </option> ))} </select> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Choose the KoboldCPP model you want to use for your conversations. </p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/ModalWrapper/index.jsx
frontend/src/components/ModalWrapper/index.jsx
import { createPortal } from "react-dom"; /** * @typedef {Object} ModalWrapperProps * @property {import("react").ReactComponentElement} children - The DOM/JSX to render * @property {boolean} isOpen - Option that renders the modal * @property {boolean} noPortal - (default: false) Used for creating sub-DOM modals that need to be rendered as a child element instead of a modal placed at the root * Note: This can impact the bg-overlay presentation due to conflicting DOM positions so if using this property you should double check it renders as desired. */ /** * * @param {ModalWrapperProps} props - ModalWrapperProps to pass * @returns {import("react").ReactNode} * * @todo Add a closeModal prop to the ModalWrapper component so we can escape dismiss anywhere this is used */ export default function ModalWrapper({ children, isOpen, noPortal = false }) { if (!isOpen) return null; if (noPortal) { return ( <div className="bg-black/60 backdrop-blur-sm fixed top-0 left-0 outline-none w-screen h-screen flex items-center justify-center z-99"> {children} </div> ); } return createPortal( <div className="bg-black/60 backdrop-blur-sm fixed top-0 left-0 outline-none w-screen h-screen flex items-center justify-center z-99"> {children} </div>, document.getElementById("root") ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/TranscriptionSelection/NativeTranscriptionOptions/index.jsx
frontend/src/components/TranscriptionSelection/NativeTranscriptionOptions/index.jsx
import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Gauge } from "@phosphor-icons/react"; export default function NativeTranscriptionOptions({ settings }) { const { t } = useTranslation(); const [model, setModel] = useState(settings?.WhisperModelPref); return ( <div className="w-full flex flex-col gap-y-4"> <LocalWarning model={model} /> <div className="w-full flex items-center gap-4"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> {t("common.selection")} </label> <select name="WhisperModelPref" defaultValue={model} onChange={(e) => setModel(e.target.value)} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {["Xenova/whisper-small", "Xenova/whisper-large"].map( (value, i) => { return ( <option key={i} value={value}> {value} </option> ); } )} </select> </div> </div> </div> ); } function LocalWarning({ model }) { switch (model) { case "Xenova/whisper-small": return <WhisperSmall />; case "Xenova/whisper-large": return <WhisperLarge />; default: return <WhisperSmall />; } } function WhisperSmall() { const { t } = useTranslation(); return ( <div className="flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-4 bg-blue-800/30 w-fit rounded-lg px-4 py-2"> <div className="gap-x-2 flex items-center"> <Gauge size={25} /> <p className="text-sm"> {t("transcription.warn-start")} <br /> {t("transcription.warn-recommend")} <br /> <br /> <i>{t("transcription.warn-end")} (250mb)</i> </p> </div> </div> ); } function WhisperLarge() { const { t } = useTranslation(); return ( <div className="flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-4 bg-blue-800/30 w-fit rounded-lg px-4 py-2"> <div className="gap-x-2 flex items-center"> <Gauge size={25} /> <p className="text-sm"> {t("transcription.warn-start")} <br /> {t("transcription.warn-recommend")} <br /> <br /> <i>{t("transcription.warn-end")} (1.56GB)</i> </p> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/TranscriptionSelection/OpenAiOptions/index.jsx
frontend/src/components/TranscriptionSelection/OpenAiOptions/index.jsx
import { useState } from "react"; export default function OpenAiWhisperOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.OpenAiKey); const [_openAIKey, setOpenAIKey] = useState(settings?.OpenAiKey); return ( <div className="flex gap-x-7 gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="OpenAiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="OpenAI API Key" defaultValue={settings?.OpenAiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setOpenAIKey(inputValue)} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Whisper Model </label> <select disabled={true} className="border-none flex-shrink-0 bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> Whisper Large </option> </select> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/CanViewChatHistory/index.jsx
frontend/src/components/CanViewChatHistory/index.jsx
import { useEffect, useState } from "react"; import { FullScreenLoader } from "@/components/Preloader"; import System from "@/models/system"; import paths from "@/utils/paths"; /** * Protects the view from system set ups who cannot view chat history. * If the user cannot view chat history, they are redirected to the home page. * @param {React.ReactNode} children */ export function CanViewChatHistory({ children }) { const { loading, viewable } = useCanViewChatHistory(); if (loading) return <FullScreenLoader />; if (!viewable) { window.location.href = paths.home(); return <FullScreenLoader />; } return <>{children}</>; } /** * Provides the `viewable` state to the children. * @returns {React.ReactNode} */ export function CanViewChatHistoryProvider({ children }) { const { loading, viewable } = useCanViewChatHistory(); if (loading) return null; return <>{children({ viewable })}</>; } /** * Hook that fetches the can view chat history state from local storage or the system settings. * @returns {Promise<{viewable: boolean, error: string | null}>} */ export function useCanViewChatHistory() { const [loading, setLoading] = useState(true); const [viewable, setViewable] = useState(false); useEffect(() => { async function fetchViewable() { const { viewable } = await System.fetchCanViewChatHistory(); setViewable(viewable); setLoading(false); } fetchViewable(); }, []); return { loading, viewable }; }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/LanceDBOptions/index.jsx
frontend/src/components/VectorDBSelection/LanceDBOptions/index.jsx
import { useTranslation } from "react-i18next"; export default function LanceDBOptions() { const { t } = useTranslation(); return ( <div className="w-full h-10 items-center flex"> <p className="text-sm font-base text-white text-opacity-60"> {t("vector.provider.description")} </p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/PineconeDBOptions/index.jsx
frontend/src/components/VectorDBSelection/PineconeDBOptions/index.jsx
export default function PineconeDBOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Pinecone DB API Key </label> <input type="password" name="PineConeKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Pinecone API Key" defaultValue={settings?.PineConeKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Pinecone Index Name </label> <input type="text" name="PineConeIndex" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="my-index" defaultValue={settings?.PineConeIndex} required={true} autoComplete="off" spellCheck={false} /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/ZillizCloudOptions/index.jsx
frontend/src/components/VectorDBSelection/ZillizCloudOptions/index.jsx
export default function ZillizCloudOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-4"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Cluster Endpoint </label> <input type="text" name="ZillizEndpoint" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="https://sample.api.gcp-us-west1.zillizcloud.com" defaultValue={settings?.ZillizEndpoint} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Token </label> <input type="password" name="ZillizApiToken" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Zilliz cluster API Token" defaultValue={settings?.ZillizApiToken ? "*".repeat(20) : ""} autoComplete="off" spellCheck={false} /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/VectorDBItem/index.jsx
frontend/src/components/VectorDBSelection/VectorDBItem/index.jsx
export default function VectorDBItem({ name, value, image, description, checked, onClick, }) { return ( <div onClick={() => onClick(value)} className={`w-full p-2 rounded-md hover:cursor-pointer hover:bg-theme-bg-secondary ${ checked ? "bg-theme-bg-secondary" : "" }`} > <input type="checkbox" value={value} className="peer hidden" checked={checked} readOnly={true} formNoValidate={true} /> <div className="flex gap-x-4 items-center"> <img src={image} alt={`${name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col"> <div className="text-sm font-semibold text-white">{name}</div> <div className="mt-1 text-xs text-description">{description}</div> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/ChromaDBOptions/index.jsx
frontend/src/components/VectorDBSelection/ChromaDBOptions/index.jsx
export default function ChromaDBOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chroma Endpoint </label> <input type="url" name="ChromaEndpoint" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://localhost:8000" defaultValue={settings?.ChromaEndpoint} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Header </label> <input name="ChromaApiHeader" autoComplete="off" type="text" defaultValue={settings?.ChromaApiHeader} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="X-Api-Key" /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input name="ChromaApiKey" autoComplete="off" type="password" defaultValue={settings?.ChromaApiKey ? "*".repeat(20) : ""} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="sk-myApiKeyToAccessMyChromaInstance" /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/WeaviateDBOptions/index.jsx
frontend/src/components/VectorDBSelection/WeaviateDBOptions/index.jsx
export default function WeaviateDBOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Weaviate Endpoint </label> <input type="url" name="WeaviateEndpoint" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://localhost:8080" defaultValue={settings?.WeaviateEndpoint} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="WeaviateApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="sk-123Abcweaviate" defaultValue={settings?.WeaviateApiKey} autoComplete="off" spellCheck={false} /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/ChromaCloudOptions/index.jsx
frontend/src/components/VectorDBSelection/ChromaCloudOptions/index.jsx
export default function ChromaCloudOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="ChromaCloudApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="ck-your-api-key-here" defaultValue={settings?.ChromaCloudApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Tenant ID </label> <input name="ChromaCloudTenant" autoComplete="off" type="text" defaultValue={settings?.ChromaCloudTenant} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="your-tenant-id-here" required={true} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Database Name </label> <input name="ChromaCloudDatabase" autoComplete="off" type="text" defaultValue={settings?.ChromaCloudDatabase} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="your-database-name" required={true} /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/AstraDBOptions/index.jsx
frontend/src/components/VectorDBSelection/AstraDBOptions/index.jsx
export default function AstraDBOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Astra DB Endpoint </label> <input type="url" name="AstraDBEndpoint" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Astra DB API endpoint" defaultValue={settings?.AstraDBEndpoint} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Astra DB Application Token </label> <input type="password" name="AstraDBApplicationToken" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="AstraCS:..." defaultValue={ settings?.AstraDBApplicationToken ? "*".repeat(20) : "" } required={true} autoComplete="off" spellCheck={false} /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/PGVectorOptions/index.jsx
frontend/src/components/VectorDBSelection/PGVectorOptions/index.jsx
import { Info } from "@phosphor-icons/react"; import { Tooltip } from "react-tooltip"; export default function PGVectorOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-96"> <div className="flex items-center gap-x-1 mb-3"> <label className="text-white text-sm font-semibold block"> Postgres Connection String </label> <Info size={16} className="text-theme-text-secondary cursor-pointer" data-tooltip-id="pgvector-connection-string-tooltip" data-tooltip-place="right" /> <Tooltip delayHide={300} id="pgvector-connection-string-tooltip" className="max-w-md z-99" clickable={true} > <p className="text-md whitespace-pre-line break-words"> This is the connection string for the Postgres database in the format of <br /> <code>postgresql://username:password@host:port/database</code> <br /> <br /> The user for the database must have the following permissions: <ul className="list-disc list-inside"> <li>Read access to the database</li> <li>Read access to the database schema</li> <li>Create access to the database</li> </ul> <br /> <b> You must have the pgvector extension installed on the database. </b> </p> </Tooltip> </div> <input type="text" name="PGVectorConnectionString" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="postgresql://username:password@host:port/database" defaultValue={ settings?.PGVectorConnectionString ? "*".repeat(20) : "" } required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <div className="flex items-center gap-x-1 mb-3"> <label className="text-white text-sm font-semibold block"> Vector Table Name </label> <Info size={16} className="text-theme-text-secondary cursor-pointer" data-tooltip-id="pgvector-table-name-tooltip" data-tooltip-place="right" /> <Tooltip delayHide={300} id="pgvector-table-name-tooltip" className="max-w-md z-99" clickable={true} > <p className="text-md whitespace-pre-line break-words"> This is the name of the table in the Postgres database that will store the vectors. <br /> <br /> By default, the table name is <code>anythingllm_vectors</code>. <br /> <br /> <b> This table must not already exist on the database - it will be created automatically. </b> </p> </Tooltip> </div> <input type="text" name="PGVectorTableName" autoComplete="off" defaultValue={settings?.PGVectorTableName} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="vector_table" /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/QDrantDBOptions/index.jsx
frontend/src/components/VectorDBSelection/QDrantDBOptions/index.jsx
export default function QDrantDBOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> QDrant API Endpoint </label> <input type="url" name="QdrantEndpoint" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://localhost:6633" defaultValue={settings?.QdrantEndpoint} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="QdrantApiKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="wOeqxsYP4....1244sba" defaultValue={settings?.QdrantApiKey} autoComplete="off" spellCheck={false} /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/VectorDBSelection/MilvusDBOptions/index.jsx
frontend/src/components/VectorDBSelection/MilvusDBOptions/index.jsx
export default function MilvusDBOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="w-full flex items-center gap-[36px] mt-1.5"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Milvus DB Address </label> <input type="text" name="MilvusAddress" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://localhost:19530" defaultValue={settings?.MilvusAddress} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Milvus Username </label> <input type="text" name="MilvusUsername" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="username" defaultValue={settings?.MilvusUsername} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Milvus Password </label> <input type="password" name="MilvusPassword" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="password" defaultValue={settings?.MilvusPassword ? "*".repeat(20) : ""} autoComplete="off" spellCheck={false} /> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/DefaultChat/index.jsx
frontend/src/components/DefaultChat/index.jsx
import React, { useEffect, useState } from "react"; import paths from "@/utils/paths"; import { isMobile } from "react-device-detect"; import useUser from "@/hooks/useUser"; import Appearance from "@/models/appearance"; import useLogo from "@/hooks/useLogo"; import Workspace from "@/models/workspace"; import { NavLink } from "react-router-dom"; import { LAST_VISITED_WORKSPACE } from "@/utils/constants"; import { useTranslation } from "react-i18next"; import { safeJsonParse } from "@/utils/request"; export default function DefaultChatContainer() { const { t } = useTranslation(); const { user } = useUser(); const { logo } = useLogo(); const [lastVisitedWorkspace, setLastVisitedWorkspace] = useState(null); const [{ workspaces, loading }, setWorkspaces] = useState({ workspaces: [], loading: true, }); useEffect(() => { async function fetchWorkspaces() { const availableWorkspaces = await Workspace.all(); const serializedLastVisitedWorkspace = localStorage.getItem( LAST_VISITED_WORKSPACE ); if (!serializedLastVisitedWorkspace) return setWorkspaces({ workspaces: availableWorkspaces, loading: false, }); try { const lastVisitedWorkspace = safeJsonParse( serializedLastVisitedWorkspace, null ); if (lastVisitedWorkspace == null) throw new Error("Non-parseable!"); const isValid = availableWorkspaces.some( (ws) => ws.slug === lastVisitedWorkspace?.slug ); if (!isValid) throw new Error("Invalid value!"); setLastVisitedWorkspace(lastVisitedWorkspace); } catch { localStorage.removeItem(LAST_VISITED_WORKSPACE); } finally { setWorkspaces({ workspaces: availableWorkspaces, loading: false }); } } fetchWorkspaces(); }, []); if (loading) { return ( <Layout> <div className="w-full h-full flex flex-col items-center justify-center overflow-y-auto no-scroll"> {/* Logo skeleton */} <div className="w-[140px] h-[140px] mb-5 rounded-lg bg-theme-bg-primary animate-pulse" /> {/* Title skeleton */} <div className="w-48 h-6 mb-4 rounded bg-theme-bg-primary animate-pulse" /> {/* Paragraph skeleton */} <div className="w-80 h-4 mb-2 rounded bg-theme-bg-primary animate-pulse" /> <div className="w-64 h-4 rounded bg-theme-bg-primary animate-pulse" /> {/* Button skeleton */} <div className="mt-[29px] w-40 h-[34px] rounded-lg bg-theme-bg-primary animate-pulse" /> </div> </Layout> ); } const hasWorkspaces = workspaces.length > 0; return ( <Layout> <div className="w-full h-full flex flex-col items-center justify-center overflow-y-auto no-scroll"> <img src={logo} alt="Custom Logo" className=" w-[200px] h-fit mb-5 rounded-lg" /> <h1 className="text-white text-2xl font-semibold"> {t("home.welcome")}, {user.username}! </h1> <p className="text-theme-home-text-secondary text-base text-center whitespace-pre-line"> {hasWorkspaces ? t("home.chooseWorkspace") : t("home.notAssigned")} </p> {hasWorkspaces && ( <NavLink to={paths.workspace.chat( lastVisitedWorkspace?.slug || workspaces[0].slug )} className="text-sm font-medium mt-[10px] w-fit px-4 h-[34px] flex items-center justify-center rounded-lg cursor-pointer bg-theme-home-button-secondary hover:bg-theme-home-button-secondary-hover text-theme-home-button-secondary-text hover:text-theme-home-button-secondary-hover-text transition-all duration-200" > {t("home.goToWorkspace", { workspace: lastVisitedWorkspace?.name || workspaces[0].name, })}{" "} &rarr; </NavLink> )} </div> </Layout> ); } const Layout = ({ children }) => { const { showScrollbar } = Appearance.getSettings(); return ( <div style={{ height: isMobile ? "100%" : "calc(100% - 32px)" }} className={`relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary light:border-[1px] light:border-theme-sidebar-border w-full h-full overflow-y-scroll ${showScrollbar ? "show-scrollbar" : "no-scroll"}`} > {children} </div> ); };
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/PrivateRoute/index.jsx
frontend/src/components/PrivateRoute/index.jsx
import { useEffect, useState } from "react"; import { Navigate } from "react-router-dom"; import { FullScreenLoader } from "../Preloader"; import validateSessionTokenForUser from "@/utils/session"; import paths from "@/utils/paths"; import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "@/utils/constants"; import { userFromStorage } from "@/utils/request"; import System from "@/models/system"; import UserMenu from "../UserMenu"; import { KeyboardShortcutWrapper } from "@/utils/keyboardShortcuts"; // Used only for Multi-user mode only as we permission specific pages based on auth role. // When in single user mode we just bypass any authchecks. function useIsAuthenticated() { const [isAuthd, setIsAuthed] = useState(null); const [shouldRedirectToOnboarding, setShouldRedirectToOnboarding] = useState(false); const [multiUserMode, setMultiUserMode] = useState(false); useEffect(() => { const validateSession = async () => { const { MultiUserMode, RequiresAuth, LLMProvider = null, VectorDB = null, } = await System.keys(); setMultiUserMode(MultiUserMode); // Check for the onboarding redirect condition if ( !MultiUserMode && !RequiresAuth && // Not in Multi-user AND no password set. !LLMProvider && !VectorDB ) { setShouldRedirectToOnboarding(true); setIsAuthed(true); return; } if (!MultiUserMode && !RequiresAuth) { setIsAuthed(true); return; } // Single User password mode check if (!MultiUserMode && RequiresAuth) { const localAuthToken = localStorage.getItem(AUTH_TOKEN); if (!localAuthToken) { setIsAuthed(false); return; } const isValid = await validateSessionTokenForUser(); setIsAuthed(isValid); return; } const localUser = localStorage.getItem(AUTH_USER); const localAuthToken = localStorage.getItem(AUTH_TOKEN); if (!localUser || !localAuthToken) { setIsAuthed(false); return; } const isValid = await validateSessionTokenForUser(); if (!isValid) { localStorage.removeItem(AUTH_USER); localStorage.removeItem(AUTH_TOKEN); localStorage.removeItem(AUTH_TIMESTAMP); setIsAuthed(false); return; } setIsAuthed(true); }; validateSession(); }, []); return { isAuthd, shouldRedirectToOnboarding, multiUserMode }; } // Allows only admin to access the route and if in single user mode, // allows all users to access the route export function AdminRoute({ Component, hideUserMenu = false }) { const { isAuthd, shouldRedirectToOnboarding, multiUserMode } = useIsAuthenticated(); if (isAuthd === null) return <FullScreenLoader />; if (shouldRedirectToOnboarding) { return <Navigate to={paths.onboarding.home()} />; } const user = userFromStorage(); return isAuthd && (user?.role === "admin" || !multiUserMode) ? ( hideUserMenu ? ( <KeyboardShortcutWrapper> <Component /> </KeyboardShortcutWrapper> ) : ( <KeyboardShortcutWrapper> <UserMenu> <Component /> </UserMenu> </KeyboardShortcutWrapper> ) ) : ( <Navigate to={paths.home()} /> ); } // Allows manager and admin to access the route and if in single user mode, // allows all users to access the route export function ManagerRoute({ Component }) { const { isAuthd, shouldRedirectToOnboarding, multiUserMode } = useIsAuthenticated(); if (isAuthd === null) return <FullScreenLoader />; if (shouldRedirectToOnboarding) { return <Navigate to={paths.onboarding.home()} />; } const user = userFromStorage(); return isAuthd && (user?.role !== "default" || !multiUserMode) ? ( <KeyboardShortcutWrapper> <UserMenu> <Component /> </UserMenu> </KeyboardShortcutWrapper> ) : ( <Navigate to={paths.home()} /> ); } export default function PrivateRoute({ Component }) { const { isAuthd, shouldRedirectToOnboarding } = useIsAuthenticated(); if (isAuthd === null) return <FullScreenLoader />; if (shouldRedirectToOnboarding) { return <Navigate to="/onboarding" />; } return isAuthd ? ( <KeyboardShortcutWrapper> <UserMenu> <Component /> </UserMenu> </KeyboardShortcutWrapper> ) : ( <Navigate to={paths.login(true)} /> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/UserIcon/index.jsx
frontend/src/components/UserIcon/index.jsx
import React, { memo } from "react"; import usePfp from "../../hooks/usePfp"; import UserDefaultPfp from "./user.svg"; import WorkspaceDefaultPfp from "./workspace.svg"; const UserIcon = memo(({ role }) => { const { pfp } = usePfp(); return ( <div className="relative w-[35px] h-[35px] rounded-full flex-shrink-0 overflow-hidden"> {role === "user" && <RenderUserPfp pfp={pfp} />} {role !== "user" && ( <img src={WorkspaceDefaultPfp} alt="system profile picture" className="flex items-center justify-center rounded-full border-solid border border-white/40 light:border-theme-sidebar-border light:bg-theme-bg-chat-input" /> )} </div> ); }); function RenderUserPfp({ pfp }) { if (!pfp) return ( <img src={UserDefaultPfp} alt="User profile picture" className="rounded-full border-none" /> ); return ( <img src={pfp} alt="User profile picture" className="absolute top-0 left-0 w-full h-full object-cover rounded-full border-none" /> ); } export default UserIcon;
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/KeyboardShortcutsHelp/index.jsx
frontend/src/components/KeyboardShortcutsHelp/index.jsx
import React, { useEffect, useState } from "react"; import { X } from "@phosphor-icons/react"; import { useTranslation } from "react-i18next"; import { SHORTCUTS, isMac, KEYBOARD_SHORTCUTS_HELP_EVENT, } from "@/utils/keyboardShortcuts"; export default function KeyboardShortcutsHelp() { const [isOpen, setIsOpen] = useState(false); const { t } = useTranslation(); useEffect(() => { window.addEventListener(KEYBOARD_SHORTCUTS_HELP_EVENT, () => setIsOpen((prev) => !prev) ); return () => { window.removeEventListener(KEYBOARD_SHORTCUTS_HELP_EVENT, () => setIsOpen(false) ); }; }, []); if (!isOpen) return null; return ( <div className="fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center"> <div className="relative bg-theme-bg-secondary rounded-lg p-6 max-w-2xl w-full mx-4"> <div className="flex justify-between items-center mb-6"> <h2 className="text-xl font-semibold text-white"> {t("keyboard-shortcuts.title")} </h2> <button onClick={() => setIsOpen(false)} className="text-white hover:text-gray-300" aria-label="Close" > <X size={24} /> </button> </div> <div className="grid grid-cols-1 md:grid-cols-2 gap-4"> {Object.entries(SHORTCUTS).map(([key, shortcut]) => ( <div key={key} className="flex items-center justify-between p-3 bg-theme-bg-hover rounded-lg" > <span className="text-white"> {t(`keyboard-shortcuts.shortcuts.${shortcut.translationKey}`)} </span> <kbd className="px-2 py-1 bg-theme-bg-secondary text-white rounded border border-gray-600"> {isMac ? key : key.replace("⌘", "Ctrl")} </kbd> </div> ))} </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/SettingsSidebar/index.jsx
frontend/src/components/SettingsSidebar/index.jsx
import React, { useEffect, useRef, useState } from "react"; import paths from "@/utils/paths"; import useLogo from "@/hooks/useLogo"; import { House, List, Robot, Flask, Gear, UserCircleGear, PencilSimpleLine, Nut, Toolbox, Globe, } from "@phosphor-icons/react"; import useUser from "@/hooks/useUser"; import { isMobile } from "react-device-detect"; import Footer from "../Footer"; import { Link } from "react-router-dom"; import { useTranslation } from "react-i18next"; import showToast from "@/utils/toast"; import System from "@/models/system"; import Option from "./MenuOption"; import { CanViewChatHistoryProvider } from "../CanViewChatHistory"; import useAppVersion from "@/hooks/useAppVersion"; export default function SettingsSidebar() { const { t } = useTranslation(); const { logo } = useLogo(); const { user } = useUser(); const sidebarRef = useRef(null); const [showSidebar, setShowSidebar] = useState(false); const [showBgOverlay, setShowBgOverlay] = useState(false); useEffect(() => { function handleBg() { if (showSidebar) { setTimeout(() => { setShowBgOverlay(true); }, 300); } else { setShowBgOverlay(false); } } handleBg(); }, [showSidebar]); if (isMobile) { return ( <> <div className="fixed top-0 left-0 right-0 z-10 flex justify-between items-center px-4 py-2 bg-theme-bg-sidebar light:bg-white text-theme-text-secondary shadow-lg h-16"> <button onClick={() => setShowSidebar(true)} className="rounded-md p-2 flex items-center justify-center text-theme-text-secondary" > <List className="h-6 w-6" /> </button> <div className="flex items-center justify-center flex-grow"> <img src={logo} alt="Logo" className="block mx-auto h-6 w-auto" style={{ maxHeight: "40px", objectFit: "contain" }} /> </div> <div className="w-12"></div> </div> <div style={{ transform: showSidebar ? `translateX(0vw)` : `translateX(-100vw)`, }} className={`z-99 fixed top-0 left-0 transition-all duration-500 w-[100vw] h-[100vh]`} > <div className={`${ showBgOverlay ? "transition-all opacity-1" : "transition-none opacity-0" } duration-500 fixed top-0 left-0 bg-theme-bg-secondary bg-opacity-75 w-screen h-screen`} onClick={() => setShowSidebar(false)} /> <div ref={sidebarRef} className="h-[100vh] fixed top-0 left-0 rounded-r-[26px] bg-theme-bg-sidebar w-[80%] p-[18px]" > <div className="w-full h-full flex flex-col overflow-x-hidden items-between"> {/* Header Information */} <div className="flex w-full items-center justify-between gap-x-4"> <div className="flex shrink-1 w-fit items-center justify-start"> <img src={logo} alt="Logo" className="rounded w-full max-h-[40px]" style={{ objectFit: "contain" }} /> </div> <div className="flex gap-x-2 items-center text-slate-500 shrink-0"> <a href={paths.home()} className="transition-all duration-300 p-2 rounded-full text-white bg-theme-action-menu-bg hover:bg-theme-action-menu-item-hover hover:border-slate-100 hover:border-opacity-50 border-transparent border" > <House className="h-4 w-4" /> </a> </div> </div> {/* Primary Body */} <div className="h-full flex flex-col w-full justify-between pt-4 overflow-y-scroll no-scroll"> <div className="h-auto md:sidebar-items"> <div className="flex flex-col gap-y-4 pb-[60px] overflow-y-scroll no-scroll"> <SidebarOptions user={user} t={t} /> <div className="h-[1.5px] bg-[#3D4147] mx-3 mt-[14px]" /> <SupportEmail /> <Link hidden={ user?.hasOwnProperty("role") && user.role !== "admin" } to={paths.settings.privacy()} className="text-theme-text-secondary hover:text-white text-xs leading-[18px] mx-3" > {t("settings.privacy")} </Link> <AppVersion /> </div> </div> </div> <div className="absolute bottom-2 left-0 right-0 pt-2 bg-theme-bg-sidebar bg-opacity-80 backdrop-filter backdrop-blur-md"> <Footer /> </div> </div> </div> </div> </> ); } return ( <> <div> <Link to={paths.home()} className="flex shrink-0 max-w-[55%] items-center justify-start mx-[38px] my-[18px]" > <img src={logo} alt="Logo" className="rounded max-h-[24px]" style={{ objectFit: "contain" }} /> </Link> <div ref={sidebarRef} className="transition-all duration-500 relative m-[16px] rounded-[16px] bg-theme-bg-sidebar border-[2px] border-theme-sidebar-border light:border-none min-w-[250px] p-[10px] h-[calc(100%-76px)]" > <div className="w-full h-full flex flex-col overflow-x-hidden items-between min-w-[235px]"> <div className="text-theme-text-secondary text-sm font-medium uppercase mt-[4px] mb-0 ml-2"> {t("settings.title")} </div> <div className="relative h-[calc(100%-60px)] flex flex-col w-full justify-between pt-[10px] overflow-y-scroll no-scroll"> <div className="h-auto sidebar-items"> <div className="flex flex-col gap-y-2 pb-[60px] overflow-y-scroll no-scroll"> <SidebarOptions user={user} t={t} /> <div className="h-[1.5px] bg-[#3D4147] mx-3 mt-[14px]" /> <SupportEmail /> <Link hidden={ user?.hasOwnProperty("role") && user.role !== "admin" } to={paths.settings.privacy()} className="text-theme-text-secondary hover:text-white hover:light:text-theme-text-primary text-xs leading-[18px] mx-3" > {t("settings.privacy")} </Link> <AppVersion /> </div> </div> </div> <div className="absolute bottom-0 left-0 right-0 pt-4 pb-3 rounded-b-[16px] bg-theme-bg-sidebar bg-opacity-80 backdrop-filter backdrop-blur-md z-10"> <Footer /> </div> </div> </div> </div> </> ); } function SupportEmail() { const [supportEmail, setSupportEmail] = useState(paths.mailToMintplex()); const { t } = useTranslation(); useEffect(() => { const fetchSupportEmail = async () => { const supportEmail = await System.fetchSupportEmail(); setSupportEmail( supportEmail?.email ? `mailto:${supportEmail.email}` : paths.mailToMintplex() ); }; fetchSupportEmail(); }, []); return ( <Link to={supportEmail} className="text-theme-text-secondary hover:text-white hover:light:text-theme-text-primary text-xs leading-[18px] mx-3 mt-1" > {t("settings.contact")} </Link> ); } const SidebarOptions = ({ user = null, t }) => ( <CanViewChatHistoryProvider> {({ viewable: canViewChatHistory }) => ( <> <Option btnText={t("settings.ai-providers")} icon={<Gear className="h-5 w-5 flex-shrink-0" />} user={user} childOptions={[ { btnText: t("settings.llm"), href: paths.settings.llmPreference(), flex: true, roles: ["admin"], }, { btnText: t("settings.vector-database"), href: paths.settings.vectorDatabase(), flex: true, roles: ["admin"], }, { btnText: t("settings.embedder"), href: paths.settings.embedder.modelPreference(), flex: true, roles: ["admin"], }, { btnText: t("settings.text-splitting"), href: paths.settings.embedder.chunkingPreference(), flex: true, roles: ["admin"], }, { btnText: t("settings.voice-speech"), href: paths.settings.audioPreference(), flex: true, roles: ["admin"], }, { btnText: t("settings.transcription"), href: paths.settings.transcriptionPreference(), flex: true, roles: ["admin"], }, ]} /> <Option btnText={t("settings.admin")} icon={<UserCircleGear className="h-5 w-5 flex-shrink-0" />} user={user} childOptions={[ { btnText: t("settings.users"), href: paths.settings.users(), roles: ["admin", "manager"], }, { btnText: t("settings.workspaces"), href: paths.settings.workspaces(), roles: ["admin", "manager"], }, { hidden: !canViewChatHistory, btnText: t("settings.workspace-chats"), href: paths.settings.chats(), flex: true, roles: ["admin", "manager"], }, { btnText: t("settings.invites"), href: paths.settings.invites(), roles: ["admin", "manager"], }, { btnText: "Default System Prompt", href: paths.settings.defaultSystemPrompt(), flex: true, roles: ["admin"], }, ]} /> <Option btnText={t("settings.agent-skills")} icon={<Robot className="h-5 w-5 flex-shrink-0" />} href={paths.settings.agentSkills()} user={user} flex={true} roles={["admin"]} /> <Option btnText="Community Hub" icon={<Globe className="h-5 w-5 flex-shrink-0" />} childOptions={[ { btnText: "Explore Trending", href: paths.communityHub.trending(), flex: true, roles: ["admin"], }, { btnText: "Your Account", href: paths.communityHub.authentication(), flex: true, roles: ["admin"], }, { btnText: "Import Item", href: paths.communityHub.importItem(), flex: true, roles: ["admin"], }, ]} /> <Option btnText={t("settings.customization")} icon={<PencilSimpleLine className="h-5 w-5 flex-shrink-0" />} user={user} childOptions={[ { btnText: t("settings.interface"), href: paths.settings.interface(), flex: true, roles: ["admin", "manager"], }, { btnText: t("settings.branding"), href: paths.settings.branding(), flex: true, roles: ["admin", "manager"], }, { btnText: t("settings.chat"), href: paths.settings.chat(), flex: true, roles: ["admin", "manager"], }, ]} /> <Option btnText={t("settings.tools")} icon={<Toolbox className="h-5 w-5 flex-shrink-0" />} user={user} childOptions={[ { hidden: !canViewChatHistory, btnText: t("settings.embeds"), href: paths.settings.embedChatWidgets(), flex: true, roles: ["admin"], }, { btnText: t("settings.event-logs"), href: paths.settings.logs(), flex: true, roles: ["admin"], }, { btnText: t("settings.api-keys"), href: paths.settings.apiKeys(), flex: true, roles: ["admin"], }, { btnText: t("settings.system-prompt-variables"), href: paths.settings.systemPromptVariables(), flex: true, roles: ["admin"], }, { btnText: t("settings.browser-extension"), href: paths.settings.browserExtension(), flex: true, roles: ["admin", "manager"], }, ]} /> <Option btnText={t("settings.security")} icon={<Nut className="h-5 w-5 flex-shrink-0" />} href={paths.settings.security()} user={user} flex={true} roles={["admin", "manager"]} hidden={user?.role} /> <HoldToReveal key="exp_features"> <Option btnText={t("settings.experimental-features")} icon={<Flask className="h-5 w-5 flex-shrink-0" />} href={paths.settings.experimental()} user={user} flex={true} roles={["admin"]} /> </HoldToReveal> </> )} </CanViewChatHistoryProvider> ); function HoldToReveal({ children, holdForMs = 3_000 }) { let timeout = null; const [showing, setShowing] = useState( window.localStorage.getItem( "anythingllm_experimental_feature_preview_unlocked" ) ); useEffect(() => { const onPress = (e) => { if (!["Control", "Meta"].includes(e.key) || timeout !== null) return; timeout = setTimeout(() => { setShowing(true); // Setting toastId prevents hook spam from holding control too many times or the event not detaching showToast("Experimental feature previews unlocked!"); window.localStorage.setItem( "anythingllm_experimental_feature_preview_unlocked", "enabled" ); window.removeEventListener("keypress", onPress); window.removeEventListener("keyup", onRelease); clearTimeout(timeout); }, holdForMs); }; const onRelease = (e) => { if (!["Control", "Meta"].includes(e.key)) return; if (showing) { window.removeEventListener("keypress", onPress); window.removeEventListener("keyup", onRelease); clearTimeout(timeout); return; } clearTimeout(timeout); }; if (!showing) { window.addEventListener("keydown", onPress); window.addEventListener("keyup", onRelease); } return () => { window.removeEventListener("keydown", onPress); window.removeEventListener("keyup", onRelease); }; }, []); if (!showing) return null; return children; } function AppVersion() { const { version, isLoading } = useAppVersion(); if (isLoading) return null; return ( <Link to={`https://github.com/Mintplex-Labs/anything-llm/releases/tag/v${version}`} target="_blank" rel="noreferrer" className="text-theme-text-secondary light:opacity-80 opacity-50 text-xs mx-3" > v{version} </Link> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/SettingsSidebar/MenuOption/index.jsx
frontend/src/components/SettingsSidebar/MenuOption/index.jsx
import React, { useEffect, useState } from "react"; import { CaretRight } from "@phosphor-icons/react"; import { Link, useLocation } from "react-router-dom"; import { safeJsonParse } from "@/utils/request"; export default function MenuOption({ btnText, icon, href, childOptions = [], flex = false, user = null, roles = [], hidden = false, isChild = false, }) { const storageKey = generateStorageKey({ key: btnText }); const location = useLocation(); const hasChildren = childOptions.length > 0; const hasVisibleChildren = hasVisibleOptions(user, childOptions); const { isExpanded, setIsExpanded } = useIsExpanded({ storageKey, hasVisibleChildren, childOptions, location: location.pathname, }); if (hidden) return null; // If this option is a parent level option if (!isChild) { // and has no children then use its flex props and roles prop directly if (!hasChildren) { if (!flex && !roles.includes(user?.role)) return null; if (flex && !!user && !roles.includes(user?.role)) return null; } // if has children and no visible children - remove it. if (hasChildren && !hasVisibleChildren) return null; } else { // is a child so we use it's permissions if (!flex && !roles.includes(user?.role)) return null; if (flex && !!user && !roles.includes(user?.role)) return null; } const isActive = hasChildren ? (!isExpanded && childOptions.some((child) => child.href === location.pathname)) || location.pathname === href : location.pathname === href; const handleClick = (e) => { if (hasChildren) { e.preventDefault(); const newExpandedState = !isExpanded; setIsExpanded(newExpandedState); localStorage.setItem(storageKey, JSON.stringify(newExpandedState)); } }; return ( <div> <div className={` flex items-center justify-between w-full transition-all duration-300 rounded-[6px] ${ isActive ? "bg-theme-sidebar-subitem-selected font-medium border-outline" : "hover:bg-theme-sidebar-subitem-hover" } `} > <Link to={href} className={`flex flex-grow items-center px-[12px] h-[32px] font-medium ${ isChild ? "hover:text-white" : "text-white light:text-black" }`} onClick={hasChildren ? handleClick : undefined} > {icon} <p className={`${ isChild ? "text-xs" : "text-sm" } leading-loose whitespace-nowrap overflow-hidden ml-2 ${ isActive ? "text-white font-semibold" : "text-white light:text-black" } ${!icon && "pl-5"}`} > {btnText} </p> </Link> {hasChildren && ( <button onClick={handleClick} className="p-2 text-white"> <CaretRight size={16} weight="bold" // color={isExpanded ? "#000000" : "var(--theme-sidebar-subitem-icon)"} className={`transition-transform text-white light:text-black ${ isExpanded ? "rotate-90" : "" }`} /> </button> )} </div> {isExpanded && hasChildren && ( <div className="mt-1 rounded-r-lg w-full"> {childOptions.map((childOption, index) => ( <MenuOption key={index} {...childOption} // flex and roles go here. user={user} isChild={true} /> ))} </div> )} </div> ); } function useIsExpanded({ storageKey = "", hasVisibleChildren = false, childOptions = [], location = null, }) { const [isExpanded, setIsExpanded] = useState(() => { if (hasVisibleChildren) { const storedValue = localStorage.getItem(storageKey); if (storedValue !== null) { return safeJsonParse(storedValue, false); } return childOptions.some((child) => child.href === location); } return false; }); useEffect(() => { if (hasVisibleChildren) { const shouldExpand = childOptions.some( (child) => child.href === location ); if (shouldExpand && !isExpanded) { setIsExpanded(true); localStorage.setItem(storageKey, JSON.stringify(true)); } } }, [location]); return { isExpanded, setIsExpanded }; } /** * Checks if the child options are visible to the user. * This hides the top level options if the child options are not visible * for either the users permissions or the child options hidden prop is set to true by other means. * If all child options return false for `isVisible` then the parent option will not be visible as well. * @param {object} user - The user object. * @param {array} childOptions - The child options. * @returns {boolean} - True if the child options are visible, false otherwise. */ function hasVisibleOptions(user = null, childOptions = []) { if (!Array.isArray(childOptions) || childOptions?.length === 0) return false; function isVisible({ roles = [], user = null, flex = false, hidden = false, }) { if (hidden) return false; if (!flex && !roles.includes(user?.role)) return false; if (flex && !!user && !roles.includes(user?.role)) return false; return true; } return childOptions.some((opt) => isVisible({ roles: opt.roles, user, flex: opt.flex, hidden: opt.hidden }) ); } function generateStorageKey({ key = "" }) { const _key = key.replace(/\s+/g, "_").toLowerCase(); return `anything_llm_menu_${_key}_expanded`; }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/Footer/index.jsx
frontend/src/components/Footer/index.jsx
import System from "@/models/system"; import paths from "@/utils/paths"; import { BookOpen, DiscordLogo, GithubLogo, Briefcase, Envelope, Globe, HouseLine, Info, LinkSimple, } from "@phosphor-icons/react"; import React, { useEffect, useState } from "react"; import SettingsButton from "../SettingsButton"; import { isMobile } from "react-device-detect"; import { Tooltip } from "react-tooltip"; import { Link } from "react-router-dom"; export const MAX_ICONS = 3; export const ICON_COMPONENTS = { BookOpen: BookOpen, DiscordLogo: DiscordLogo, GithubLogo: GithubLogo, Envelope: Envelope, LinkSimple: LinkSimple, HouseLine: HouseLine, Globe: Globe, Briefcase: Briefcase, Info: Info, }; export default function Footer() { const [footerData, setFooterData] = useState(false); useEffect(() => { async function fetchFooterData() { const { footerData } = await System.fetchCustomFooterIcons(); setFooterData(footerData); } fetchFooterData(); }, []); // wait for some kind of non-false response from footer data first // to prevent pop-in. if (footerData === false) return null; if (!Array.isArray(footerData) || footerData.length === 0) { return ( <div className="flex justify-center mb-2"> <div className="flex space-x-4"> <div className="flex w-fit"> <Link to={paths.github()} target="_blank" rel="noreferrer" className="transition-all duration-300 p-2 rounded-full bg-theme-sidebar-footer-icon hover:bg-theme-sidebar-footer-icon-hover" aria-label="Find us on GitHub" data-tooltip-id="footer-item" data-tooltip-content="View Source Code" > <GithubLogo weight="fill" className="h-5 w-5" color="var(--theme-sidebar-footer-icon-fill)" /> </Link> </div> <div className="flex w-fit"> <Link to={paths.docs()} target="_blank" rel="noreferrer" className="transition-all duration-300 p-2 rounded-full bg-theme-sidebar-footer-icon hover:bg-theme-sidebar-footer-icon-hover" aria-label="Docs" data-tooltip-id="footer-item" data-tooltip-content="Open AnythingLLM help docs" > <BookOpen weight="fill" className="h-5 w-5" color="var(--theme-sidebar-footer-icon-fill)" /> </Link> </div> <div className="flex w-fit"> <Link to={paths.discord()} target="_blank" rel="noreferrer" className="transition-all duration-300 p-2 rounded-full bg-theme-sidebar-footer-icon hover:bg-theme-sidebar-footer-icon-hover" aria-label="Join our Discord server" data-tooltip-id="footer-item" data-tooltip-content="Join the AnythingLLM Discord" > <DiscordLogo weight="fill" className="h-5 w-5" color="var(--theme-sidebar-footer-icon-fill)" /> </Link> </div> {!isMobile && <SettingsButton />} </div> <Tooltip id="footer-item" place="top" delayShow={300} className="tooltip !text-xs z-99" /> </div> ); } return ( <div className="flex justify-center mb-2"> <div className="flex space-x-4"> {footerData.map((item, index) => ( <a key={index} href={item.url} target="_blank" rel="noreferrer" className="transition-all duration-300 flex w-fit h-fit p-2 p-2 rounded-full bg-theme-sidebar-footer-icon hover:bg-theme-sidebar-footer-icon-hover hover:border-slate-100" > {React.createElement( ICON_COMPONENTS?.[item.icon] ?? ICON_COMPONENTS.Info, { weight: "fill", className: "h-5 w-5", color: "var(--theme-sidebar-footer-icon-fill)", } )} </a> ))} {!isMobile && <SettingsButton />} </div> <Tooltip id="footer-item" place="top" delayShow={300} className="tooltip !text-xs z-99" /> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/DataConnectorOption/index.jsx
frontend/src/components/DataConnectorOption/index.jsx
export default function DataConnectorOption({ slug }) { if (!DATA_CONNECTORS.hasOwnProperty(slug)) return null; const { path, image, name, description, link } = DATA_CONNECTORS[slug]; return ( <a href={path}> <label className="transition-all duration-300 inline-flex flex-col h-full w-60 cursor-pointer items-start justify-between rounded-2xl bg-preference-gradient border-2 border-transparent shadow-md px-5 py-4 text-white hover:bg-selected-preference-gradient hover:border-white/60 peer-checked:border-white peer-checked:border-opacity-90 peer-checked:bg-selected-preference-gradient"> <div className="flex items-center"> <img src={image} alt={name} className="h-10 w-10 rounded" /> <div className="ml-4 text-sm font-semibold">{name}</div> </div> <div className="mt-2 text-xs font-base text-white tracking-wide"> {description} </div> <a href={link} target="_blank" className="mt-2 text-xs text-white font-medium underline" > {link} </a> </label> </a> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/DataConnectorOption/media/index.js
frontend/src/components/DataConnectorOption/media/index.js
import GitHub from "./github.svg"; import GitLab from "./gitlab.svg"; import YouTube from "./youtube.svg"; import Link from "./link.svg"; import Confluence from "./confluence.jpeg"; import DrupalWiki from "./drupalwiki.jpg"; import Obsidian from "./obsidian.png"; import PaperlessNgx from "./paperless-ngx.jpeg"; const ConnectorImages = { github: GitHub, gitlab: GitLab, youtube: YouTube, websiteDepth: Link, confluence: Confluence, drupalwiki: DrupalWiki, obsidian: Obsidian, paperlessNgx: PaperlessNgx, }; export default ConnectorImages;
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/SettingsButton/index.jsx
frontend/src/components/SettingsButton/index.jsx
import useUser from "@/hooks/useUser"; import paths from "@/utils/paths"; import { ArrowUUpLeft, Wrench } from "@phosphor-icons/react"; import { Link } from "react-router-dom"; import { useMatch } from "react-router-dom"; export default function SettingsButton() { const isInSettings = !!useMatch("/settings/*"); const { user } = useUser(); if (user && user?.role === "default") return null; if (isInSettings) return ( <div className="flex w-fit"> <Link to={paths.home()} className="transition-all duration-300 p-2 rounded-full bg-theme-sidebar-footer-icon hover:bg-theme-sidebar-footer-icon-hover" aria-label="Home" data-tooltip-id="footer-item" data-tooltip-content="Back to workspaces" > <ArrowUUpLeft className="h-5 w-5" weight="fill" color="var(--theme-sidebar-footer-icon-fill)" /> </Link> </div> ); return ( <div className="flex w-fit"> <Link to={paths.settings.interface()} className="transition-all duration-300 p-2 rounded-full bg-theme-sidebar-footer-icon hover:bg-theme-sidebar-footer-icon-hover" aria-label="Settings" data-tooltip-id="footer-item" data-tooltip-content="Open settings" > <Wrench className="h-5 w-5" weight="fill" color="var(--theme-sidebar-footer-icon-fill)" /> </Link> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/TextToSpeech/OpenAiGenericOptions/index.jsx
frontend/src/components/TextToSpeech/OpenAiGenericOptions/index.jsx
import React from "react"; export default function OpenAiGenericTextToSpeechOptions({ settings }) { return ( <div className="w-full flex flex-col gap-y-7"> <div className="flex gap-x-4"> <div className="flex flex-col w-60"> <div className="flex justify-between items-start mb-2"> <label className="text-white text-sm font-semibold">Base URL</label> </div> <input type="url" name="TTSOpenAICompatibleEndpoint" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="http://localhost:7851/v1" defaultValue={settings?.TTSOpenAICompatibleEndpoint} required={false} autoComplete="off" spellCheck={false} /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> This should be the base URL of the OpenAI compatible TTS service you will generate TTS responses from. </p> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-2"> API Key </label> <input type="password" name="TTSOpenAICompatibleKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="API Key" defaultValue={ settings?.TTSOpenAICompatibleKey ? "*".repeat(20) : "" } autoComplete="off" spellCheck={false} /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Some TTS services require an API key to generate TTS responses - this is optional if your service does not require one. </p> </div> </div> <div className="flex gap-x-4"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> TTS Model </label> <input type="text" name="TTSOpenAICompatibleModel" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Your TTS model identifier" defaultValue={settings?.TTSOpenAICompatibleModel} required={true} autoComplete="off" spellCheck={false} /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Most TTS services will have several models available. This is the{" "} <code>model</code> parameter you will use to select the model you want to use. Note: This is not the same as the voice model. </p> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Voice Model </label> <input type="text" name="TTSOpenAICompatibleVoiceModel" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Your voice model identifier" defaultValue={settings?.TTSOpenAICompatibleVoiceModel} required={true} autoComplete="off" spellCheck={false} /> <p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> Most TTS services will have several voice models available, this is the identifier for the voice model you want to use. </p> </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/TextToSpeech/ElevenLabsOptions/index.jsx
frontend/src/components/TextToSpeech/ElevenLabsOptions/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; export default function ElevenLabsOptions({ settings }) { const [inputValue, setInputValue] = useState(settings?.TTSElevenLabsKey); const [elevenLabsKey, setElevenLabsKey] = useState( settings?.TTSElevenLabsKey ); return ( <div className="flex gap-x-4"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="TTSElevenLabsKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="ElevenLabs API Key" defaultValue={settings?.TTSElevenLabsKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} onChange={(e) => setInputValue(e.target.value)} onBlur={() => setElevenLabsKey(inputValue)} /> </div> {!settings?.credentialsOnly && ( <ElevenLabsModelSelection settings={settings} apiKey={elevenLabsKey} /> )} </div> ); } function ElevenLabsModelSelection({ apiKey, settings }) { const [groupedModels, setGroupedModels] = useState({}); const [loading, setLoading] = useState(true); useEffect(() => { async function findCustomModels() { setLoading(true); const { models } = await System.customModels( "elevenlabs-tts", typeof apiKey === "boolean" ? null : apiKey ); if (models?.length > 0) { const modelsByOrganization = models.reduce((acc, model) => { acc[model.organization] = acc[model.organization] || []; acc[model.organization].push(model); return acc; }, {}); setGroupedModels(modelsByOrganization); } setLoading(false); } findCustomModels(); }, [apiKey]); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="TTSElevenLabsVoiceModel" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option disabled={true} selected={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Chat Model Selection </label> <select name="TTSElevenLabsVoiceModel" required={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {Object.keys(groupedModels) .sort() .map((organization) => ( <optgroup key={organization} label={organization}> {groupedModels[organization].map((model) => ( <option key={model.id} value={model.id} selected={model.id === settings?.TTSElevenLabsVoiceModel} > {model.name} </option> ))} </optgroup> ))} </select> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/TextToSpeech/BrowserNative/index.jsx
frontend/src/components/TextToSpeech/BrowserNative/index.jsx
export default function BrowserNative() { return ( <div className="w-full h-10 items-center flex"> <p className="text-sm font-base text-white text-opacity-60"> There is no configuration needed for this provider. </p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/TextToSpeech/OpenAiOptions/index.jsx
frontend/src/components/TextToSpeech/OpenAiOptions/index.jsx
function toProperCase(string) { return string.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); } export default function OpenAiTextToSpeechOptions({ settings }) { const apiKey = settings?.TTSOpenAIKey; return ( <div className="flex gap-x-4"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> API Key </label> <input type="password" name="TTSOpenAIKey" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="OpenAI API Key" defaultValue={apiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Voice Model </label> <select name="TTSOpenAIVoiceModel" defaultValue={settings?.TTSOpenAIVoiceModel ?? "alloy"} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {["alloy", "echo", "fable", "onyx", "nova", "shimmer"].map( (voice) => { return ( <option key={voice} value={voice}> {toProperCase(voice)} </option> ); } )} </select> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/TextToSpeech/PiperTTSOptions/index.jsx
frontend/src/components/TextToSpeech/PiperTTSOptions/index.jsx
import { useState, useEffect, useRef } from "react"; import PiperTTSClient from "@/utils/piperTTS"; import { titleCase } from "text-case"; import { humanFileSize } from "@/utils/numbers"; import showToast from "@/utils/toast"; import { CircleNotch, PauseCircle, PlayCircle } from "@phosphor-icons/react"; export default function PiperTTSOptions({ settings }) { return ( <> <p className="text-sm font-base text-white text-opacity-60 mb-4"> All PiperTTS models will run in your browser locally. This can be resource intensive on lower-end devices. </p> <div className="flex gap-x-4 items-center"> <PiperTTSModelSelection settings={settings} /> </div> </> ); } function voicesByLanguage(voices = []) { const voicesByLanguage = voices.reduce((acc, voice) => { const langName = voice?.language?.name_english ?? "Unlisted"; acc[langName] = acc[langName] || []; acc[langName].push(voice); return acc; }, {}); return Object.entries(voicesByLanguage); } function voiceDisplayName(voice) { const { is_stored, name, quality, files } = voice; const onnxFileKey = Object.keys(files).find((key) => key.endsWith(".onnx")); const fileSize = files?.[onnxFileKey]?.size_bytes || 0; return `${is_stored ? "✔ " : ""}${titleCase(name)}-${quality === "low" ? "Low" : "HQ"} (${humanFileSize(fileSize)})`; } function PiperTTSModelSelection({ settings }) { const [loading, setLoading] = useState(true); const [voices, setVoices] = useState([]); const [selectedVoice, setSelectedVoice] = useState( settings?.TTSPiperTTSVoiceModel ); function flushVoices() { PiperTTSClient.flush() .then(() => showToast("All voices flushed from browser storage", "info", { clear: true, }) ) .catch((e) => console.error(e)); } useEffect(() => { PiperTTSClient.voices() .then((voices) => { if (voices?.length !== 0) return setVoices(voices); throw new Error("Could not fetch voices from web worker."); }) .catch((e) => { console.error(e); }) .finally(() => setLoading(false)); }, []); if (loading) { return ( <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Voice Model Selection </label> <select name="TTSPiperTTSVoiceModel" value="" disabled={true} className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <option value="" disabled={true}> -- loading available models -- </option> </select> </div> ); } return ( <div className="flex flex-col w-fit"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Voice Model Selection </label> <div className="flex items-center w-fit gap-x-4 mb-2"> <select name="TTSPiperTTSVoiceModel" required={true} onChange={(e) => setSelectedVoice(e.target.value)} value={selectedVoice} className="border-none flex-shrink-0 bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > {voicesByLanguage(voices).map(([lang, voices]) => { return ( <optgroup key={lang} label={lang}> {voices.map((voice) => ( <option key={voice.key} value={voice.key}> {voiceDisplayName(voice)} </option> ))} </optgroup> ); })} </select> <DemoVoiceSample voiceId={selectedVoice} /> </div> <p className="text-xs text-white/40"> The "✔" indicates this model is already stored locally and does not need to be downloaded when run. </p> </div> {!!voices.find((voice) => voice.is_stored) && ( <button type="button" onClick={flushVoices} className="w-fit border-none hover:text-white hover:underline text-white/40 text-sm my-4" > Flush voice cache </button> )} </div> ); } function DemoVoiceSample({ voiceId }) { const playerRef = useRef(null); const [speaking, setSpeaking] = useState(false); const [loading, setLoading] = useState(false); const [audioSrc, setAudioSrc] = useState(null); async function speakMessage(e) { e.preventDefault(); if (speaking) { playerRef?.current?.pause(); return; } try { if (!audioSrc) { setLoading(true); const client = new PiperTTSClient({ voiceId }); const blobUrl = await client.getAudioBlobForText( "Hello, welcome to AnythingLLM!" ); setAudioSrc(blobUrl); setLoading(false); client.worker?.terminate(); PiperTTSClient._instance = null; } else { playerRef.current.play(); } } catch (e) { console.error(e); setLoading(false); setSpeaking(false); } } useEffect(() => { function setupPlayer() { if (!playerRef?.current) return; playerRef.current.addEventListener("play", () => { setSpeaking(true); }); playerRef.current.addEventListener("pause", () => { playerRef.current.currentTime = 0; setSpeaking(false); setAudioSrc(null); }); } setupPlayer(); }, []); return ( <button type="button" onClick={speakMessage} disabled={loading} className="border-none text-zinc-300 flex items-center gap-x-1" > {speaking ? ( <> <PauseCircle size={20} className="flex-shrink-0" /> <p className="text-sm flex-shrink-0">Stop demo</p> </> ) : ( <> {loading ? ( <> <CircleNotch size={20} className="animate-spin flex-shrink-0" /> <p className="text-sm flex-shrink-0">Loading voice</p> </> ) : ( <> <PlayCircle size={20} className="flex-shrink-0 text-white" /> <p className="text-white text-sm flex-shrink-0">Play sample</p> </> )} </> )} <audio ref={playerRef} hidden={true} src={audioSrc} autoPlay={true} controls={false} /> </button> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/ProviderPrivacy/index.jsx
frontend/src/components/ProviderPrivacy/index.jsx
import { useState, useEffect } from "react"; import System from "@/models/system"; import { PROVIDER_PRIVACY_MAP } from "./constants"; import { ArrowSquareOut } from "@phosphor-icons/react"; import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png"; import { Link } from "react-router-dom"; import { titleCase, sentenceCase } from "text-case"; function defaultProvider(providerString) { return { name: providerString ? titleCase(sentenceCase(String(providerString))) : "Unknown", description: [ `"${providerString}" has no known data handling policy defined in AnythingLLM.`, ], logo: AnythingLLMIcon, }; } export default function ProviderPrivacy() { const [loading, setLoading] = useState(true); const [providers, setProviders] = useState({ llmProvider: null, embeddingEngine: null, vectorDb: null, }); useEffect(() => { async function fetchProviders() { const _settings = await System.keys(); const providerDefinition = PROVIDER_PRIVACY_MAP.llm[_settings?.LLMProvider] || defaultProvider(_settings?.LLMProvider); const embeddingEngineDefinition = PROVIDER_PRIVACY_MAP.embeddingEngine[_settings?.EmbeddingEngine] || defaultProvider(_settings?.EmbeddingEngine); const vectorDbDefinition = PROVIDER_PRIVACY_MAP.vectorDb[_settings?.VectorDB] || defaultProvider(_settings?.VectorDB); setProviders({ llmProvider: providerDefinition, embeddingEngine: embeddingEngineDefinition, vectorDb: vectorDbDefinition, }); setLoading(false); } fetchProviders(); }, []); if (loading) return null; return ( <div className="flex flex-col gap-8 w-full max-w-2xl"> <ProviderPrivacyItem title="LLM Provider" provider={providers.llmProvider} altText="LLM Logo" /> <ProviderPrivacyItem title="Embedding Preference" provider={providers.embeddingEngine} altText="Embedding Logo" /> <ProviderPrivacyItem title="Vector Database" provider={providers.vectorDb} altText="Vector DB Logo" /> </div> ); } function ProviderPrivacyItem({ title, provider, altText }) { return ( <div className="flex flex-col items-start gap-y-3 pb-4 border-b border-theme-sidebar-border"> <div className="text-theme-text-primary text-base font-bold">{title}</div> <div className="flex items-start gap-3"> <img src={provider.logo} alt={altText} className="w-8 h-8 rounded flex-shrink-0 mt-0.5" /> <div className="flex flex-col gap-2 flex-1"> <div className="flex items-center gap-2 flex-wrap"> <span className="text-theme-text-primary text-sm font-semibold"> {provider.name} </span> </div> {provider.policyUrl ? ( <div className="text-theme-text-secondary text-sm"> Your usage, chats, and data are subject to the service&apos;s{" "} <Link className="text-theme-text-secondary hover:text-theme-text-primary text-sm font-medium underline transition-colors inline-flex items-center gap-1" to={provider.policyUrl} target="_blank" rel="noopener noreferrer" > privacy policy <ArrowSquareOut size={12} /> </Link> . </div> ) : ( provider.description && ( <ul className="flex flex-col list-none gap-1"> {provider.description.map((desc, idx) => ( <li key={idx} className="text-theme-text-secondary text-sm"> {desc} </li> ))} </ul> ) )} </div> </div> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/ProviderPrivacy/constants.js
frontend/src/components/ProviderPrivacy/constants.js
import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png"; import OpenAiLogo from "@/media/llmprovider/openai.png"; import GenericOpenAiLogo from "@/media/llmprovider/generic-openai.png"; import AzureOpenAiLogo from "@/media/llmprovider/azure.png"; import AnthropicLogo from "@/media/llmprovider/anthropic.png"; import GeminiLogo from "@/media/llmprovider/gemini.png"; import OllamaLogo from "@/media/llmprovider/ollama.png"; import TogetherAILogo from "@/media/llmprovider/togetherai.png"; import FireworksAILogo from "@/media/llmprovider/fireworksai.jpeg"; import NvidiaNimLogo from "@/media/llmprovider/nvidia-nim.png"; import LMStudioLogo from "@/media/llmprovider/lmstudio.png"; import LocalAiLogo from "@/media/llmprovider/localai.png"; import MistralLogo from "@/media/llmprovider/mistral.jpeg"; import HuggingFaceLogo from "@/media/llmprovider/huggingface.png"; import PerplexityLogo from "@/media/llmprovider/perplexity.png"; import OpenRouterLogo from "@/media/llmprovider/openrouter.jpeg"; import NovitaLogo from "@/media/llmprovider/novita.png"; import GroqLogo from "@/media/llmprovider/groq.png"; import KoboldCPPLogo from "@/media/llmprovider/koboldcpp.png"; import TextGenWebUILogo from "@/media/llmprovider/text-generation-webui.png"; import LiteLLMLogo from "@/media/llmprovider/litellm.png"; import AWSBedrockLogo from "@/media/llmprovider/bedrock.png"; import DeepSeekLogo from "@/media/llmprovider/deepseek.png"; import APIPieLogo from "@/media/llmprovider/apipie.png"; import XAILogo from "@/media/llmprovider/xai.png"; import ZAiLogo from "@/media/llmprovider/zai.png"; import CohereLogo from "@/media/llmprovider/cohere.png"; import ZillizLogo from "@/media/vectordbs/zilliz.png"; import AstraDBLogo from "@/media/vectordbs/astraDB.png"; import ChromaLogo from "@/media/vectordbs/chroma.png"; import PineconeLogo from "@/media/vectordbs/pinecone.png"; import LanceDbLogo from "@/media/vectordbs/lancedb.png"; import WeaviateLogo from "@/media/vectordbs/weaviate.png"; import QDrantLogo from "@/media/vectordbs/qdrant.png"; import MilvusLogo from "@/media/vectordbs/milvus.png"; import VoyageAiLogo from "@/media/embeddingprovider/voyageai.png"; import PPIOLogo from "@/media/llmprovider/ppio.png"; import PGVectorLogo from "@/media/vectordbs/pgvector.png"; import DPAISLogo from "@/media/llmprovider/dpais.png"; import MoonshotAiLogo from "@/media/llmprovider/moonshotai.png"; import CometApiLogo from "@/media/llmprovider/cometapi.png"; import FoundryLogo from "@/media/llmprovider/foundry-local.png"; import GiteeAILogo from "@/media/llmprovider/giteeai.png"; const LLM_PROVIDER_PRIVACY_MAP = { openai: { name: "OpenAI", policyUrl: "https://openai.com/policies/privacy-policy/", logo: OpenAiLogo, }, azure: { name: "Azure OpenAI", policyUrl: "https://privacy.microsoft.com/privacystatement", logo: AzureOpenAiLogo, }, anthropic: { name: "Anthropic", policyUrl: "https://www.anthropic.com/privacy", logo: AnthropicLogo, }, gemini: { name: "Google Gemini", policyUrl: "https://policies.google.com/privacy", logo: GeminiLogo, }, "nvidia-nim": { name: "NVIDIA NIM", description: [ "Your model and chats are only accessible on the machine running the NVIDIA NIM.", ], logo: NvidiaNimLogo, }, lmstudio: { name: "LMStudio", description: [ "Your model and chats are only accessible on the server running LMStudio.", ], logo: LMStudioLogo, }, localai: { name: "LocalAI", description: [ "Your model and chats are only accessible on the server running LocalAI.", ], logo: LocalAiLogo, }, ollama: { name: "Ollama", description: [ "Your model and chats are only accessible on the machine running Ollama models.", ], logo: OllamaLogo, }, togetherai: { name: "TogetherAI", policyUrl: "https://www.together.ai/privacy", logo: TogetherAILogo, }, fireworksai: { name: "FireworksAI", policyUrl: "https://fireworks.ai/privacy-policy", logo: FireworksAILogo, }, mistral: { name: "Mistral", policyUrl: "https://legal.mistral.ai/terms/privacy-policy", logo: MistralLogo, }, huggingface: { name: "HuggingFace", policyUrl: "https://huggingface.co/privacy", logo: HuggingFaceLogo, }, perplexity: { name: "Perplexity AI", policyUrl: "https://www.perplexity.ai/privacy", logo: PerplexityLogo, }, openrouter: { name: "OpenRouter", policyUrl: "https://openrouter.ai/privacy", logo: OpenRouterLogo, }, novita: { name: "Novita AI", policyUrl: "https://novita.ai/legal/privacy-policy", logo: NovitaLogo, }, groq: { name: "Groq", policyUrl: "https://groq.com/privacy-policy/", logo: GroqLogo, }, koboldcpp: { name: "KoboldCPP", description: [ "Your model and chats are only accessible on the server running KoboldCPP", ], logo: KoboldCPPLogo, }, textgenwebui: { name: "Oobabooga Web UI", description: [ "Your model and chats are only accessible on the server running the Oobabooga Text Generation Web UI", ], logo: TextGenWebUILogo, }, "generic-openai": { name: "Generic OpenAI compatible service", description: [ "Data is shared according to the terms of service applicable with your generic endpoint provider.", ], logo: GenericOpenAiLogo, }, cohere: { name: "Cohere", policyUrl: "https://cohere.com/privacy", logo: CohereLogo, }, litellm: { name: "LiteLLM", description: [ "Your model and chats are only accessible on the server running LiteLLM", ], logo: LiteLLMLogo, }, bedrock: { name: "AWS Bedrock", policyUrl: "https://aws.amazon.com/bedrock/security-compliance/", logo: AWSBedrockLogo, }, deepseek: { name: "DeepSeek", policyUrl: "https://cdn.deepseek.com/policies/en-US/deepseek-privacy-policy.html", logo: DeepSeekLogo, }, apipie: { name: "APIpie.AI", policyUrl: "https://apipie.ai/docs/Terms/privacy", logo: APIPieLogo, }, xai: { name: "xAI", policyUrl: "https://x.ai/legal/privacy-policy", logo: XAILogo, }, zai: { name: "Z.AI", policyUrl: "https://docs.z.ai/legal-agreement/privacy-policy", logo: ZAiLogo, }, ppio: { name: "PPIO", policyUrl: "https://www.pipio.ai/privacy-policy", logo: PPIOLogo, }, dpais: { name: "Dell Pro AI Studio", description: [ "Your model and chat contents are only accessible on the computer running Dell Pro AI Studio.", ], logo: DPAISLogo, }, moonshotai: { name: "Moonshot AI", policyUrl: "https://platform.moonshot.ai/docs/agreement/userprivacy", logo: MoonshotAiLogo, }, cometapi: { name: "CometAPI", policyUrl: "https://apidoc.cometapi.com/privacy-policy-873819m0", logo: CometApiLogo, }, foundry: { name: "Microsoft Foundry Local", description: [ "Your model and chats are only accessible on the machine running Foundry Local.", ], logo: FoundryLogo, }, giteeai: { name: "GiteeAI", policyUrl: "https://ai.gitee.com/docs/appendix/privacy", logo: GiteeAILogo, }, }; const VECTOR_DB_PROVIDER_PRIVACY_MAP = { pgvector: { name: "PGVector", description: [ "Your vectors and document text are stored on your PostgreSQL instance.", "Access to your instance is managed by you.", ], logo: PGVectorLogo, }, chroma: { name: "Chroma", description: [ "Your vectors and document text are stored on your Chroma instance.", "Access to your instance is managed by you.", ], logo: ChromaLogo, }, chromacloud: { name: "Chroma Cloud", policyUrl: "https://www.trychroma.com/privacy", logo: ChromaLogo, }, pinecone: { name: "Pinecone", policyUrl: "https://www.pinecone.io/privacy/", logo: PineconeLogo, }, qdrant: { name: "Qdrant", policyUrl: "https://qdrant.tech/legal/privacy-policy/", logo: QDrantLogo, }, weaviate: { name: "Weaviate", policyUrl: "https://weaviate.io/privacy", logo: WeaviateLogo, }, milvus: { name: "Milvus", description: [ "Your vectors and document text are stored on your Milvus instance (cloud or self-hosted).", ], logo: MilvusLogo, }, zilliz: { name: "Zilliz Cloud", policyUrl: "https://zilliz.com/privacy-policy", logo: ZillizLogo, }, astra: { name: "AstraDB", policyUrl: "https://www.ibm.com/us-en/privacy", logo: AstraDBLogo, }, lancedb: { name: "LanceDB", description: [ "Your vectors and document text are stored privately on this instance of AnythingLLM.", ], logo: LanceDbLogo, }, }; const EMBEDDING_ENGINE_PROVIDER_PRIVACY_MAP = { native: { name: "AnythingLLM Embedder", description: [ "Your document text is embedded privately on this instance of AnythingLLM.", ], logo: AnythingLLMIcon, }, openai: { name: "OpenAI", policyUrl: "https://openai.com/policies/privacy-policy/", logo: OpenAiLogo, }, azure: { name: "Azure OpenAI", policyUrl: "https://privacy.microsoft.com/privacystatement", logo: AzureOpenAiLogo, }, localai: { name: "LocalAI", description: [ "Your document text is embedded privately on the server running LocalAI.", ], logo: LocalAiLogo, }, ollama: { name: "Ollama", description: [ "Your document text is embedded privately on the server running Ollama.", ], logo: OllamaLogo, }, lmstudio: { name: "LMStudio", description: [ "Your document text is embedded privately on the server running LMStudio.", ], logo: LMStudioLogo, }, openrouter: { name: "OpenRouter", policyUrl: "https://openrouter.ai/privacy", logo: OpenRouterLogo, }, cohere: { name: "Cohere", policyUrl: "https://cohere.com/privacy", logo: CohereLogo, }, voyageai: { name: "Voyage AI", policyUrl: "https://www.voyageai.com/privacy", logo: VoyageAiLogo, }, mistral: { name: "Mistral AI", policyUrl: "https://legal.mistral.ai/terms/privacy-policy", logo: MistralLogo, }, litellm: { name: "LiteLLM", description: [ "Your document text is only accessible on the server running LiteLLM and to the providers you configured in LiteLLM.", ], logo: LiteLLMLogo, }, "generic-openai": { name: "Generic OpenAI compatible service", description: [ "Data is shared according to the terms of service applicable with your generic endpoint provider.", ], logo: GenericOpenAiLogo, }, gemini: { name: "Google Gemini", policyUrl: "https://policies.google.com/privacy", logo: GeminiLogo, }, }; export const PROVIDER_PRIVACY_MAP = { llm: LLM_PROVIDER_PRIVACY_MAP, embeddingEngine: EMBEDDING_ENGINE_PROVIDER_PRIVACY_MAP, vectorDb: VECTOR_DB_PROVIDER_PRIVACY_MAP, };
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false
Mintplex-Labs/anything-llm
https://github.com/Mintplex-Labs/anything-llm/blob/e287fab56089cf8fcea9ba579a3ecdeca0daa313/frontend/src/components/WorkspaceChat/index.jsx
frontend/src/components/WorkspaceChat/index.jsx
import React, { useEffect, useState } from "react"; import Workspace from "@/models/workspace"; import LoadingChat from "./LoadingChat"; import ChatContainer from "./ChatContainer"; import paths from "@/utils/paths"; import ModalWrapper from "../ModalWrapper"; import { useParams } from "react-router-dom"; import { DnDFileUploaderProvider } from "./ChatContainer/DnDWrapper"; import { WarningCircle } from "@phosphor-icons/react"; import { TTSProvider, useWatchForAutoPlayAssistantTTSResponse, } from "../contexts/TTSProvider"; export default function WorkspaceChat({ loading, workspace }) { useWatchForAutoPlayAssistantTTSResponse(); const { threadSlug = null } = useParams(); const [history, setHistory] = useState([]); const [loadingHistory, setLoadingHistory] = useState(true); useEffect(() => { async function getHistory() { if (loading) return; if (!workspace?.slug) { setLoadingHistory(false); return false; } const chatHistory = threadSlug ? await Workspace.threads.chatHistory(workspace.slug, threadSlug) : await Workspace.chatHistory(workspace.slug); setHistory(chatHistory); setLoadingHistory(false); } getHistory(); }, [workspace, loading]); if (loadingHistory) return <LoadingChat />; if (!loading && !loadingHistory && !workspace) { return ( <> {loading === false && !workspace && ( <ModalWrapper isOpen={true}> <div className="w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border overflow-hidden"> <div className="relative p-6 border-b rounded-t border-theme-modal-border"> <div className="w-full flex gap-x-2 items-center"> <WarningCircle className="text-red-500 w-6 h-6" weight="fill" /> <h3 className="text-xl font-semibold text-red-500 overflow-hidden overflow-ellipsis whitespace-nowrap"> Workspace not found </h3> </div> </div> <div className="py-7 px-9 space-y-2 flex-col"> <p className="text-white text-sm"> The workspace you're looking for is not available. It may have been deleted or you may not have access to it. </p> </div> <div className="flex w-full justify-end items-center p-6 space-x-2 border-t border-theme-modal-border rounded-b"> <a href={paths.home()} className="transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm" > Return to homepage </a> </div> </div> </ModalWrapper> )} <LoadingChat /> </> ); } setEventDelegatorForCodeSnippets(); return ( <TTSProvider> <DnDFileUploaderProvider workspace={workspace} threadSlug={threadSlug}> <ChatContainer workspace={workspace} knownHistory={history} /> </DnDFileUploaderProvider> </TTSProvider> ); } // Enables us to safely markdown and sanitize all responses without risk of injection // but still be able to attach a handler to copy code snippets on all elements // that are code snippets. function copyCodeSnippet(uuid) { const target = document.querySelector(`[data-code="${uuid}"]`); if (!target) return false; const markdown = target.parentElement?.parentElement?.querySelector( "pre:first-of-type" )?.innerText; if (!markdown) return false; window.navigator.clipboard.writeText(markdown); target.classList.add("text-green-500"); const originalText = target.innerHTML; target.innerText = "Copied!"; target.setAttribute("disabled", true); setTimeout(() => { target.classList.remove("text-green-500"); target.innerHTML = originalText; target.removeAttribute("disabled"); }, 2500); } // Listens and hunts for all data-code-snippet clicks. export function setEventDelegatorForCodeSnippets() { document?.addEventListener("click", function (e) { const target = e.target.closest("[data-code-snippet]"); const uuidCode = target?.dataset?.code; if (!uuidCode) return false; copyCodeSnippet(uuidCode); }); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false