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/Admin/Agents/AgentFlows/index.jsx
frontend/src/pages/Admin/Agents/AgentFlows/index.jsx
import React from "react"; import { CaretRight } from "@phosphor-icons/react"; export default function AgentFlowsList({ flows = [], selectedFlow, handleClick, }) { if (flows.length === 0) { return ( <div className="text-theme-text-secondary text-center text-xs flex flex-col gap-y-2"> <p>No agent flows found</p> <a href="https://docs.anythingllm.com/agent-flows/getting-started" target="_blank" className="text-theme-text-secondary underline hover:text-cta-button" > Learn more about Agent Flows. </a> </div> ); } return ( <div className="bg-theme-bg-secondary text-white rounded-xl w-full md:min-w-[360px]"> {flows.map((flow, index) => ( <div key={flow.uuid} className={`py-3 px-4 flex items-center justify-between ${ index === 0 ? "rounded-t-xl" : "" } ${ index === flows.length - 1 ? "rounded-b-xl" : "border-b border-white/10" } cursor-pointer transition-all duration-300 hover:bg-theme-bg-primary ${ selectedFlow?.uuid === flow.uuid ? "bg-white/10 light:bg-theme-bg-sidebar" : "" }`} onClick={() => handleClick?.(flow)} > <div className="text-sm font-light">{flow.name}</div> <div className="flex items-center gap-x-2"> <div className="text-sm text-theme-text-secondary font-medium"> {flow.active ? "On" : "Off"} </div> <CaretRight size={14} weight="bold" className="text-theme-text-secondary" /> </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/Admin/Agents/AgentFlows/FlowPanel.jsx
frontend/src/pages/Admin/Agents/AgentFlows/FlowPanel.jsx
import React, { useState, useEffect, useRef } from "react"; import AgentFlows from "@/models/agentFlows"; import showToast from "@/utils/toast"; import { FlowArrow, Gear } from "@phosphor-icons/react"; import { useNavigate } from "react-router-dom"; import paths from "@/utils/paths"; function ManageFlowMenu({ flow, onDelete }) { const [open, setOpen] = useState(false); const menuRef = useRef(null); const navigate = useNavigate(); async function deleteFlow() { if ( !window.confirm( "Are you sure you want to delete this flow? This action cannot be undone." ) ) return; const { success, error } = await AgentFlows.deleteFlow(flow.uuid); if (success) { showToast("Flow deleted successfully.", "success"); onDelete(flow.uuid); } else { showToast(error || "Failed to delete flow.", "error"); } } useEffect(() => { const handleClickOutside = (event) => { if (menuRef.current && !menuRef.current.contains(event.target)) { setOpen(false); } }; document.addEventListener("mousedown", handleClickOutside); return () => { document.removeEventListener("mousedown", handleClickOutside); }; }, []); return ( <div className="relative" ref={menuRef}> <button type="button" onClick={() => setOpen(!open)} className="p-1.5 rounded-lg text-white hover:bg-theme-action-menu-item-hover transition-colors duration-300" > <Gear className="h-5 w-5" weight="bold" /> </button> {open && ( <div className="absolute w-[100px] -top-1 left-7 mt-1 border-[1.5px] border-white/40 rounded-lg bg-theme-action-menu-bg flex flex-col shadow-[0_4px_14px_rgba(0,0,0,0.25)] text-white z-99 md:z-10"> <button type="button" onClick={() => navigate(paths.agents.editAgent(flow.uuid))} className="border-none flex items-center rounded-lg gap-x-2 hover:bg-theme-action-menu-item-hover py-1.5 px-2 transition-colors duration-200 w-full text-left" > <span className="text-sm">Edit Flow</span> </button> <button type="button" onClick={deleteFlow} className="border-none flex items-center rounded-lg gap-x-2 hover:bg-theme-action-menu-item-hover py-1.5 px-2 transition-colors duration-200 w-full text-left" > <span className="text-sm">Delete Flow</span> </button> </div> )} </div> ); } export default function FlowPanel({ flow, toggleFlow, onDelete }) { const [isActive, setIsActive] = useState(flow.active); useEffect(() => { setIsActive(flow.active); }, [flow.uuid, flow.active]); const handleToggle = async () => { try { const { success, error } = await AgentFlows.toggleFlow( flow.uuid, !isActive ); if (!success) throw new Error(error); setIsActive(!isActive); toggleFlow(flow.uuid); showToast("Flow status updated successfully", "success", { clear: true }); } catch (error) { console.error("Failed to toggle flow:", error); showToast("Failed to toggle flow", "error", { clear: true }); } }; return ( <> <div className="p-2"> <div className="flex flex-col gap-y-[18px] max-w-[500px]"> <div className="flex items-center gap-x-2"> <FlowArrow size={24} weight="bold" className="text-white" /> <label htmlFor="name" className="text-white text-md font-bold"> {flow.name} </label> <label className="border-none relative inline-flex items-center ml-auto cursor-pointer"> <input type="checkbox" className="peer sr-only" checked={isActive} onChange={handleToggle} /> <div className="peer-disabled:opacity-50 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> <span className="ml-3 text-sm font-medium"></span> </label> <ManageFlowMenu flow={flow} onDelete={onDelete} /> </div> <p className="whitespace-pre-wrap text-white text-opacity-60 text-xs font-medium py-1.5"> {flow.description || "No description provided"} </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/Admin/Agents/WebSearchSelection/index.jsx
frontend/src/pages/Admin/Agents/WebSearchSelection/index.jsx
import React, { useEffect, useRef, useState } from "react"; import Admin from "@/models/admin"; import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png"; import GoogleSearchIcon from "./icons/google.png"; import SerpApiIcon from "./icons/serpapi.png"; import SearchApiIcon from "./icons/searchapi.png"; import SerperDotDevIcon from "./icons/serper.png"; import BingSearchIcon from "./icons/bing.png"; import SerplySearchIcon from "./icons/serply.png"; import SearXNGSearchIcon from "./icons/searxng.png"; import TavilySearchIcon from "./icons/tavily.svg"; import DuckDuckGoIcon from "./icons/duckduckgo.png"; import ExaIcon from "./icons/exa.png"; import { CaretUpDown, MagnifyingGlass, X, ListMagnifyingGlass, } from "@phosphor-icons/react"; import SearchProviderItem from "./SearchProviderItem"; import WebSearchImage from "@/media/agents/scrape-websites.png"; import { SerpApiOptions, SearchApiOptions, SerperDotDevOptions, GoogleSearchOptions, BingSearchOptions, SerplySearchOptions, SearXNGOptions, TavilySearchOptions, DuckDuckGoOptions, ExaSearchOptions, } from "./SearchProviderOptions"; const SEARCH_PROVIDERS = [ { name: "Please make a selection", value: "none", logo: AnythingLLMIcon, options: () => <React.Fragment />, description: "Web search will be disabled until a provider and keys are provided.", }, { name: "DuckDuckGo", value: "duckduckgo-engine", logo: DuckDuckGoIcon, options: () => <DuckDuckGoOptions />, description: "Free and privacy-focused web search using DuckDuckGo.", }, { name: "Google Search Engine", value: "google-search-engine", logo: GoogleSearchIcon, options: (settings) => <GoogleSearchOptions settings={settings} />, description: "Web search powered by a custom Google Search Engine.", }, { name: "SerpApi", value: "serpapi", logo: SerpApiIcon, options: (settings) => <SerpApiOptions settings={settings} />, description: "Scrape Google and several other search engines with SerpApi. 250 free searches every month, and then paid.", }, { name: "SearchApi", value: "searchapi", logo: SearchApiIcon, options: (settings) => <SearchApiOptions settings={settings} />, description: "SearchApi delivers structured data from multiple search engines. Free for 100 queries, but then paid. ", }, { name: "Serper.dev", value: "serper-dot-dev", logo: SerperDotDevIcon, options: (settings) => <SerperDotDevOptions settings={settings} />, description: "Serper.dev web-search. Free account with a 2,500 calls, but then paid.", }, { name: "Bing Search", value: "bing-search", logo: BingSearchIcon, options: (settings) => <BingSearchOptions settings={settings} />, description: "Web search powered by the Bing Search API (paid service).", }, { name: "Serply.io", value: "serply-engine", logo: SerplySearchIcon, options: (settings) => <SerplySearchOptions settings={settings} />, description: "Serply.io web-search. Free account with a 100 calls/month forever.", }, { name: "SearXNG", value: "searxng-engine", logo: SearXNGSearchIcon, options: (settings) => <SearXNGOptions settings={settings} />, description: "Free, open-source, internet meta-search engine with no tracking.", }, { name: "Tavily Search", value: "tavily-search", logo: TavilySearchIcon, options: (settings) => <TavilySearchOptions settings={settings} />, description: "Tavily Search API. Offers a free tier with 1000 queries per month.", }, { name: "Exa Search", value: "exa-search", logo: ExaIcon, options: (settings) => <ExaSearchOptions settings={settings} />, description: "AI-powered search engine optimized for LLM use cases.", }, ]; export default function AgentWebSearchSelection({ skill, settings, toggleSkill, enabled = false, setHasChanges, }) { const searchInputRef = useRef(null); const [filteredResults, setFilteredResults] = useState([]); const [selectedProvider, setSelectedProvider] = useState("none"); const [searchQuery, setSearchQuery] = useState(""); const [searchMenuOpen, setSearchMenuOpen] = useState(false); function updateChoice(selection) { setSearchQuery(""); setSelectedProvider(selection); setSearchMenuOpen(false); setHasChanges(true); } function handleXButton() { if (searchQuery.length > 0) { setSearchQuery(""); if (searchInputRef.current) searchInputRef.current.value = ""; } else { setSearchMenuOpen(!searchMenuOpen); } } useEffect(() => { const filtered = SEARCH_PROVIDERS.filter((provider) => provider.name.toLowerCase().includes(searchQuery.toLowerCase()) ); setFilteredResults(filtered); }, [searchQuery, selectedProvider]); useEffect(() => { Admin.systemPreferencesByFields(["agent_search_provider"]) .then((res) => setSelectedProvider(res?.settings?.agent_search_provider ?? "none") ) .catch(() => setSelectedProvider("none")); }, []); const selectedSearchProviderObject = SEARCH_PROVIDERS.find( (provider) => provider.value === selectedProvider ); return ( <div className="p-2"> <div className="flex flex-col gap-y-[18px] max-w-[500px]"> <div className="flex items-center gap-x-2"> <ListMagnifyingGlass size={24} color="var(--theme-text-primary)" weight="bold" /> <label htmlFor="name" className="text-theme-text-primary text-md font-bold" > Live web search and browsing </label> <label className="border-none relative inline-flex items-center ml-auto cursor-pointer"> <input type="checkbox" className="peer sr-only" checked={enabled} onChange={() => toggleSkill(skill)} /> <div className="peer-disabled:opacity-50 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> <span className="ml-3 text-sm font-medium"></span> </label> </div> <img src={WebSearchImage} alt="Web Search" className="w-full rounded-md" /> <p className="text-theme-text-secondary text-opacity-60 text-xs font-medium py-1.5"> Enable your agent to search the web to answer your questions by connecting to a web-search (SERP) provider. Web search during agent sessions will not work until this is set up. </p> <div hidden={!enabled}> <div className="relative"> <input type="hidden" name="system::agent_search_provider" value={selectedProvider} /> {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="web-provider-search" autoComplete="off" placeholder="Search available web-search 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-white 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]"> {filteredResults.map((provider) => { return ( <SearchProviderItem provider={provider} key={provider.name} checked={selectedProvider === provider.value} onClick={() => updateChoice(provider.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={selectedSearchProviderObject.logo} alt={`${selectedSearchProviderObject.name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col text-left"> <div className="text-sm font-semibold text-white"> {selectedSearchProviderObject.name} </div> <div className="mt-1 text-xs text-description"> {selectedSearchProviderObject.description} </div> </div> </div> <CaretUpDown size={24} weight="bold" className="text-white" /> </button> )} </div> {selectedProvider !== "none" && ( <div className="mt-4 flex flex-col gap-y-1"> {selectedSearchProviderObject.options(settings)} </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/pages/Admin/Agents/WebSearchSelection/SearchProviderItem/index.jsx
frontend/src/pages/Admin/Agents/WebSearchSelection/SearchProviderItem/index.jsx
export default function SearchProviderItem({ provider, checked, onClick }) { const { name, value, logo, description } = provider; return ( <div onClick={onClick} 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={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-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/pages/Admin/Agents/WebSearchSelection/SearchProviderOptions/index.jsx
frontend/src/pages/Admin/Agents/WebSearchSelection/SearchProviderOptions/index.jsx
export function GoogleSearchOptions({ settings }) { return ( <> <p className="text-sm text-white/60 my-2"> You can get a free search engine & API key{" "} <a href="https://programmablesearchengine.google.com/controlpanel/create" target="_blank" rel="noreferrer" className="text-blue-300 underline" > from Google here. </a> </p> <div className="flex gap-x-4"> <div className="flex flex-col w-60"> <label className="text-white text-sm font-semibold block mb-3"> Search engine ID </label> <input type="text" name="env::AgentGoogleSearchEngineId" 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 Search Engine Id" defaultValue={settings?.AgentGoogleSearchEngineId} 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"> Programmatic Access API Key </label> <input type="password" name="env::AgentGoogleSearchEngineKey" 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 Search Engine API Key" defaultValue={ settings?.AgentGoogleSearchEngineKey ? "*".repeat(20) : "" } required={true} autoComplete="off" spellCheck={false} /> </div> </div> </> ); } const SerpApiEngines = [ { name: "Google Search", value: "google" }, { name: "Google Images", value: "google_images_light" }, { name: "Google Jobs", value: "google_jobs" }, { name: "Google Maps", value: "google_maps" }, { name: "Google News", value: "google_news_light" }, { name: "Google Patents", value: "google_patents" }, { name: "Google Scholar", value: "google_scholar" }, { name: "Google Shopping", value: "google_shopping_light" }, { name: "Amazon", value: "amazon" }, { name: "Baidu", value: "baidu" }, ]; export function SerpApiOptions({ settings }) { return ( <> <p className="text-sm text-white/60 my-2"> Get a free API key{" "} <a href="https://serpapi.com/" target="_blank" rel="noreferrer" className="text-blue-300 underline" > from SerpApi. </a> </p> <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="env::AgentSerpApiKey" 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="SerpApi API Key" defaultValue={settings?.AgentSerpApiKey ? "*".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"> Engine </label> <select name="env::AgentSerpApiEngine" 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" defaultValue={settings?.AgentSerpApiEngine || "google"} > {SerpApiEngines.map(({ name, value }) => ( <option key={name} value={value}> {name} </option> ))} </select> {/* <input type="text" name="env::AgentSerpApiEngine" 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="SerpApi engine (Google, Amazon...)" defaultValue={settings?.AgentSerpApiEngine || "google"} required={true} autoComplete="off" spellCheck={false} /> */} </div> </div> </> ); } const SearchApiEngines = [ { name: "Google Search", value: "google" }, { name: "Google Maps", value: "google_maps" }, { name: "Google Shopping", value: "google_shopping" }, { name: "Google News", value: "google_news" }, { name: "Google Jobs", value: "google_jobs" }, { name: "Google Scholar", value: "google_scholar" }, { name: "Google Finance", value: "google_finance" }, { name: "Google Patents", value: "google_patents" }, { name: "YouTube", value: "youtube" }, { name: "Bing", value: "bing" }, { name: "Bing News", value: "bing_news" }, { name: "Amazon Product Search", value: "amazon_search" }, { name: "Baidu", value: "baidu" }, ]; export function SearchApiOptions({ settings }) { return ( <> <p className="text-sm text-white/60 my-2"> You can get a free API key{" "} <a href="https://www.searchapi.io/" target="_blank" rel="noreferrer" className="text-blue-300 underline" > from SearchApi. </a> </p> <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="env::AgentSearchApiKey" 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="SearchApi API Key" defaultValue={settings?.AgentSearchApiKey ? "*".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"> Engine </label> <select name="env::AgentSearchApiEngine" 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" defaultValue={settings?.AgentSearchApiEngine || "google"} > {SearchApiEngines.map(({ name, value }) => ( <option key={name} value={value}> {name} </option> ))} </select> {/* <input type="text" name="env::AgentSearchApiEngine" 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="SearchApi engine (Google, Bing...)" defaultValue={settings?.AgentSearchApiEngine || "google"} required={true} autoComplete="off" spellCheck={false} /> */} </div> </div> </> ); } export function SerperDotDevOptions({ settings }) { return ( <> <p className="text-sm text-white/60 my-2"> You can get a free API key{" "} <a href="https://serper.dev" target="_blank" rel="noreferrer" className="text-blue-300 underline" > from Serper.dev. </a> </p> <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="env::AgentSerperApiKey" 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="Serper.dev API Key" defaultValue={settings?.AgentSerperApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> </div> </> ); } export function BingSearchOptions({ settings }) { return ( <> <p className="text-sm text-white/60 my-2"> You can get a Bing Web Search API subscription key{" "} <a href="https://portal.azure.com/" target="_blank" rel="noreferrer" className="text-blue-300 underline" > from the Azure portal. </a> </p> <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="env::AgentBingSearchApiKey" 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="Bing Web Search API Key" defaultValue={settings?.AgentBingSearchApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> </div> <p className="text-sm text-white/60 my-2"> To set up a Bing Web Search API subscription: </p> <ol className="list-decimal text-sm text-white/60 ml-6"> <li> Go to the Azure portal:{" "} <a href="https://portal.azure.com/" target="_blank" rel="noreferrer" className="text-blue-300 underline" > https://portal.azure.com/ </a> </li> <li>Create a new Azure account or sign in with an existing one.</li> <li> Navigate to the "Create a resource" section and search for "Grounding with Bing Search". </li> <li> Select the "Grounding with Bing Search" resource and create a new subscription. </li> <li>Choose the pricing tier that suits your needs.</li> <li> Obtain the API key for your Grounding with Bing Search subscription. </li> </ol> </> ); } export function SerplySearchOptions({ settings }) { return ( <> <p className="text-sm text-white/60 my-2"> You can get a free API key{" "} <a href="https://serply.io" target="_blank" rel="noreferrer" className="text-blue-300 underline" > from Serply.io. </a> </p> <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="env::AgentSerplyApiKey" 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="Serply API Key" defaultValue={settings?.AgentSerplyApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> </div> </> ); } export function SearXNGOptions({ settings }) { 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"> SearXNG API Base URL </label> <input type="url" name="env::AgentSearXNGApiUrl" 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="SearXNG API Base URL" defaultValue={settings?.AgentSearXNGApiUrl} required={true} autoComplete="off" spellCheck={false} /> </div> </div> ); } export function TavilySearchOptions({ settings }) { return ( <> <p className="text-sm text-white/60 my-2"> You can get an API key{" "} <a href="https://tavily.com/" target="_blank" rel="noreferrer" className="text-blue-300 underline" > from Tavily. </a> </p> <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="env::AgentTavilyApiKey" 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="Tavily API Key" defaultValue={settings?.AgentTavilyApiKey ? "*".repeat(20) : ""} required={true} autoComplete="off" spellCheck={false} /> </div> </div> </> ); } export function DuckDuckGoOptions() { return ( <> <p className="text-sm text-white/60 my-2"> DuckDuckGo is ready to use without any additional configuration. </p> </> ); } export function ExaSearchOptions({ settings }) { return ( <> <p className="text-sm text-white/60 my-2"> You can get an API key{" "} <a href="https://exa.ai" target="_blank" rel="noreferrer" className="text-blue-300 underline" > from Exa. </a> </p> <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="env::AgentExaApiKey" 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="Exa API Key" defaultValue={settings?.AgentExaApiKey ? "*".repeat(20) : ""} required={true} 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/pages/Admin/Invitations/index.jsx
frontend/src/pages/Admin/Invitations/index.jsx
import { useEffect, useState } from "react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; import { EnvelopeSimple } from "@phosphor-icons/react"; import Admin from "@/models/admin"; import InviteRow from "./InviteRow"; import NewInviteModal from "./NewInviteModal"; import { useModal } from "@/hooks/useModal"; import ModalWrapper from "@/components/ModalWrapper"; import CTAButton from "@/components/lib/CTAButton"; export default function AdminInvites() { const { isOpen, openModal, closeModal } = useModal(); const [loading, setLoading] = useState(true); const [invites, setInvites] = useState([]); const fetchInvites = async () => { const _invites = await Admin.invites(); setInvites(_invites); setLoading(false); }; useEffect(() => { fetchInvites(); }, []); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2"> <div className="items-center flex gap-x-4"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> Invitations </p> </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary mt-2"> Create invitation links for people in your organization to accept and sign up with. Invitations can only be used by a single user. </p> </div> <div className="w-full justify-end flex"> <CTAButton onClick={openModal} className="mt-3 mr-0 mb-4 md:-mb-12 z-10" > <EnvelopeSimple className="h-4 w-4" weight="bold" /> Create Invite Link </CTAButton> </div> <div className="overflow-x-auto mt-6"> {loading ? ( <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" containerClassName="flex w-full" /> ) : ( <table className="w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0"> <thead className="text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b"> <tr> <th scope="col" className="px-6 py-3 rounded-tl-lg"> Status </th> <th scope="col" className="px-6 py-3"> Accepted By </th> <th scope="col" className="px-6 py-3"> Created By </th> <th scope="col" className="px-6 py-3"> Created </th> <th scope="col" className="px-6 py-3 rounded-tr-lg"> {" "} </th> </tr> </thead> <tbody> {invites.length === 0 ? ( <tr className="bg-transparent text-theme-text-secondary text-sm font-medium"> <td colSpan="5" className="px-6 py-4 text-center"> No invitations found </td> </tr> ) : ( invites.map((invite) => ( <InviteRow key={invite.id} invite={invite} /> )) )} </tbody> </table> )} </div> </div> <ModalWrapper isOpen={isOpen}> <NewInviteModal closeModal={closeModal} onSuccess={fetchInvites} /> </ModalWrapper> </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/Admin/Invitations/InviteRow/index.jsx
frontend/src/pages/Admin/Invitations/InviteRow/index.jsx
import { useEffect, useRef, useState } from "react"; import { titleCase } from "text-case"; import Admin from "@/models/admin"; import { Trash } from "@phosphor-icons/react"; export default function InviteRow({ invite }) { const rowRef = useRef(null); const [status, setStatus] = useState(invite.status); const [copied, setCopied] = useState(false); const handleDelete = async () => { if ( !window.confirm( `Are you sure you want to deactivate this invite?\nAfter you do this it will not longer be useable.\n\nThis action is irreversible.` ) ) return false; if (rowRef?.current) { rowRef.current.children[0].innerText = "Disabled"; } setStatus("disabled"); await Admin.disableInvite(invite.id); }; const copyInviteLink = () => { if (!invite) return false; window.navigator.clipboard.writeText( `${window.location.origin}/accept-invite/${invite.code}` ); setCopied(true); }; useEffect(() => { function resetStatus() { if (!copied) return false; setTimeout(() => { setCopied(false); }, 3000); } resetStatus(); }, [copied]); return ( <> <tr ref={rowRef} className="bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10" > <td scope="row" className="px-6 whitespace-nowrap"> {titleCase(status)} </td> <td className="px-6"> {invite.claimedBy ? invite.claimedBy?.username || "deleted user" : "--"} </td> <td className="px-6">{invite.createdBy?.username || "deleted user"}</td> <td className="px-6">{invite.createdAt}</td> <td className="px-6 flex items-center gap-x-6 h-full mt-1"> {status === "pending" && ( <> <button onClick={copyInviteLink} disabled={copied} className="text-xs font-medium text-blue-300 rounded-lg hover:text-blue-400 hover:underline" > {copied ? "Copied" : "Copy Invite Link"} </button> <button onClick={handleDelete} className="text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10" > <Trash className="h-5 w-5" /> </button> </> )} </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/Admin/Invitations/NewInviteModal/index.jsx
frontend/src/pages/Admin/Invitations/NewInviteModal/index.jsx
import React, { useEffect, useState } from "react"; import { X, Copy, Check } from "@phosphor-icons/react"; import Admin from "@/models/admin"; import Workspace from "@/models/workspace"; import showToast from "@/utils/toast"; export default function NewInviteModal({ closeModal, onSuccess }) { const [invite, setInvite] = useState(null); const [error, setError] = useState(null); const [copied, setCopied] = useState(false); const [workspaces, setWorkspaces] = useState([]); const [selectedWorkspaceIds, setSelectedWorkspaceIds] = useState([]); const handleCreate = async (e) => { setError(null); e.preventDefault(); const { invite: newInvite, error } = await Admin.newInvite({ role: null, workspaceIds: selectedWorkspaceIds, }); if (!!newInvite) { setInvite(newInvite); onSuccess(); } setError(error); }; const copyInviteLink = () => { if (!invite) return false; window.navigator.clipboard.writeText( `${window.location.origin}/accept-invite/${invite.code}` ); setCopied(true); showToast("Invite link copied to clipboard", "success", { clear: true, }); }; const handleWorkspaceSelection = (workspaceId) => { if (selectedWorkspaceIds.includes(workspaceId)) { const updated = selectedWorkspaceIds.filter((id) => id !== workspaceId); setSelectedWorkspaceIds(updated); return; } setSelectedWorkspaceIds([...selectedWorkspaceIds, workspaceId]); }; useEffect(() => { function resetStatus() { if (!copied) return false; setTimeout(() => { setCopied(false); }, 3000); } resetStatus(); }, [copied]); useEffect(() => { async function fetchWorkspaces() { Workspace.all() .then((workspaces) => setWorkspaces(workspaces)) .catch(() => setWorkspaces([])); } fetchWorkspaces(); }, []); return ( <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"> Create new invite </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> <div className="p-6"> <form onSubmit={handleCreate}> <div className="space-y-4"> {error && <p className="text-red-400 text-sm">Error: {error}</p>} {invite && ( <div className="relative"> <input type="url" defaultValue={`${window.location.origin}/accept-invite/${invite.code}`} disabled={true} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg outline-none block w-full p-2.5 pr-10" /> <button type="button" onClick={copyInviteLink} disabled={copied} className="absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded-md hover:bg-theme-modal-border transition-all duration-300" > {copied ? ( <Check size={20} className="text-green-400" weight="bold" /> ) : ( <Copy size={20} className="text-white" weight="bold" /> )} </button> </div> )} <p className="text-white text-opacity-60 text-xs md:text-sm"> After creation you will be able to copy the invite and send it to a new user where they can create an account as the{" "} <b>default</b> role and automatically be added to workspaces selected. </p> </div> {workspaces.length > 0 && !invite && ( <div className="mt-6"> <div className="w-full"> <div className="flex flex-col gap-y-1 mb-2"> <label htmlFor="workspaces" className="block text-sm font-medium text-white" > Auto-add invitee to workspaces </label> <p className="text-white text-opacity-60 text-xs"> You can optionally automatically assign the user to the workspaces below by selecting them. By default, the user will not have any workspaces visible. You can assign workspaces later post-invite acceptance. </p> </div> <div className="flex flex-col gap-y-2 mt-2"> {workspaces.map((workspace) => ( <WorkspaceOption key={workspace.id} workspace={workspace} selected={selectedWorkspaceIds.includes(workspace.id)} toggleSelection={handleWorkspaceSelection} /> ))} </div> </div> </div> )} <div className="flex justify-end items-center mt-6 pt-6 border-t border-theme-modal-border"> {!invite ? ( <> <button onClick={closeModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm mr-2" > 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" > Create Invite </button> </> ) : ( <button onClick={closeModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > Close </button> )} </div> </form> </div> </div> </div> ); } function WorkspaceOption({ workspace, selected, toggleSelection }) { return ( <button type="button" onClick={() => toggleSelection(workspace.id)} className={`transition-all duration-300 w-full h-11 p-2.5 rounded-lg flex justify-start items-center gap-2.5 cursor-pointer border ${ selected ? "border-theme-sidebar-item-workspace-active bg-theme-bg-secondary" : "border-theme-sidebar-border" } hover:border-theme-sidebar-border hover:bg-theme-bg-secondary`} > <input type="radio" name="workspace" value={workspace.id} checked={selected} className="hidden" /> <div className={`w-4 h-4 rounded-full border-2 border-theme-sidebar-border mr-2 ${ selected ? "bg-[var(--theme-sidebar-item-workspace-active)]" : "" }`} ></div> <div className="text-theme-text-primary text-sm font-medium font-['Plus Jakarta Sans'] leading-tight"> {workspace.name} </div> </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/Admin/SystemPromptVariables/index.jsx
frontend/src/pages/Admin/SystemPromptVariables/index.jsx
import React, { useState, useEffect } from "react"; import System from "@/models/system"; import showToast from "@/utils/toast"; import { Plus } from "@phosphor-icons/react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import CTAButton from "@/components/lib/CTAButton"; import VariableRow from "./VariableRow"; import ModalWrapper from "@/components/ModalWrapper"; import AddVariableModal from "./AddVariableModal"; import { useModal } from "@/hooks/useModal"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; export default function SystemPromptVariables() { const [variables, setVariables] = useState([]); const [loading, setLoading] = useState(true); const { isOpen, openModal, closeModal } = useModal(); useEffect(() => { fetchVariables(); }, []); const fetchVariables = async () => { setLoading(true); try { const { variables } = await System.promptVariables.getAll(); setVariables(variables || []); } catch (error) { console.error("Error fetching variables:", error); showToast("No variables found", "error"); } finally { setLoading(false); } }; return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2"> <div className="items-center flex gap-x-4"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> System Prompt Variables </p> </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary"> System prompt variables are used to store configuration values that can be referenced in your system prompt to enable dynamic content in your prompts. </p> </div> <div className="w-full justify-end flex"> <CTAButton onClick={openModal} className="mt-3 mr-0 mb-4 md:-mb-6 z-10" > <Plus className="h-4 w-4" weight="bold" /> Add Variable </CTAButton> </div> <div className="overflow-x-auto"> {loading ? ( <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-8" containerClassName="flex w-full" /> ) : variables.length === 0 ? ( <div className="text-center py-4 text-theme-text-secondary"> No variables found </div> ) : ( <table className="w-full text-sm text-left rounded-lg min-w-[640px] border-spacing-0"> <thead className="text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b"> <tr> <th scope="col" className="px-4 py-2 rounded-tl-lg"> Key </th> <th scope="col" className="px-4 py-2"> Value </th> <th scope="col" className="px-4 py-2"> Description </th> <th scope="col" className="px-4 py-2"> Type </th> </tr> </thead> <tbody> {variables.map((variable) => ( <VariableRow key={variable.id} variable={variable} onRefresh={fetchVariables} /> ))} </tbody> </table> )} </div> </div> </div> <ModalWrapper isOpen={isOpen}> <AddVariableModal closeModal={closeModal} onRefresh={fetchVariables} /> </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/Admin/SystemPromptVariables/AddVariableModal/index.jsx
frontend/src/pages/Admin/SystemPromptVariables/AddVariableModal/index.jsx
import React, { useState } from "react"; import { X } from "@phosphor-icons/react"; import System from "@/models/system"; import showToast from "@/utils/toast"; export default function AddVariableModal({ closeModal, onRefresh }) { const [error, setError] = useState(null); const handleCreate = async (e) => { e.preventDefault(); setError(null); const formData = new FormData(e.target); const newVariable = {}; for (const [key, value] of formData.entries()) newVariable[key] = value.trim(); if (!newVariable.key || !newVariable.value) { setError("Key and value are required"); return; } try { await System.promptVariables.create(newVariable); showToast("Variable created successfully", "success", { clear: true }); if (onRefresh) onRefresh(); closeModal(); } catch (error) { console.error("Error creating variable:", error); setError("Failed to create variable"); } }; return ( <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"> Add New Variable </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> <div className="p-6"> <form onSubmit={handleCreate}> <div className="space-y-4"> <div> <label htmlFor="key" className="block mb-2 text-sm font-medium text-white" > Key </label> <input name="key" type="text" minLength={3} maxLength={255} className="border-none bg-theme-settings-input-bg w-full 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="e.g., company_name" required={true} autoComplete="off" pattern="^[a-zA-Z0-9_]+$" /> <p className="mt-2 text-xs text-white/60"> Key must be unique and will be used in prompts as {"{key}"}. Only letters, numbers and underscores are allowed. </p> </div> <div> <label htmlFor="value" className="block mb-2 text-sm font-medium text-white" > Value </label> <input name="value" type="text" className="border-none bg-theme-settings-input-bg w-full 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="e.g., Acme Corp" required={true} autoComplete="off" /> </div> <div> <label htmlFor="description" className="block mb-2 text-sm font-medium text-white" > Description </label> <input name="description" type="text" className="border-none bg-theme-settings-input-bg w-full 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="Optional description" autoComplete="off" /> </div> {error && <p className="text-red-400 text-sm">Error: {error}</p>} </div> <div className="flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border"> <button onClick={closeModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > 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" > Create variable </button> </div> </form> </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/Admin/SystemPromptVariables/VariableRow/index.jsx
frontend/src/pages/Admin/SystemPromptVariables/VariableRow/index.jsx
import { useRef } from "react"; import System from "@/models/system"; import showToast from "@/utils/toast"; import { useModal } from "@/hooks/useModal"; import ModalWrapper from "@/components/ModalWrapper"; import EditVariableModal from "./EditVariableModal"; import { titleCase } from "text-case"; import truncate from "truncate"; import { Trash } from "@phosphor-icons/react"; /** * A row component for displaying a system prompt variable * @param {{id: number|null, key: string, value: string, description: string, type: string}} variable - The system prompt variable to display * @param {Function} onRefresh - A function to call when the variable is refreshed * @returns {JSX.Element} A JSX element for displaying the variable */ export default function VariableRow({ variable, onRefresh }) { const rowRef = useRef(null); const { isOpen, openModal, closeModal } = useModal(); const handleDelete = async () => { if (!variable.id) return; if ( !window.confirm( `Are you sure you want to delete the variable "${variable.key}"?\nThis action is irreversible.` ) ) return false; try { await System.promptVariables.delete(variable.id); rowRef?.current?.remove(); showToast("Variable deleted successfully", "success", { clear: true }); if (onRefresh) onRefresh(); } catch (error) { console.error("Error deleting variable:", error); showToast("Failed to delete variable", "error", { clear: true }); } }; const getTypeColorTheme = (type) => { switch (type) { case "system": return { bg: "bg-blue-600/20", text: "text-blue-400 light:text-blue-800", }; case "user": return { bg: "bg-green-600/20", text: "text-green-400 light:text-green-800", }; case "workspace": return { bg: "bg-cyan-600/20", text: "text-cyan-400 light:text-cyan-800", }; default: return { bg: "bg-yellow-600/20", text: "text-yellow-400 light:text-yellow-800", }; } }; const colorTheme = getTypeColorTheme(variable.type); return ( <> <tr ref={rowRef} className="bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10" > <th scope="row" className="px-4 py-2 whitespace-nowrap"> {variable.key} </th> <td className="px-4 py-2"> {typeof variable.value === "function" ? variable.value() : truncate(variable.value, 50)} </td> <td className="px-4 py-2"> {truncate(variable.description || "-", 50)} </td> <td className="px-4 py-2"> <span className={`rounded-full ${colorTheme.bg} px-2 py-0.5 text-xs leading-5 font-semibold ${colorTheme.text} shadow-sm`} > {titleCase(variable?.type ?? "static")} </span> </td> <td className="px-4 py-2 flex items-center justify-end gap-x-4"> {variable.type === "static" && ( <> <button onClick={openModal} className="text-xs font-medium text-white/80 light:text-black/80 rounded-lg hover:text-white hover:light:text-gray-500 px-2 py-1 hover:bg-white hover:bg-opacity-10" > Edit </button> <button onClick={handleDelete} className="text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10" > <Trash className="h-4 w-4" /> </button> </> )} </td> </tr> <ModalWrapper isOpen={isOpen}> <EditVariableModal variable={variable} closeModal={closeModal} onRefresh={onRefresh} /> </ModalWrapper> </> ); }
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/Admin/SystemPromptVariables/VariableRow/EditVariableModal/index.jsx
frontend/src/pages/Admin/SystemPromptVariables/VariableRow/EditVariableModal/index.jsx
import React, { useState } from "react"; import { X } from "@phosphor-icons/react"; import System from "@/models/system"; import showToast from "@/utils/toast"; export default function EditVariableModal({ variable, closeModal, onRefresh }) { const [error, setError] = useState(null); const handleUpdate = async (e) => { if (!variable.id) return; e.preventDefault(); setError(null); const formData = new FormData(e.target); const updatedVariable = {}; for (const [key, value] of formData.entries()) updatedVariable[key] = value.trim(); if (!updatedVariable.key || !updatedVariable.value) { setError("Key and value are required"); return; } try { await System.promptVariables.update(variable.id, updatedVariable); showToast("Variable updated successfully", "success", { clear: true }); if (onRefresh) onRefresh(); closeModal(); } catch (error) { console.error("Error updating variable:", error); setError("Failed to update variable"); } }; return ( <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"> Edit {variable.key} </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> <div className="p-6"> <form onSubmit={handleUpdate}> <div className="space-y-4"> <div> <label htmlFor="key" className="block mb-2 text-sm font-medium text-white" > Key </label> <input name="key" minLength={3} maxLength={255} type="text" className="border-none bg-theme-settings-input-bg w-full 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="e.g., company_name" defaultValue={variable.key} required={true} autoComplete="off" pattern="^[a-zA-Z0-9_]+$" /> <p className="mt-2 text-xs text-white/60"> Key must be unique and will be used in prompts as {"{key}"}. Only letters, numbers and underscores are allowed. </p> </div> <div> <label htmlFor="value" className="block mb-2 text-sm font-medium text-white" > Value </label> <input name="value" type="text" className="border-none bg-theme-settings-input-bg w-full 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="e.g., Acme Corp" defaultValue={variable.value} required={true} autoComplete="off" /> </div> <div> <label htmlFor="description" className="block mb-2 text-sm font-medium text-white" > Description </label> <input name="description" type="text" className="border-none bg-theme-settings-input-bg w-full 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="Optional description" defaultValue={variable.description} autoComplete="off" /> </div> {error && <p className="text-red-400 text-sm">Error: {error}</p>} </div> <div className="flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border"> <button onClick={closeModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > 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" > Update variable </button> </div> </form> </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/OnboardingFlow/index.jsx
frontend/src/pages/OnboardingFlow/index.jsx
import React from "react"; import OnboardingSteps, { OnboardingLayout } from "./Steps"; import { useParams } from "react-router-dom"; export default function OnboardingFlow() { const { step } = useParams(); const StepPage = OnboardingSteps[step || "home"]; if (step === "home" || !step) return <StepPage />; return ( <OnboardingLayout> {(setHeader, setBackBtn, setForwardBtn) => ( <StepPage setHeader={setHeader} setBackBtn={setBackBtn} setForwardBtn={setForwardBtn} /> )} </OnboardingLayout> ); }
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/OnboardingFlow/Steps/index.jsx
frontend/src/pages/OnboardingFlow/Steps/index.jsx
import { ArrowLeft, ArrowRight } from "@phosphor-icons/react"; import { useState } from "react"; import { isMobile } from "react-device-detect"; import Home from "./Home"; import LLMPreference from "./LLMPreference"; import UserSetup from "./UserSetup"; import DataHandling from "./DataHandling"; import Survey from "./Survey"; import CreateWorkspace from "./CreateWorkspace"; const OnboardingSteps = { home: Home, "llm-preference": LLMPreference, "user-setup": UserSetup, "data-handling": DataHandling, survey: Survey, "create-workspace": CreateWorkspace, }; export default OnboardingSteps; export function OnboardingLayout({ children }) { const [header, setHeader] = useState({ title: "", description: "", }); const [backBtn, setBackBtn] = useState({ showing: false, disabled: true, onClick: () => null, }); const [forwardBtn, setForwardBtn] = useState({ showing: false, disabled: true, onClick: () => null, }); if (isMobile) { return ( <div data-layout="onboarding" className="w-screen h-screen overflow-y-auto bg-theme-bg-primary overflow-hidden" > <div className="flex flex-col"> <div className="w-full relative py-10 px-2"> <div className="flex flex-col w-fit mx-auto gap-y-1 mb-[55px]"> <h1 className="text-theme-text-primary font-semibold text-center text-2xl"> {header.title} </h1> <p className="text-theme-text-secondary text-base text-center"> {header.description} </p> </div> {children(setHeader, setBackBtn, setForwardBtn)} </div> <div className="flex w-full justify-center gap-x-4 pb-20"> <div className="flex justify-center items-center"> {backBtn.showing && ( <button disabled={backBtn.disabled} onClick={backBtn.onClick} className="group p-2 rounded-lg border-2 border-zinc-300 disabled:border-zinc-600 h-fit w-fit disabled:not-allowed hover:bg-zinc-100 disabled:hover:bg-transparent" > <ArrowLeft className="text-white group-hover:text-black group-disabled:text-gray-500" size={30} /> </button> )} </div> <div className="flex justify-center items-center"> {forwardBtn.showing && ( <button disabled={forwardBtn.disabled} onClick={forwardBtn.onClick} className="group p-2 rounded-lg border-2 border-zinc-300 disabled:border-zinc-600 h-fit w-fit disabled:not-allowed hover:bg-teal disabled:hover:bg-transparent" > <ArrowRight className="text-white group-hover:text-teal group-disabled:text-gray-500" size={30} /> </button> )} </div> </div> </div> </div> ); } return ( <div data-layout="onboarding" className="w-screen overflow-y-auto bg-theme-bg-primary flex justify-center overflow-hidden" > <div className="flex w-1/5 h-screen justify-center items-center"> {backBtn.showing && ( <button disabled={backBtn.disabled} onClick={backBtn.onClick} className="group p-2 rounded-lg border-2 border-theme-sidebar-border h-fit w-fit disabled:cursor-not-allowed hover:bg-theme-bg-secondary disabled:hover:bg-transparent" aria-label="Back" > <ArrowLeft className="text-theme-text-secondary group-hover:text-theme-text-primary group-disabled:text-gray-500" size={30} /> </button> )} </div> <div className="w-full md:w-3/5 relative h-full py-10"> <div className="flex flex-col w-fit mx-auto gap-y-1 mb-[55px]"> <h1 className="text-theme-text-primary font-semibold text-center text-2xl"> {header.title} </h1> <p className="text-theme-text-secondary text-base text-center"> {header.description} </p> </div> {children(setHeader, setBackBtn, setForwardBtn)} </div> <div className="flex w-1/5 h-screen justify-center items-center"> {forwardBtn.showing && ( <button disabled={forwardBtn.disabled} onClick={forwardBtn.onClick} className="group p-2 rounded-lg border-2 border-theme-sidebar-border h-fit w-fit disabled:cursor-not-allowed hover:bg-teal disabled:hover:bg-transparent" aria-label="Continue" > <ArrowRight className="text-theme-text-secondary group-hover:text-white group-disabled:text-gray-500" size={30} /> </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/OnboardingFlow/Steps/UserSetup/index.jsx
frontend/src/pages/OnboardingFlow/Steps/UserSetup/index.jsx
import System from "@/models/system"; import showToast from "@/utils/toast"; import React, { useState, useEffect, useRef } from "react"; import debounce from "lodash.debounce"; import paths from "@/utils/paths"; import { useNavigate } from "react-router-dom"; import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "@/utils/constants"; import { useTranslation } from "react-i18next"; export default function UserSetup({ setHeader, setForwardBtn, setBackBtn }) { const { t } = useTranslation(); const [selectedOption, setSelectedOption] = useState(""); const [singleUserPasswordValid, setSingleUserPasswordValid] = useState(false); const [multiUserLoginValid, setMultiUserLoginValid] = useState(false); const [enablePassword, setEnablePassword] = useState(false); const myTeamSubmitRef = useRef(null); const justMeSubmitRef = useRef(null); const navigate = useNavigate(); const TITLE = t("onboarding.userSetup.title"); const DESCRIPTION = t("onboarding.userSetup.description"); function handleForward() { if (selectedOption === "just_me" && enablePassword) { justMeSubmitRef.current?.click(); } else if (selectedOption === "just_me" && !enablePassword) { navigate(paths.onboarding.dataHandling()); } else if (selectedOption === "my_team") { myTeamSubmitRef.current?.click(); } } function handleBack() { navigate(paths.onboarding.llmPreference()); } useEffect(() => { let isDisabled = true; if (selectedOption === "just_me") { isDisabled = !singleUserPasswordValid; } else if (selectedOption === "my_team") { isDisabled = !multiUserLoginValid; } setForwardBtn({ showing: true, disabled: isDisabled, onClick: handleForward, }); }, [selectedOption, singleUserPasswordValid, multiUserLoginValid]); useEffect(() => { setHeader({ title: TITLE, description: DESCRIPTION }); setBackBtn({ showing: true, disabled: false, onClick: handleBack }); }, []); return ( <div className="w-full flex items-center justify-center flex-col gap-y-6"> <div className="flex flex-col border rounded-lg border-white/20 light:border-theme-sidebar-border p-8 items-center gap-y-4 w-full max-w-[600px]"> <div className=" text-white text-sm font-semibold md:-ml-44"> {t("onboarding.userSetup.howManyUsers")} </div> <div className="flex flex-col md:flex-row gap-6 w-full justify-center"> <button onClick={() => setSelectedOption("just_me")} className={`${ selectedOption === "just_me" ? "text-sky-400 border-sky-400/70" : "text-theme-text-primary border-theme-sidebar-border" } min-w-[230px] h-11 p-4 rounded-[10px] border-2 justify-center items-center gap-[100px] inline-flex hover:border-sky-400/70 hover:text-sky-400 transition-all duration-300`} > <div className="text-center text-sm font-bold"> {t("onboarding.userSetup.justMe")} </div> </button> <button onClick={() => setSelectedOption("my_team")} className={`${ selectedOption === "my_team" ? "text-sky-400 border-sky-400/70" : "text-theme-text-primary border-theme-sidebar-border" } min-w-[230px] h-11 p-4 rounded-[10px] border-2 justify-center items-center gap-[100px] inline-flex hover:border-sky-400/70 hover:text-sky-400 transition-all duration-300`} > <div className="text-center text-sm font-bold"> {t("onboarding.userSetup.myTeam")} </div> </button> </div> </div> {selectedOption === "just_me" && ( <JustMe setSingleUserPasswordValid={setSingleUserPasswordValid} enablePassword={enablePassword} setEnablePassword={setEnablePassword} justMeSubmitRef={justMeSubmitRef} navigate={navigate} /> )} {selectedOption === "my_team" && ( <MyTeam setMultiUserLoginValid={setMultiUserLoginValid} myTeamSubmitRef={myTeamSubmitRef} navigate={navigate} /> )} </div> ); } const JustMe = ({ setSingleUserPasswordValid, enablePassword, setEnablePassword, justMeSubmitRef, navigate, }) => { const { t } = useTranslation(); const [itemSelected, setItemSelected] = useState(false); const [password, setPassword] = useState(""); const handleSubmit = async (e) => { e.preventDefault(); const form = e.target; const formData = new FormData(form); const { error } = await System.updateSystemPassword({ usePassword: true, newPassword: formData.get("password"), }); if (error) { showToast(`Failed to set password: ${error}`, "error"); return; } // Auto-request token with password that was just set so they // are not redirected to login after completion. const { token } = await System.requestToken({ password: formData.get("password"), }); window.localStorage.removeItem(AUTH_USER); window.localStorage.removeItem(AUTH_TIMESTAMP); window.localStorage.setItem(AUTH_TOKEN, token); navigate(paths.onboarding.dataHandling()); }; const setNewPassword = (e) => setPassword(e.target.value); const handlePasswordChange = debounce(setNewPassword, 500); function handleYes() { setItemSelected(true); setEnablePassword(true); } function handleNo() { setItemSelected(true); setEnablePassword(false); } useEffect(() => { if (enablePassword && itemSelected && password.length >= 8) { setSingleUserPasswordValid(true); } else if (!enablePassword && itemSelected) { setSingleUserPasswordValid(true); } else { setSingleUserPasswordValid(false); } }); return ( <div className="w-full flex items-center justify-center flex-col gap-y-6"> <div className="flex flex-col border rounded-lg border-white/20 light:border-theme-sidebar-border p-8 items-center gap-y-4 w-full max-w-[600px]"> <div className=" text-white text-sm font-semibold md:-ml-56"> {t("onboarding.userSetup.setPassword")} </div> <div className="flex flex-col md:flex-row gap-6 w-full justify-center"> <button onClick={handleYes} className={`${ enablePassword && itemSelected ? "text-sky-400 border-sky-400/70" : "text-theme-text-primary border-theme-sidebar-border" } min-w-[230px] h-11 p-4 rounded-[10px] border-2 justify-center items-center gap-[100px] inline-flex hover:border-sky-400/70 hover:text-sky-400 transition-all duration-300`} > <div className="text-center text-sm font-bold"> {t("common.yes")} </div> </button> <button onClick={handleNo} className={`${ !enablePassword && itemSelected ? "text-sky-400 border-sky-400/70" : "text-theme-text-primary border-theme-sidebar-border" } min-w-[230px] h-11 p-4 rounded-[10px] border-2 justify-center items-center gap-[100px] inline-flex hover:border-sky-400/70 hover:text-sky-400 transition-all duration-300`} > <div className="text-center text-sm font-bold"> {t("common.no")} </div> </button> </div> {enablePassword && ( <form className="w-full mt-4" onSubmit={handleSubmit}> <label htmlFor="name" className="block mb-3 text-sm font-medium text-white" > {t("onboarding.userSetup.instancePassword")} </label> <input name="password" type="password" className="border-none bg-theme-settings-input-bg text-white text-sm rounded-lg block w-full p-2.5 focus:outline-primary-button active:outline-primary-button outline-none placeholder:text-theme-text-secondary" placeholder="Your admin password" minLength={6} required={true} autoComplete="off" onChange={handlePasswordChange} /> <div className="mt-4 text-white text-opacity-80 text-xs font-base -mb-2"> {t("onboarding.userSetup.passwordReq")} <br /> <i>{t("onboarding.userSetup.passwordWarn")}</i>{" "} </div> <button type="submit" ref={justMeSubmitRef} hidden aria-hidden="true" ></button> </form> )} </div> </div> ); }; const MyTeam = ({ setMultiUserLoginValid, myTeamSubmitRef, navigate }) => { const { t } = useTranslation(); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const handleSubmit = async (e) => { e.preventDefault(); const form = e.target; const formData = new FormData(form); const data = { username: formData.get("username"), password: formData.get("password"), }; const { success, error } = await System.setupMultiUser(data); if (!success) { showToast(`Error: ${error}`, "error"); return; } navigate(paths.onboarding.dataHandling()); // Auto-request token with credentials that was just set so they // are not redirected to login after completion. const { user, token } = await System.requestToken(data); window.localStorage.setItem(AUTH_USER, JSON.stringify(user)); window.localStorage.setItem(AUTH_TOKEN, token); window.localStorage.removeItem(AUTH_TIMESTAMP); }; const setNewUsername = (e) => setUsername(e.target.value); const setNewPassword = (e) => setPassword(e.target.value); const handleUsernameChange = debounce(setNewUsername, 500); const handlePasswordChange = debounce(setNewPassword, 500); useEffect(() => { if (username.length >= 6 && password.length >= 8) { setMultiUserLoginValid(true); } else { setMultiUserLoginValid(false); } }, [username, password]); return ( <div className="w-full flex items-center justify-center border max-w-[600px] rounded-lg border-white/20 light:border-theme-sidebar-border"> <form onSubmit={handleSubmit}> <div className="flex flex-col w-full md:px-8 px-2 py-4"> <div className="space-y-6 flex h-full w-full"> <div className="w-full flex flex-col gap-y-4"> <div> <label htmlFor="name" className="block mb-3 text-sm font-medium text-white" > {t("onboarding.userSetup.adminUsername")} </label> <input name="username" type="text" className="border-none bg-theme-settings-input-bg text-white text-sm rounded-lg block w-full p-2.5 focus:outline-primary-button active:outline-primary-button placeholder:text-theme-text-secondary outline-none" placeholder="Your admin username" minLength={6} required={true} autoComplete="off" onChange={handleUsernameChange} /> </div> <p className=" text-white text-opacity-80 text-xs font-base"> {t("onboarding.userSetup.adminUsernameReq")} </p> <div className="mt-4"> <label htmlFor="name" className="block mb-3 text-sm font-medium text-white" > {t("onboarding.userSetup.adminPassword")} </label> <input name="password" type="password" className="border-none bg-theme-settings-input-bg text-white text-sm rounded-lg block w-full p-2.5 focus:outline-primary-button active:outline-primary-button placeholder:text-theme-text-secondary outline-none" placeholder="Your admin password" minLength={8} required={true} autoComplete="off" onChange={handlePasswordChange} /> </div> <p className=" text-white text-opacity-80 text-xs font-base"> {t("onboarding.userSetup.adminPasswordReq")} </p> </div> </div> </div> <div className="flex w-full justify-between items-center px-6 py-4 space-x-6 border-t rounded-b border-theme-sidebar-border"> <div className="text-theme-text-secondary text-opacity-80 text-xs font-base"> {t("onboarding.userSetup.teamHint")} </div> </div> <button type="submit" ref={myTeamSubmitRef} hidden aria-hidden="true" ></button> </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/OnboardingFlow/Steps/DataHandling/index.jsx
frontend/src/pages/OnboardingFlow/Steps/DataHandling/index.jsx
import { useEffect } from "react"; import paths from "@/utils/paths"; import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; import ProviderPrivacy from "@/components/ProviderPrivacy"; export default function DataHandling({ setHeader, setForwardBtn, setBackBtn }) { const { t } = useTranslation(); const navigate = useNavigate(); const TITLE = t("onboarding.data.title"); const DESCRIPTION = t("onboarding.data.description"); useEffect(() => { setHeader({ title: TITLE, description: DESCRIPTION }); setForwardBtn({ showing: true, disabled: false, onClick: handleForward }); setBackBtn({ showing: false, disabled: false, onClick: handleBack }); }, []); function handleForward() { navigate(paths.onboarding.survey()); } function handleBack() { navigate(paths.onboarding.userSetup()); } return ( <div className="w-full flex items-center justify-center flex-col gap-y-6"> <ProviderPrivacy /> <p className="text-theme-text-secondary text-sm font-medium py-1"> {t("onboarding.data.settingsHint")} </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/OnboardingFlow/Steps/LLMPreference/index.jsx
frontend/src/pages/OnboardingFlow/Steps/LLMPreference/index.jsx
import { MagnifyingGlass } from "@phosphor-icons/react"; import { useEffect, useState, useRef } from "react"; 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 LMStudioLogo from "@/media/llmprovider/lmstudio.png"; import LocalAiLogo from "@/media/llmprovider/localai.png"; import TogetherAILogo from "@/media/llmprovider/togetherai.png"; import FireworksAILogo from "@/media/llmprovider/fireworksai.jpeg"; 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 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 NovitaLogo from "@/media/llmprovider/novita.png"; import XAILogo from "@/media/llmprovider/xai.png"; import ZAiLogo from "@/media/llmprovider/zai.png"; import NvidiaNimLogo from "@/media/llmprovider/nvidia-nim.png"; import CohereLogo from "@/media/llmprovider/cohere.png"; import PPIOLogo from "@/media/llmprovider/ppio.png"; import DellProAiStudioLogo from "@/media/llmprovider/dpais.png"; import MoonshotAiLogo from "@/media/llmprovider/moonshotai.png"; import CometApiLogo from "@/media/llmprovider/cometapi.png"; import GiteeAILogo from "@/media/llmprovider/giteeai.png"; import OpenAiOptions from "@/components/LLMSelection/OpenAiOptions"; import GenericOpenAiOptions from "@/components/LLMSelection/GenericOpenAiOptions"; import AzureAiOptions from "@/components/LLMSelection/AzureAiOptions"; import AnthropicAiOptions from "@/components/LLMSelection/AnthropicAiOptions"; import LMStudioOptions from "@/components/LLMSelection/LMStudioOptions"; import LocalAiOptions from "@/components/LLMSelection/LocalAiOptions"; import GeminiLLMOptions from "@/components/LLMSelection/GeminiLLMOptions"; import OllamaLLMOptions from "@/components/LLMSelection/OllamaLLMOptions"; import MistralOptions from "@/components/LLMSelection/MistralOptions"; import HuggingFaceOptions from "@/components/LLMSelection/HuggingFaceOptions"; import TogetherAiOptions from "@/components/LLMSelection/TogetherAiOptions"; import FireworksAiOptions from "@/components/LLMSelection/FireworksAiOptions"; import PerplexityOptions from "@/components/LLMSelection/PerplexityOptions"; import OpenRouterOptions from "@/components/LLMSelection/OpenRouterOptions"; import GroqAiOptions from "@/components/LLMSelection/GroqAiOptions"; import CohereAiOptions from "@/components/LLMSelection/CohereAiOptions"; import KoboldCPPOptions from "@/components/LLMSelection/KoboldCPPOptions"; import TextGenWebUIOptions from "@/components/LLMSelection/TextGenWebUIOptions"; import LiteLLMOptions from "@/components/LLMSelection/LiteLLMOptions"; import AWSBedrockLLMOptions from "@/components/LLMSelection/AwsBedrockLLMOptions"; import DeepSeekOptions from "@/components/LLMSelection/DeepSeekOptions"; import ApiPieLLMOptions from "@/components/LLMSelection/ApiPieOptions"; import NovitaLLMOptions from "@/components/LLMSelection/NovitaLLMOptions"; import XAILLMOptions from "@/components/LLMSelection/XAiLLMOptions"; import ZAiLLMOptions from "@/components/LLMSelection/ZAiLLMOptions"; import NvidiaNimOptions from "@/components/LLMSelection/NvidiaNimOptions"; import PPIOLLMOptions from "@/components/LLMSelection/PPIOLLMOptions"; import DellProAiStudioOptions from "@/components/LLMSelection/DPAISOptions"; import MoonshotAiOptions from "@/components/LLMSelection/MoonshotAiOptions"; import CometApiLLMOptions from "@/components/LLMSelection/CometApiLLMOptions"; import GiteeAiOptions from "@/components/LLMSelection/GiteeAIOptions"; import LLMItem from "@/components/LLMSelection/LLMItem"; import System from "@/models/system"; import paths from "@/utils/paths"; import showToast from "@/utils/toast"; import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; const LLMS = [ { name: "OpenAI", value: "openai", logo: OpenAiLogo, options: (settings) => <OpenAiOptions settings={settings} />, description: "The standard option for most non-commercial use.", }, { name: "Azure OpenAI", value: "azure", logo: AzureOpenAiLogo, options: (settings) => <AzureAiOptions settings={settings} />, description: "The enterprise option of OpenAI hosted on Azure services.", }, { name: "Anthropic", value: "anthropic", logo: AnthropicLogo, options: (settings) => <AnthropicAiOptions settings={settings} />, description: "A friendly AI Assistant hosted by Anthropic.", }, { name: "Gemini", value: "gemini", logo: GeminiLogo, options: (settings) => <GeminiLLMOptions settings={settings} />, description: "Google's largest and most capable AI model", }, { name: "NVIDIA NIM", value: "nvidia-nim", logo: NvidiaNimLogo, options: (settings) => <NvidiaNimOptions settings={settings} />, description: "Run full parameter LLMs directly on your NVIDIA RTX GPU using NVIDIA NIM.", }, { name: "HuggingFace", value: "huggingface", logo: HuggingFaceLogo, options: (settings) => <HuggingFaceOptions settings={settings} />, description: "Access 150,000+ open-source LLMs and the world's AI community", }, { name: "Ollama", value: "ollama", logo: OllamaLogo, options: (settings) => <OllamaLLMOptions settings={settings} />, description: "Run LLMs locally on your own machine.", }, { name: "Dell Pro AI Studio", value: "dpais", logo: DellProAiStudioLogo, options: (settings) => <DellProAiStudioOptions settings={settings} />, description: "Run powerful LLMs quickly on NPU powered by Dell Pro AI Studio.", }, { name: "LM Studio", value: "lmstudio", logo: LMStudioLogo, options: (settings) => <LMStudioOptions settings={settings} />, description: "Discover, download, and run thousands of cutting edge LLMs in a few clicks.", }, { name: "Local AI", value: "localai", logo: LocalAiLogo, options: (settings) => <LocalAiOptions settings={settings} />, description: "Run LLMs locally on your own machine.", }, { name: "Novita AI", value: "novita", logo: NovitaLogo, options: (settings) => <NovitaLLMOptions settings={settings} />, description: "Reliable, Scalable, and Cost-Effective for LLMs from Novita AI", }, { name: "KoboldCPP", value: "koboldcpp", logo: KoboldCPPLogo, options: (settings) => <KoboldCPPOptions settings={settings} />, description: "Run local LLMs using koboldcpp.", }, { name: "Oobabooga Web UI", value: "textgenwebui", logo: TextGenWebUILogo, options: (settings) => <TextGenWebUIOptions settings={settings} />, description: "Run local LLMs using Oobabooga's Text Generation Web UI.", }, { name: "Together AI", value: "togetherai", logo: TogetherAILogo, options: (settings) => <TogetherAiOptions settings={settings} />, description: "Run open source models from Together AI.", }, { name: "Fireworks AI", value: "fireworksai", logo: FireworksAILogo, options: (settings) => <FireworksAiOptions settings={settings} />, description: "The fastest and most efficient inference engine to build production-ready, compound AI systems.", }, { name: "Mistral", value: "mistral", logo: MistralLogo, options: (settings) => <MistralOptions settings={settings} />, description: "Run open source models from Mistral AI.", }, { name: "Perplexity AI", value: "perplexity", logo: PerplexityLogo, options: (settings) => <PerplexityOptions settings={settings} />, description: "Run powerful and internet-connected models hosted by Perplexity AI.", }, { name: "OpenRouter", value: "openrouter", logo: OpenRouterLogo, options: (settings) => <OpenRouterOptions settings={settings} />, description: "A unified interface for LLMs.", }, { name: "Groq", value: "groq", logo: GroqLogo, options: (settings) => <GroqAiOptions settings={settings} />, description: "The fastest LLM inferencing available for real-time AI applications.", }, { name: "Cohere", value: "cohere", logo: CohereLogo, options: (settings) => <CohereAiOptions settings={settings} />, description: "Run Cohere's powerful Command models.", }, { name: "LiteLLM", value: "litellm", logo: LiteLLMLogo, options: (settings) => <LiteLLMOptions settings={settings} />, description: "Run LiteLLM's OpenAI compatible proxy for various LLMs.", }, { name: "DeepSeek", value: "deepseek", logo: DeepSeekLogo, options: (settings) => <DeepSeekOptions settings={settings} />, description: "Run DeepSeek's powerful LLMs.", }, { name: "PPIO", value: "ppio", logo: PPIOLogo, options: (settings) => <PPIOLLMOptions settings={settings} />, description: "Run stable and cost-efficient open-source LLM APIs, such as DeepSeek, Llama, Qwen etc.", }, { name: "APIpie", value: "apipie", logo: APIPieLogo, options: (settings) => <ApiPieLLMOptions settings={settings} />, description: "A unified API of AI services from leading providers", }, { name: "Generic OpenAI", value: "generic-openai", logo: GenericOpenAiLogo, options: (settings) => <GenericOpenAiOptions settings={settings} />, description: "Connect to any OpenAi-compatible service via a custom configuration", }, { name: "AWS Bedrock", value: "bedrock", logo: AWSBedrockLogo, options: (settings) => <AWSBedrockLLMOptions settings={settings} />, description: "Run powerful foundation models privately with AWS Bedrock.", }, { name: "xAI", value: "xai", logo: XAILogo, options: (settings) => <XAILLMOptions settings={settings} />, description: "Run xAI's powerful LLMs like Grok-2 and more.", }, { name: "Z.AI", value: "zai", logo: ZAiLogo, options: (settings) => <ZAiLLMOptions settings={settings} />, description: "Run Z.AI's powerful GLM models.", }, { name: "Moonshot AI", value: "moonshotai", logo: MoonshotAiLogo, options: (settings) => <MoonshotAiOptions settings={settings} />, description: "Run Moonshot AI's powerful LLMs.", }, { name: "CometAPI", value: "cometapi", logo: CometApiLogo, options: (settings) => <CometApiLLMOptions settings={settings} />, description: "500+ AI Models all in one API.", }, { name: "GiteeAI", value: "giteeai", logo: GiteeAILogo, options: (settings) => <GiteeAiOptions settings={settings} />, description: "Run GiteeAI's powerful LLMs.", }, ]; export default function LLMPreference({ setHeader, setForwardBtn, setBackBtn, }) { const { t } = useTranslation(); const [searchQuery, setSearchQuery] = useState(""); const [filteredLLMs, setFilteredLLMs] = useState([]); const [selectedLLM, setSelectedLLM] = useState(null); const [settings, setSettings] = useState(null); const formRef = useRef(null); const hiddenSubmitButtonRef = useRef(null); const isHosted = window.location.hostname.includes("useanything.com"); const navigate = useNavigate(); const TITLE = t("onboarding.llm.title"); const DESCRIPTION = t("onboarding.llm.description"); useEffect(() => { async function fetchKeys() { const _settings = await System.keys(); setSettings(_settings); setSelectedLLM(_settings?.LLMProvider || "openai"); } fetchKeys(); }, []); function handleForward() { if (hiddenSubmitButtonRef.current) { hiddenSubmitButtonRef.current.click(); } } function handleBack() { navigate(paths.onboarding.home()); } const handleSubmit = async (e) => { e.preventDefault(); const form = e.target; const data = {}; const formData = new FormData(form); data.LLMProvider = selectedLLM; // Default to AnythingLLM embedder and LanceDB data.EmbeddingEngine = "native"; data.VectorDB = "lancedb"; for (var [key, value] of formData.entries()) data[key] = value; const { error } = await System.updateSystem(data); if (error) { showToast(`Failed to save LLM settings: ${error}`, "error"); return; } navigate(paths.onboarding.userSetup()); }; useEffect(() => { setHeader({ title: TITLE, description: DESCRIPTION }); setForwardBtn({ showing: true, disabled: false, onClick: handleForward }); setBackBtn({ showing: true, disabled: false, onClick: handleBack }); }, []); useEffect(() => { const filtered = LLMS.filter((llm) => llm.name.toLowerCase().includes(searchQuery.toLowerCase()) ); setFilteredLLMs(filtered); }, [searchQuery, selectedLLM]); return ( <div> <form ref={formRef} onSubmit={handleSubmit} className="w-full"> <div className="w-full relative border-theme-chat-input-border shadow border-2 rounded-lg text-white"> <div className="w-full p-4 absolute top-0 rounded-t-lg backdrop-blur-sm"> <div className="w-full flex items-center sticky top-0"> <MagnifyingGlass size={16} weight="bold" className="absolute left-4 z-30 text-theme-text-primary" /> <input type="text" placeholder="Search LLM providers" className="bg-theme-bg-secondary placeholder:text-theme-text-secondary z-20 pl-10 h-[38px] rounded-full w-full px-4 py-1 text-sm border border-theme-chat-input-border outline-none focus:outline-primary-button active:outline-primary-button outline-none text-theme-text-primary" onChange={(e) => setSearchQuery(e.target.value)} autoComplete="off" onKeyDown={(e) => { if (e.key === "Enter") e.preventDefault(); }} /> </div> </div> <div className="px-4 pt-[70px] flex flex-col gap-y-1 max-h-[390px] overflow-y-auto no-scroll pb-4"> {filteredLLMs.map((llm) => { if (llm.value === "native" && isHosted) return null; return ( <LLMItem key={llm.name} name={llm.name} value={llm.value} image={llm.logo} description={llm.description} checked={selectedLLM === llm.value} onClick={() => setSelectedLLM(llm.value)} /> ); })} </div> </div> <div className="mt-4 flex flex-col gap-y-1"> {selectedLLM && LLMS.find((llm) => llm.value === selectedLLM)?.options(settings)} </div> <button type="submit" ref={hiddenSubmitButtonRef} hidden aria-hidden="true" ></button> </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/OnboardingFlow/Steps/Home/index.jsx
frontend/src/pages/OnboardingFlow/Steps/Home/index.jsx
import paths from "@/utils/paths"; import LGroupImg from "./l_group.png"; import RGroupImg from "./r_group.png"; import LGroupImgLight from "./l_group-light.png"; import RGroupImgLight from "./r_group-light.png"; import AnythingLLMLogo from "@/media/logo/anything-llm.png"; import { useNavigate } from "react-router-dom"; import { useTheme } from "@/hooks/useTheme"; import { useTranslation } from "react-i18next"; const IMG_SRCSET = { light: { l: LGroupImgLight, r: RGroupImgLight, }, default: { l: LGroupImg, r: RGroupImg, }, }; export default function OnboardingHome() { const navigate = useNavigate(); const { theme } = useTheme(); const { t } = useTranslation(); const srcSet = IMG_SRCSET?.[theme] || IMG_SRCSET.default; return ( <> <div className="relative w-screen h-screen flex overflow-hidden bg-theme-bg-primary"> <div className="hidden md:block fixed bottom-10 left-10 w-[320px] h-[320px] bg-no-repeat bg-contain" style={{ backgroundImage: `url(${srcSet.l})` }} ></div> <div className="hidden md:block fixed top-10 right-10 w-[320px] h-[320px] bg-no-repeat bg-contain" style={{ backgroundImage: `url(${srcSet.r})` }} ></div> <div className="relative flex justify-center items-center m-auto"> <div className="flex flex-col justify-center items-center"> <p className="text-theme-text-primary font-thin text-[24px]"> {t("onboarding.home.title")} </p> <img src={AnythingLLMLogo} alt="AnythingLLM" className="md:h-[50px] flex-shrink-0 max-w-[300px] light:invert" /> <button onClick={() => navigate(paths.onboarding.llmPreference())} className="border-[2px] border-theme-text-primary animate-pulse light:animate-none w-full md:max-w-[350px] md:min-w-[300px] text-center py-3 bg-theme-button-primary hover:bg-theme-bg-secondary text-theme-text-primary font-semibold text-sm my-10 rounded-md " > {t("onboarding.home.getStarted")} </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/OnboardingFlow/Steps/Survey/index.jsx
frontend/src/pages/OnboardingFlow/Steps/Survey/index.jsx
import { COMPLETE_QUESTIONNAIRE, ONBOARDING_SURVEY_URL, } from "@/utils/constants"; import paths from "@/utils/paths"; import { CheckCircle } from "@phosphor-icons/react"; import React, { useState, useEffect, useRef } from "react"; import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; async function sendQuestionnaire({ email, useCase, comment }) { if (import.meta.env.DEV) { console.log("sendQuestionnaire", { email, useCase, comment }); return; } const data = JSON.stringify({ email, useCase, comment, sourceId: "0VRjqHh6Vukqi0x0Vd0n/m8JuT7k8nOz", }); if (!navigator.sendBeacon) { console.log("navigator.sendBeacon not supported, falling back to fetch"); return fetch(ONBOARDING_SURVEY_URL, { method: "POST", body: data, }) .then(() => { window.localStorage.setItem(COMPLETE_QUESTIONNAIRE, true); console.log(`✅ Questionnaire responses sent.`); }) .catch((error) => { console.error(`sendQuestionnaire`, error.message); }); } navigator.sendBeacon(ONBOARDING_SURVEY_URL, data); window.localStorage.setItem(COMPLETE_QUESTIONNAIRE, true); console.log(`✅ Questionnaire responses sent.`); } export default function Survey({ setHeader, setForwardBtn, setBackBtn }) { const { t } = useTranslation(); const [selectedOption, setSelectedOption] = useState(""); const formRef = useRef(null); const navigate = useNavigate(); const submitRef = useRef(null); const TITLE = t("onboarding.survey.title"); const DESCRIPTION = t("onboarding.survey.description"); function handleForward() { if (!!window?.localStorage?.getItem(COMPLETE_QUESTIONNAIRE)) { navigate(paths.onboarding.createWorkspace()); return; } if (!formRef.current) { skipSurvey(); return; } // Check if any inputs are not empty. If that is the case, trigger form validation. // via the requestSubmit() handler const formData = new FormData(formRef.current); if ( !!formData.get("email") || !!formData.get("use_case") || !!formData.get("comment") ) { formRef.current.requestSubmit(); return; } skipSurvey(); } function skipSurvey() { navigate(paths.onboarding.createWorkspace()); } function handleBack() { navigate(paths.onboarding.dataHandling()); } useEffect(() => { setHeader({ title: TITLE, description: DESCRIPTION }); setForwardBtn({ showing: true, disabled: false, onClick: handleForward }); setBackBtn({ showing: true, disabled: false, onClick: handleBack }); }, []); const handleSubmit = async (e) => { e.preventDefault(); const form = e.target; const formData = new FormData(form); await sendQuestionnaire({ email: formData.get("email"), useCase: formData.get("use_case") || "other", comment: formData.get("comment") || null, }); navigate(paths.onboarding.createWorkspace()); }; if (!!window?.localStorage?.getItem(COMPLETE_QUESTIONNAIRE)) { return ( <div className="w-full flex justify-center items-center py-40"> <div className="w-full flex items-center justify-center px-1 md:px-8 py-4"> <div className="w-auto flex flex-col gap-y-1 items-center"> <CheckCircle size={60} className="text-green-500" /> <p className="text-white text-lg"> {t("onboarding.survey.thankYou")} </p> <a href={paths.mailToMintplex()} className="text-sky-400 underline text-xs" > [email protected] </a> </div> </div> </div> ); } return ( <div className="w-full flex justify-center bo"> <form onSubmit={handleSubmit} ref={formRef} className=""> <div className="md:min-w-[400px]"> <label htmlFor="email" className="text-theme-text-primary text-base font-medium" > {t("onboarding.survey.email")}{" "} </label> <input name="email" type="email" placeholder="[email protected]" required={true} className="mt-2 bg-theme-settings-input-bg text-white focus:outline-primary-button active:outline-primary-button placeholder:text-theme-settings-input-placeholder outline-none text-sm font-medium font-['Plus Jakarta Sans'] leading-tight w-full h-11 p-2.5 bg-theme-settings-input-bg rounded-lg" /> </div> <div className="mt-8"> <label className="text-theme-text-primary text-base font-medium" htmlFor="use_case" > {t("onboarding.survey.useCase")}{" "} </label> <div className="mt-2 gap-y-3 flex flex-col"> <label className={`border-solid transition-all duration-300 w-full h-11 p-2.5 rounded-lg flex justify-start items-center gap-2.5 cursor-pointer border ${ selectedOption === "job" ? "border-theme-sidebar-item-workspace-active bg-theme-bg-secondary" : "border-theme-sidebar-border" } hover:border-theme-sidebar-border hover:bg-theme-bg-secondary`} > <input type="radio" name="use_case" value={"job"} checked={selectedOption === "job"} onChange={(e) => setSelectedOption(e.target.value)} className="hidden" /> <div className={`w-4 h-4 rounded-full border-2 border-theme-sidebar-border mr-2 ${ selectedOption === "job" ? "bg-[var(--theme-sidebar-item-workspace-active)]" : "" }`} ></div> <div className="text-theme-text-primary text-sm font-medium font-['Plus Jakarta Sans'] leading-tight"> {t("onboarding.survey.useCaseWork")} </div> </label> <label className={`border-solid transition-all duration-300 w-full h-11 p-2.5 rounded-lg flex justify-start items-center gap-2.5 cursor-pointer border-[1px] ${ selectedOption === "personal" ? "border-theme-sidebar-item-workspace-active bg-theme-bg-secondary" : "border-theme-sidebar-border" } hover:border-theme-sidebar-border hover:bg-theme-bg-secondary`} > <input type="radio" name="use_case" value={"personal"} checked={selectedOption === "personal"} onChange={(e) => setSelectedOption(e.target.value)} className="hidden" /> <div className={`w-4 h-4 rounded-full border-2 border-theme-sidebar-border mr-2 ${ selectedOption === "personal" ? "bg-[var(--theme-sidebar-item-workspace-active)]" : "" }`} ></div> <div className="text-theme-text-primary text-sm font-medium font-['Plus Jakarta Sans'] leading-tight"> {t("onboarding.survey.useCasePersonal")} </div> </label> <label className={`border-solid transition-all duration-300 w-full h-11 p-2.5 rounded-lg flex justify-start items-center gap-2.5 cursor-pointer border-[1px] ${ selectedOption === "other" ? "border-theme-sidebar-item-workspace-active bg-theme-bg-secondary" : "border-theme-sidebar-border" } hover:border-theme-sidebar-border hover:bg-theme-bg-secondary`} > <input type="radio" name="use_case" value={"other"} checked={selectedOption === "other"} onChange={(e) => setSelectedOption(e.target.value)} className="hidden" /> <div className={`w-4 h-4 rounded-full border-2 border-theme-sidebar-border mr-2 ${ selectedOption === "other" ? "bg-[var(--theme-sidebar-item-workspace-active)]" : "" }`} ></div> <div className="text-theme-text-primary text-sm font-medium font-['Plus Jakarta Sans'] leading-tight"> {t("onboarding.survey.useCaseOther")} </div> </label> </div> </div> <div className="mt-8"> <label htmlFor="comment" className="text-white text-base font-medium"> {t("onboarding.survey.comment")}{" "} <span className="text-neutral-400 text-base font-light"> ({t("common.optional")}) </span> </label> <textarea name="comment" rows={5} className="mt-2 bg-theme-settings-input-bg text-white text-sm rounded-lg focus:outline-primary-button active:outline-primary-button placeholder:text-theme-settings-input-placeholder outline-none block w-full p-2.5" placeholder={t("onboarding.survey.commentPlaceholder")} wrap="soft" autoComplete="off" /> </div> <button type="submit" ref={submitRef} hidden aria-hidden="true" ></button> <div className="w-full flex items-center justify-center"> <button type="button" onClick={skipSurvey} className="text-white text-base font-medium text-opacity-30 hover:text-opacity-100 hover:text-teal mt-8" > {t("onboarding.survey.skip")} </button> </div> </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/OnboardingFlow/Steps/CreateWorkspace/index.jsx
frontend/src/pages/OnboardingFlow/Steps/CreateWorkspace/index.jsx
import React, { useEffect, useRef, useState } from "react"; import illustration from "@/media/illustrations/create-workspace.png"; import paths from "@/utils/paths"; import showToast from "@/utils/toast"; import { useNavigate } from "react-router-dom"; import Workspace from "@/models/workspace"; import { useTranslation } from "react-i18next"; export default function CreateWorkspace({ setHeader, setForwardBtn, setBackBtn, }) { const { t } = useTranslation(); const [workspaceName, setWorkspaceName] = useState(""); const navigate = useNavigate(); const createWorkspaceRef = useRef(); const TITLE = t("onboarding.workspace.title"); const DESCRIPTION = t("onboarding.workspace.description"); useEffect(() => { setHeader({ title: TITLE, description: DESCRIPTION }); setBackBtn({ showing: false, disabled: false, onClick: handleBack }); }, []); useEffect(() => { if (workspaceName.length > 0) { setForwardBtn({ showing: true, disabled: false, onClick: handleForward }); } else { setForwardBtn({ showing: true, disabled: true, onClick: handleForward }); } }, [workspaceName]); const handleCreate = async (e) => { e.preventDefault(); const form = new FormData(e.target); const { workspace, error } = await Workspace.new({ name: form.get("name"), onboardingComplete: true, }); if (!!workspace) { showToast( "Workspace created successfully! Taking you to home...", "success" ); await new Promise((resolve) => setTimeout(resolve, 1000)); navigate(paths.home()); } else { showToast(`Failed to create workspace: ${error}`, "error"); } }; function handleForward() { createWorkspaceRef.current.click(); } function handleBack() { navigate(paths.onboarding.survey()); } return ( <form onSubmit={handleCreate} className="w-full flex items-center justify-center flex-col gap-y-2" > <img src={illustration} alt="Create workspace" /> <div className="flex flex-col gap-y-4 w-full max-w-[600px]"> {" "} <div className="w-full mt-4"> <label htmlFor="name" className="block mb-3 text-sm font-medium text-white" > {t("common.workspaces-name")} </label> <input name="name" type="text" className="border-none bg-theme-settings-input-bg text-white focus:outline-primary-button active:outline-primary-button placeholder:text-theme-settings-input-placeholder outline-none text-sm rounded-lg block w-full p-2.5" placeholder="My Workspace" required={true} autoComplete="off" onChange={(e) => setWorkspaceName(e.target.value)} /> </div> </div> <button type="submit" ref={createWorkspaceRef} hidden aria-hidden="true" ></button> </form> ); }
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/GeneralSettings/Chats/MarkdownRenderer.jsx
frontend/src/pages/GeneralSettings/Chats/MarkdownRenderer.jsx
import { useState } from "react"; import MarkdownIt from "markdown-it"; import hljs from "highlight.js"; import { CaretDown } from "@phosphor-icons/react"; import "highlight.js/styles/github-dark.css"; import DOMPurify from "@/utils/chat/purify"; const md = new MarkdownIt({ html: true, breaks: true, highlight: function (str, lang) { if (lang && hljs.getLanguage(lang)) { try { return hljs.highlight(str, { language: lang }).value; } catch (__) {} } return ""; // use external default escaping }, }); const ThoughtBubble = ({ thought }) => { const [isExpanded, setIsExpanded] = useState(false); if (!thought) return null; const cleanThought = thought.replace(/<\/?think>/g, "").trim(); if (!cleanThought) return null; return ( <div className="mb-3"> <div onClick={() => setIsExpanded(!isExpanded)} className="cursor-pointer flex items-center gap-x-2 text-theme-text-secondary hover:text-theme-text-primary transition-colors mb-2" > <CaretDown size={14} weight="bold" className={`transition-transform ${isExpanded ? "rotate-180" : ""}`} /> <span className="text-xs font-medium">View thoughts</span> </div> {isExpanded && ( <div className="bg-theme-bg-chat-input rounded-md p-3 border-l-2 border-theme-text-secondary/30"> <div className="text-xs text-theme-text-secondary font-mono whitespace-pre-wrap"> {cleanThought} </div> </div> )} </div> ); }; function parseContent(content) { const parts = []; let lastIndex = 0; content.replace(/<think>([^]*?)<\/think>/g, (match, thinkContent, offset) => { if (offset > lastIndex) { parts.push({ type: "normal", text: content.slice(lastIndex, offset) }); } parts.push({ type: "think", text: thinkContent }); lastIndex = offset + match.length; }); if (lastIndex < content.length) { parts.push({ type: "normal", text: content.slice(lastIndex) }); } return parts; } export default function MarkdownRenderer({ content }) { if (!content) return null; const parts = parseContent(content); return ( <div className="whitespace-normal"> {parts.map((part, index) => { const html = md.render(part.text); if (part.type === "think") return <ThoughtBubble key={index} thought={part.text} />; return ( <div key={index} dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(html) }} /> ); })} </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/GeneralSettings/Chats/index.jsx
frontend/src/pages/GeneralSettings/Chats/index.jsx
import { useEffect, useRef, useState } from "react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; import useQuery from "@/hooks/useQuery"; import ChatRow from "./ChatRow"; import showToast from "@/utils/toast"; import System from "@/models/system"; import { CaretDown, Download, Trash } from "@phosphor-icons/react"; import { saveAs } from "file-saver"; import { useTranslation } from "react-i18next"; import { CanViewChatHistory } from "@/components/CanViewChatHistory"; const exportOptions = { csv: { name: "CSV", mimeType: "text/csv", fileExtension: "csv", filenameFunc: () => { return `anythingllm-chats-${new Date().toLocaleDateString()}`; }, }, json: { name: "JSON", mimeType: "application/json", fileExtension: "json", filenameFunc: () => { return `anythingllm-chats-${new Date().toLocaleDateString()}`; }, }, jsonl: { name: "JSONL", mimeType: "application/jsonl", fileExtension: "jsonl", filenameFunc: () => { return `anythingllm-chats-${new Date().toLocaleDateString()}-lines`; }, }, jsonAlpaca: { name: "JSON (Alpaca)", mimeType: "application/json", fileExtension: "json", filenameFunc: () => { return `anythingllm-chats-${new Date().toLocaleDateString()}-alpaca`; }, }, }; export default function WorkspaceChats() { const [showMenu, setShowMenu] = useState(false); const menuRef = useRef(); const openMenuButton = useRef(); const query = useQuery(); const [loading, setLoading] = useState(true); const [chats, setChats] = useState([]); const [offset, setOffset] = useState(Number(query.get("offset") || 0)); const [canNext, setCanNext] = useState(false); const { t } = useTranslation(); const handleDumpChats = async (exportType) => { const chats = await System.exportChats(exportType, "workspace"); if (!!chats) { const { name, mimeType, fileExtension, filenameFunc } = exportOptions[exportType]; const blob = new Blob([chats], { type: mimeType }); saveAs(blob, `${filenameFunc()}.${fileExtension}`); showToast(`Chats exported successfully as ${name}.`, "success"); } else { showToast("Failed to export chats.", "error"); } }; const handleClearAllChats = async () => { if ( !window.confirm( `Are you sure you want to clear all chats?\n\nThis action is irreversible.` ) ) return false; await System.deleteChat(-1); setChats([]); showToast("Cleared all chats.", "success"); }; const toggleMenu = () => { setShowMenu(!showMenu); }; useEffect(() => { function handleClickOutside(event) { if ( menuRef.current && !menuRef.current.contains(event.target) && !openMenuButton.current.contains(event.target) ) { setShowMenu(false); } } document.addEventListener("mousedown", handleClickOutside); return () => { document.removeEventListener("mousedown", handleClickOutside); }; }, []); useEffect(() => { async function fetchChats() { const { chats: _chats = [], hasPages = false } = await System.chats(offset); setChats(_chats); setCanNext(hasPages); setLoading(false); } fetchChats(); }, [offset]); return ( <CanViewChatHistory> <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2"> <div className="flex flex-wrap gap-4 items-center"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> {t("recorded.title")} </p> <div className="relative"> <button ref={openMenuButton} onClick={toggleMenu} className="flex items-center gap-x-2 px-4 py-1 rounded-lg bg-primary-button hover:light:bg-theme-bg-primary hover:text-theme-text-primary text-xs font-semibold hover:bg-secondary shadow-[0_4px_14px_rgba(0,0,0,0.25)] h-[34px] w-fit" > <Download size={18} weight="bold" /> {t("recorded.export")} <CaretDown size={18} weight="bold" /> </button> <div ref={menuRef} className={`${ showMenu ? "slide-down" : "slide-up hidden" } z-20 w-fit rounded-lg absolute top-full right-0 bg-secondary light:bg-theme-bg-secondary mt-2 shadow-md`} > <div className="py-2"> {Object.entries(exportOptions).map(([key, data]) => ( <button key={key} onClick={() => { handleDumpChats(key); setShowMenu(false); }} className="w-full text-left px-4 py-2 text-white text-sm hover:bg-[#3D4147] light:hover:bg-theme-sidebar-item-hover" > {data.name} </button> ))} </div> </div> </div> {chats.length > 0 && ( <button onClick={handleClearAllChats} className="flex items-center gap-x-2 px-4 py-1 border hover:border-transparent light:border-theme-sidebar-border border-white/40 text-white/40 light:text-theme-text-secondary rounded-lg bg-transparent hover:light:text-theme-bg-primary hover:text-theme-text-primary text-xs font-semibold hover:bg-red-500 shadow-[0_4px_14px_rgba(0,0,0,0.25)] h-[34px] w-fit" > <Trash size={18} weight="bold" /> Clear Chats </button> )} </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary mt-2"> {t("recorded.description")} </p> </div> <div className="overflow-x-auto"> <ChatsContainer loading={loading} chats={chats} setChats={setChats} offset={offset} setOffset={setOffset} canNext={canNext} t={t} /> </div> </div> </div> </div> </CanViewChatHistory> ); } function ChatsContainer({ loading, chats, setChats, offset, setOffset, canNext, t, }) { const handlePrevious = () => { setOffset(Math.max(offset - 1, 0)); }; const handleNext = () => { setOffset(offset + 1); }; const handleDeleteChat = async (chatId) => { await System.deleteChat(chatId); setChats((prevChats) => prevChats.filter((chat) => chat.id !== chatId)); }; 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" containerClassName="flex w-full" /> ); } return ( <> <table className="w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0"> <thead className="text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b"> <tr> <th scope="col" className="px-6 py-3 rounded-tl-lg"> {t("recorded.table.id")} </th> <th scope="col" className="px-6 py-3"> {t("recorded.table.by")} </th> <th scope="col" className="px-6 py-3"> {t("recorded.table.workspace")} </th> <th scope="col" className="px-6 py-3"> {t("recorded.table.prompt")} </th> <th scope="col" className="px-6 py-3"> {t("recorded.table.response")} </th> <th scope="col" className="px-6 py-3"> {t("recorded.table.at")} </th> <th scope="col" className="px-6 py-3 rounded-tr-lg"> {" "} </th> </tr> </thead> <tbody> {!!chats && chats.map((chat) => ( <ChatRow key={chat.id} chat={chat} onDelete={handleDeleteChat} /> ))} </tbody> </table> <div className="flex w-full justify-between items-center mt-6"> <button onClick={handlePrevious} className="px-4 py-2 rounded-lg border border-theme-text-secondary text-theme-text-secondary text-sm items-center flex gap-x-2 hover:bg-theme-text-secondary hover:text-theme-bg-secondary disabled:invisible" disabled={offset === 0} > {" "} Previous Page </button> <button onClick={handleNext} className="px-4 py-2 rounded-lg border border-slate-200 text-slate-200 light:text-theme-text-secondary light:border-theme-sidebar-border text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 disabled:invisible" disabled={!canNext} > Next Page </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/GeneralSettings/Chats/ChatRow/index.jsx
frontend/src/pages/GeneralSettings/Chats/ChatRow/index.jsx
import truncate from "truncate"; import { X, Trash } from "@phosphor-icons/react"; import System from "@/models/system"; import ModalWrapper from "@/components/ModalWrapper"; import { useModal } from "@/hooks/useModal"; import MarkdownRenderer from "../MarkdownRenderer"; import { safeJsonParse } from "@/utils/request"; export default function ChatRow({ chat, onDelete }) { const { isOpen: isPromptOpen, openModal: openPromptModal, closeModal: closePromptModal, } = useModal(); const { isOpen: isResponseOpen, openModal: openResponseModal, closeModal: closeResponseModal, } = useModal(); const handleDelete = async () => { if ( !window.confirm( `Are you sure you want to delete this chat?\n\nThis action is irreversible.` ) ) return false; await System.deleteChat(chat.id); onDelete(chat.id); }; return ( <> <tr className="bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10"> <td className="px-6 font-medium whitespace-nowrap text-white"> {chat.id} </td> <td className="px-6 font-medium whitespace-nowrap text-white"> {chat.user?.username} </td> <td className="px-6">{chat.workspace?.name}</td> <td onClick={openPromptModal} className="px-6 border-transparent cursor-pointer transform transition-transform duration-200 hover:scale-105 hover:shadow-lg" > {truncate(chat.prompt, 40)} </td> <td onClick={openResponseModal} className="px-6 cursor-pointer transform transition-transform duration-200 hover:scale-105 hover:shadow-lg" > {truncate(safeJsonParse(chat.response, {})?.text, 40)} </td> <td className="px-6">{chat.createdAt}</td> <td className="px-6 flex items-center gap-x-6 h-full mt-1"> <button onClick={handleDelete} className="text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10" > <Trash className="h-5 w-5" /> </button> </td> </tr> <ModalWrapper isOpen={isPromptOpen}> <TextPreview text={chat.prompt} closeModal={closePromptModal} /> </ModalWrapper> <ModalWrapper isOpen={isResponseOpen}> <TextPreview text={ <MarkdownRenderer content={safeJsonParse(chat.response, {})?.text} /> } closeModal={closeResponseModal} /> </ModalWrapper> </> ); } const TextPreview = ({ text, closeModal }) => { return ( <div className="relative w-full md:max-w-2xl 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"> <h3 className="text-xl font-semibold text-white">Viewing Text</h3> <button onClick={closeModal} type="button" className="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> <div className="w-full p-6"> <pre className="w-full h-[200px] py-2 px-4 whitespace-pre-line overflow-auto rounded-lg bg-zinc-900 light:bg-theme-bg-secondary border border-gray-500 text-white text-sm"> {text} </pre> </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/GeneralSettings/LLMPreference/index.jsx
frontend/src/pages/GeneralSettings/LLMPreference/index.jsx
import React, { useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import System from "@/models/system"; import showToast from "@/utils/toast"; 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 NovitaLogo from "@/media/llmprovider/novita.png"; import LMStudioLogo from "@/media/llmprovider/lmstudio.png"; import LocalAiLogo from "@/media/llmprovider/localai.png"; import TogetherAILogo from "@/media/llmprovider/togetherai.png"; import FireworksAILogo from "@/media/llmprovider/fireworksai.jpeg"; 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 GroqLogo from "@/media/llmprovider/groq.png"; import KoboldCPPLogo from "@/media/llmprovider/koboldcpp.png"; import TextGenWebUILogo from "@/media/llmprovider/text-generation-webui.png"; import CohereLogo from "@/media/llmprovider/cohere.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 NvidiaNimLogo from "@/media/llmprovider/nvidia-nim.png"; import PPIOLogo from "@/media/llmprovider/ppio.png"; import DellProAiStudioLogo 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"; import PreLoader from "@/components/Preloader"; import OpenAiOptions from "@/components/LLMSelection/OpenAiOptions"; import GenericOpenAiOptions from "@/components/LLMSelection/GenericOpenAiOptions"; import AzureAiOptions from "@/components/LLMSelection/AzureAiOptions"; import AnthropicAiOptions from "@/components/LLMSelection/AnthropicAiOptions"; import LMStudioOptions from "@/components/LLMSelection/LMStudioOptions"; import LocalAiOptions from "@/components/LLMSelection/LocalAiOptions"; import GeminiLLMOptions from "@/components/LLMSelection/GeminiLLMOptions"; import OllamaLLMOptions from "@/components/LLMSelection/OllamaLLMOptions"; import NovitaLLMOptions from "@/components/LLMSelection/NovitaLLMOptions"; import CometApiLLMOptions from "@/components/LLMSelection/CometApiLLMOptions"; import TogetherAiOptions from "@/components/LLMSelection/TogetherAiOptions"; import FireworksAiOptions from "@/components/LLMSelection/FireworksAiOptions"; import MistralOptions from "@/components/LLMSelection/MistralOptions"; import HuggingFaceOptions from "@/components/LLMSelection/HuggingFaceOptions"; import PerplexityOptions from "@/components/LLMSelection/PerplexityOptions"; import OpenRouterOptions from "@/components/LLMSelection/OpenRouterOptions"; import GroqAiOptions from "@/components/LLMSelection/GroqAiOptions"; import CohereAiOptions from "@/components/LLMSelection/CohereAiOptions"; import KoboldCPPOptions from "@/components/LLMSelection/KoboldCPPOptions"; import TextGenWebUIOptions from "@/components/LLMSelection/TextGenWebUIOptions"; import LiteLLMOptions from "@/components/LLMSelection/LiteLLMOptions"; import AWSBedrockLLMOptions from "@/components/LLMSelection/AwsBedrockLLMOptions"; import DeepSeekOptions from "@/components/LLMSelection/DeepSeekOptions"; import ApiPieLLMOptions from "@/components/LLMSelection/ApiPieOptions"; import XAILLMOptions from "@/components/LLMSelection/XAiLLMOptions"; import ZAiLLMOptions from "@/components/LLMSelection/ZAiLLMOptions"; import NvidiaNimOptions from "@/components/LLMSelection/NvidiaNimOptions"; import PPIOLLMOptions from "@/components/LLMSelection/PPIOLLMOptions"; import DellProAiStudioOptions from "@/components/LLMSelection/DPAISOptions"; import MoonshotAiOptions from "@/components/LLMSelection/MoonshotAiOptions"; import FoundryOptions from "@/components/LLMSelection/FoundryOptions"; import GiteeAIOptions from "@/components/LLMSelection/GiteeAIOptions/index.jsx"; import LLMItem from "@/components/LLMSelection/LLMItem"; import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react"; import CTAButton from "@/components/lib/CTAButton"; export const AVAILABLE_LLM_PROVIDERS = [ { name: "OpenAI", value: "openai", logo: OpenAiLogo, options: (settings) => <OpenAiOptions settings={settings} />, description: "The standard option for most non-commercial use.", requiredConfig: ["OpenAiKey"], }, { name: "Azure OpenAI", value: "azure", logo: AzureOpenAiLogo, options: (settings) => <AzureAiOptions settings={settings} />, description: "The enterprise option of OpenAI hosted on Azure services.", requiredConfig: ["AzureOpenAiEndpoint"], }, { name: "Anthropic", value: "anthropic", logo: AnthropicLogo, options: (settings) => <AnthropicAiOptions settings={settings} />, description: "A friendly AI Assistant hosted by Anthropic.", requiredConfig: ["AnthropicApiKey"], }, { name: "Gemini", value: "gemini", logo: GeminiLogo, options: (settings) => <GeminiLLMOptions settings={settings} />, description: "Google's largest and most capable AI model", requiredConfig: ["GeminiLLMApiKey"], }, { name: "NVIDIA NIM", value: "nvidia-nim", logo: NvidiaNimLogo, options: (settings) => <NvidiaNimOptions settings={settings} />, description: "Run full parameter LLMs directly on your NVIDIA RTX GPU using NVIDIA NIM.", requiredConfig: ["NvidiaNimLLMBasePath"], }, { name: "HuggingFace", value: "huggingface", logo: HuggingFaceLogo, options: (settings) => <HuggingFaceOptions settings={settings} />, description: "Access 150,000+ open-source LLMs and the world's AI community", requiredConfig: [ "HuggingFaceLLMEndpoint", "HuggingFaceLLMAccessToken", "HuggingFaceLLMTokenLimit", ], }, { name: "Ollama", value: "ollama", logo: OllamaLogo, options: (settings) => <OllamaLLMOptions settings={settings} />, description: "Run LLMs locally on your own machine.", requiredConfig: ["OllamaLLMBasePath"], }, { name: "Dell Pro AI Studio", value: "dpais", logo: DellProAiStudioLogo, options: (settings) => <DellProAiStudioOptions settings={settings} />, description: "Run powerful LLMs quickly on NPU powered by Dell Pro AI Studio.", requiredConfig: [ "DellProAiStudioBasePath", "DellProAiStudioModelPref", "DellProAiStudioTokenLimit", ], }, { name: "LM Studio", value: "lmstudio", logo: LMStudioLogo, options: (settings) => <LMStudioOptions settings={settings} />, description: "Discover, download, and run thousands of cutting edge LLMs in a few clicks.", requiredConfig: ["LMStudioBasePath"], }, { name: "Local AI", value: "localai", logo: LocalAiLogo, options: (settings) => <LocalAiOptions settings={settings} />, description: "Run LLMs locally on your own machine.", requiredConfig: ["LocalAiApiKey", "LocalAiBasePath", "LocalAiTokenLimit"], }, { name: "Together AI", value: "togetherai", logo: TogetherAILogo, options: (settings) => <TogetherAiOptions settings={settings} />, description: "Run open source models from Together AI.", requiredConfig: ["TogetherAiApiKey"], }, { name: "Fireworks AI", value: "fireworksai", logo: FireworksAILogo, options: (settings) => <FireworksAiOptions settings={settings} />, description: "The fastest and most efficient inference engine to build production-ready, compound AI systems.", requiredConfig: ["FireworksAiLLMApiKey"], }, { name: "Mistral", value: "mistral", logo: MistralLogo, options: (settings) => <MistralOptions settings={settings} />, description: "Run open source models from Mistral AI.", requiredConfig: ["MistralApiKey"], }, { name: "Perplexity AI", value: "perplexity", logo: PerplexityLogo, options: (settings) => <PerplexityOptions settings={settings} />, description: "Run powerful and internet-connected models hosted by Perplexity AI.", requiredConfig: ["PerplexityApiKey"], }, { name: "OpenRouter", value: "openrouter", logo: OpenRouterLogo, options: (settings) => <OpenRouterOptions settings={settings} />, description: "A unified interface for LLMs.", requiredConfig: ["OpenRouterApiKey"], }, { name: "Groq", value: "groq", logo: GroqLogo, options: (settings) => <GroqAiOptions settings={settings} />, description: "The fastest LLM inferencing available for real-time AI applications.", requiredConfig: ["GroqApiKey"], }, { name: "KoboldCPP", value: "koboldcpp", logo: KoboldCPPLogo, options: (settings) => <KoboldCPPOptions settings={settings} />, description: "Run local LLMs using koboldcpp.", requiredConfig: [ "KoboldCPPModelPref", "KoboldCPPBasePath", "KoboldCPPTokenLimit", ], }, { name: "Oobabooga Web UI", value: "textgenwebui", logo: TextGenWebUILogo, options: (settings) => <TextGenWebUIOptions settings={settings} />, description: "Run local LLMs using Oobabooga's Text Generation Web UI.", requiredConfig: ["TextGenWebUIBasePath", "TextGenWebUITokenLimit"], }, { name: "Cohere", value: "cohere", logo: CohereLogo, options: (settings) => <CohereAiOptions settings={settings} />, description: "Run Cohere's powerful Command models.", requiredConfig: ["CohereApiKey"], }, { name: "LiteLLM", value: "litellm", logo: LiteLLMLogo, options: (settings) => <LiteLLMOptions settings={settings} />, description: "Run LiteLLM's OpenAI compatible proxy for various LLMs.", requiredConfig: ["LiteLLMBasePath"], }, { name: "DeepSeek", value: "deepseek", logo: DeepSeekLogo, options: (settings) => <DeepSeekOptions settings={settings} />, description: "Run DeepSeek's powerful LLMs.", requiredConfig: ["DeepSeekApiKey"], }, { name: "PPIO", value: "ppio", logo: PPIOLogo, options: (settings) => <PPIOLLMOptions settings={settings} />, description: "Run stable and cost-efficient open-source LLM APIs, such as DeepSeek, Llama, Qwen etc.", requiredConfig: ["PPIOApiKey"], }, { name: "AWS Bedrock", value: "bedrock", logo: AWSBedrockLogo, options: (settings) => <AWSBedrockLLMOptions settings={settings} />, description: "Run powerful foundation models privately with AWS Bedrock.", requiredConfig: [ "AwsBedrockLLMAccessKeyId", "AwsBedrockLLMAccessKey", "AwsBedrockLLMRegion", "AwsBedrockLLMModel", ], }, { name: "APIpie", value: "apipie", logo: APIPieLogo, options: (settings) => <ApiPieLLMOptions settings={settings} />, description: "A unified API of AI services from leading providers", requiredConfig: ["ApipieLLMApiKey", "ApipieLLMModelPref"], }, { name: "Moonshot AI", value: "moonshotai", logo: MoonshotAiLogo, options: (settings) => <MoonshotAiOptions settings={settings} />, description: "Run Moonshot AI's powerful LLMs.", requiredConfig: ["MoonshotAiApiKey"], }, { name: "Novita AI", value: "novita", logo: NovitaLogo, options: (settings) => <NovitaLLMOptions settings={settings} />, description: "Reliable, Scalable, and Cost-Effective for LLMs from Novita AI", requiredConfig: ["NovitaLLMApiKey"], }, { name: "CometAPI", value: "cometapi", logo: CometApiLogo, options: (settings) => <CometApiLLMOptions settings={settings} />, description: "500+ AI Models all in one API.", requiredConfig: ["CometApiLLMApiKey"], }, { name: "Microsoft Foundry Local", value: "foundry", logo: FoundryLogo, options: (settings) => <FoundryOptions settings={settings} />, description: "Run Microsoft's Foundry models locally.", requiredConfig: [ "FoundryBasePath", "FoundryModelPref", "FoundryModelTokenLimit", ], }, { name: "xAI", value: "xai", logo: XAILogo, options: (settings) => <XAILLMOptions settings={settings} />, description: "Run xAI's powerful LLMs like Grok-2 and more.", requiredConfig: ["XAIApiKey", "XAIModelPref"], }, { name: "Z.AI", value: "zai", logo: ZAiLogo, options: (settings) => <ZAiLLMOptions settings={settings} />, description: "Run Z.AI's powerful GLM models.", requiredConfig: ["ZAiApiKey"], }, { name: "GiteeAI", value: "giteeai", logo: GiteeAILogo, options: (settings) => <GiteeAIOptions settings={settings} />, description: "Run GiteeAI's powerful LLMs.", requiredConfig: ["GiteeAIApiKey"], }, { name: "Generic OpenAI", value: "generic-openai", logo: GenericOpenAiLogo, options: (settings) => <GenericOpenAiOptions settings={settings} />, description: "Connect to any OpenAi-compatible service via a custom configuration", requiredConfig: [ "GenericOpenAiBasePath", "GenericOpenAiModelPref", "GenericOpenAiTokenLimit", "GenericOpenAiKey", ], }, ]; export default function GeneralLLMPreference() { const [saving, setSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); const [settings, setSettings] = useState(null); const [loading, setLoading] = useState(true); const [searchQuery, setSearchQuery] = useState(""); const [filteredLLMs, setFilteredLLMs] = useState([]); const [selectedLLM, setSelectedLLM] = useState(null); const [searchMenuOpen, setSearchMenuOpen] = useState(false); const searchInputRef = useRef(null); const { t } = useTranslation(); const handleSubmit = async (e) => { e.preventDefault(); const form = e.target; const data = { LLMProvider: selectedLLM }; const formData = new FormData(form); for (var [key, value] of formData.entries()) data[key] = value; const { error } = await System.updateSystem(data); setSaving(true); if (error) { showToast(`Failed to save LLM settings: ${error}`, "error"); } else { showToast("LLM preferences saved successfully.", "success"); } setSaving(false); setHasChanges(!!error); }; const updateLLMChoice = (selection) => { setSearchQuery(""); setSelectedLLM(selection); setSearchMenuOpen(false); setHasChanges(true); }; const handleXButton = () => { if (searchQuery.length > 0) { setSearchQuery(""); if (searchInputRef.current) searchInputRef.current.value = ""; } else { setSearchMenuOpen(!searchMenuOpen); } }; useEffect(() => { async function fetchKeys() { const _settings = await System.keys(); setSettings(_settings); setSelectedLLM(_settings?.LLMProvider); setLoading(false); } fetchKeys(); }, []); useEffect(() => { const filtered = AVAILABLE_LLM_PROVIDERS.filter((llm) => llm.name.toLowerCase().includes(searchQuery.toLowerCase()) ); setFilteredLLMs(filtered); }, [searchQuery, selectedLLM]); const selectedLLMObject = AVAILABLE_LLM_PROVIDERS.find( (llm) => llm.value === selectedLLM ); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> {loading ? ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="w-full h-full flex justify-center items-center"> <PreLoader /> </div> </div> ) : ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <form onSubmit={handleSubmit} className="flex w-full"> <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="flex gap-x-4 items-center"> <p className="text-lg leading-6 font-bold text-white"> {t("llm.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> {t("llm.description")} </p> </div> <div className="w-full justify-end flex"> {hasChanges && ( <CTAButton onClick={() => handleSubmit()} className="mt-3 mr-0 -mb-14 z-10" > {saving ? "Saving..." : "Save changes"} </CTAButton> )} </div> <div className="text-base font-bold text-white mt-6 mb-4"> {t("llm.provider")} </div> <div className="relative"> {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 all 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-white 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 ( <LLMItem key={llm.name} name={llm.name} value={llm.value} image={llm.logo} description={llm.description} 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 || AnythingLLMIcon} 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 || "None selected"} </div> <div className="mt-1 text-xs text-description"> {selectedLLMObject?.description || "You need to select an LLM"} </div> </div> </div> <CaretUpDown size={24} weight="bold" className="text-white" /> </button> )} </div> <div onChange={() => setHasChanges(true)} className="mt-4 flex flex-col gap-y-1" > {selectedLLM && AVAILABLE_LLM_PROVIDERS.find( (llm) => llm.value === selectedLLM )?.options?.(settings)} </div> </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/GeneralSettings/TranscriptionPreference/index.jsx
frontend/src/pages/GeneralSettings/TranscriptionPreference/index.jsx
import React, { useEffect, useState, useRef } from "react"; import { isMobile } from "react-device-detect"; import Sidebar from "@/components/SettingsSidebar"; import System from "@/models/system"; import showToast from "@/utils/toast"; import PreLoader from "@/components/Preloader"; import OpenAiLogo from "@/media/llmprovider/openai.png"; import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png"; import OpenAiWhisperOptions from "@/components/TranscriptionSelection/OpenAiOptions"; import NativeTranscriptionOptions from "@/components/TranscriptionSelection/NativeTranscriptionOptions"; import LLMItem from "@/components/LLMSelection/LLMItem"; import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react"; import CTAButton from "@/components/lib/CTAButton"; import { useTranslation } from "react-i18next"; const PROVIDERS = [ { name: "OpenAI", value: "openai", logo: OpenAiLogo, options: (settings) => <OpenAiWhisperOptions settings={settings} />, description: "Leverage the OpenAI Whisper-large model using your API key.", }, { name: "AnythingLLM Built-In", value: "local", logo: AnythingLLMIcon, options: (settings) => <NativeTranscriptionOptions settings={settings} />, description: "Run a built-in whisper model on this instance privately.", }, ]; export default function TranscriptionModelPreference() { const [saving, setSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); const [settings, setSettings] = useState(null); const [loading, setLoading] = useState(true); const [searchQuery, setSearchQuery] = useState(""); const [filteredProviders, setFilteredProviders] = useState([]); const [selectedProvider, setSelectedProvider] = useState(null); const [searchMenuOpen, setSearchMenuOpen] = useState(false); const searchInputRef = useRef(null); const { t } = useTranslation(); const handleSubmit = async (e) => { e.preventDefault(); const form = e.target; const data = { WhisperProvider: selectedProvider }; const formData = new FormData(form); for (var [key, value] of formData.entries()) data[key] = value; const { error } = await System.updateSystem(data); setSaving(true); if (error) { showToast(`Failed to save preferences: ${error}`, "error"); } else { showToast("Transcription preferences saved successfully.", "success"); } setSaving(false); setHasChanges(!!error); }; const updateProviderChoice = (selection) => { setSearchQuery(""); setSelectedProvider(selection); setSearchMenuOpen(false); setHasChanges(true); }; const handleXButton = () => { if (searchQuery.length > 0) { setSearchQuery(""); if (searchInputRef.current) searchInputRef.current.value = ""; } else { setSearchMenuOpen(!searchMenuOpen); } }; useEffect(() => { async function fetchKeys() { const _settings = await System.keys(); setSettings(_settings); setSelectedProvider(_settings?.WhisperProvider || "local"); setLoading(false); } fetchKeys(); }, []); useEffect(() => { const filtered = PROVIDERS.filter((provider) => provider.name.toLowerCase().includes(searchQuery.toLowerCase()) ); setFilteredProviders(filtered); }, [searchQuery, selectedProvider]); const selectedProviderObject = PROVIDERS.find( (provider) => provider.value === selectedProvider ); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> {loading ? ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="w-full h-full flex justify-center items-center"> <PreLoader /> </div> </div> ) : ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <form onSubmit={handleSubmit} className="flex w-full"> <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] py-16 md:py-6"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="flex gap-x-4 items-center"> <p className="text-lg leading-6 font-bold text-white"> {t("transcription.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> {t("transcription.description")} </p> </div> <div className="w-full justify-end flex"> {hasChanges && ( <CTAButton onClick={() => handleSubmit()} className="mt-3 mr-0 -mb-14 z-10" > {saving ? "Saving..." : "Save changes"} </CTAButton> )} </div> <div className="text-base font-bold text-white mt-6 mb-4"> {t("transcription.provider")} </div> <div className="relative"> {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="provider-search" autoComplete="off" placeholder="Search audio transcription 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 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-white 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]"> {filteredProviders.map((provider) => ( <LLMItem key={provider.name} name={provider.name} value={provider.value} image={provider.logo} description={provider.description} checked={selectedProvider === provider.value} onClick={() => updateProviderChoice(provider.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={selectedProviderObject.logo} alt={`${selectedProviderObject.name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col text-left"> <div className="text-sm font-semibold text-white"> {selectedProviderObject.name} </div> <div className="mt-1 text-xs text-description"> {selectedProviderObject.description} </div> </div> </div> <CaretUpDown size={24} weight="bold" className="text-white" /> </button> )} </div> <div onChange={() => setHasChanges(true)} className="mt-4 flex flex-col gap-y-1" > {selectedProvider && PROVIDERS.find( (provider) => provider.value === selectedProvider )?.options(settings)} </div> </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/GeneralSettings/ChatEmbedWidgets/index.jsx
frontend/src/pages/GeneralSettings/ChatEmbedWidgets/index.jsx
import { useState } from "react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import { CaretLeft, CaretRight } from "@phosphor-icons/react"; import { useTranslation } from "react-i18next"; import EmbedConfigsView from "./EmbedConfigs"; import EmbedChatsView from "./EmbedChats"; export default function ChatEmbedWidgets() { const { t } = useTranslation(); const [selectedView, setSelectedView] = useState("configs"); const [showViewModal, setShowViewModal] = useState(false); if (isMobile) { return ( <WidgetLayout> <div className="flex flex-col w-full p-4 mt-10"> <div hidden={showViewModal} className="flex flex-col gap-y-[18px] overflow-y-scroll no-scroll" > <div className="text-theme-text-primary flex items-center gap-x-2"> <p className="text-lg font-medium">Chat Embed</p> </div> <WidgetList selectedView={selectedView} handleClick={(view) => { setSelectedView(view); setShowViewModal(true); }} /> </div> {showViewModal && ( <div className="fixed top-0 left-0 w-full h-full bg-sidebar z-30"> <div className="flex flex-col h-full"> <div className="flex items-center p-4"> <button type="button" onClick={() => { setShowViewModal(false); setSelectedView(""); }} className="text-white/60 hover:text-white transition-colors duration-200" > <div className="flex items-center text-sky-400"> <CaretLeft size={24} /> <div>Back</div> </div> </button> </div> <div className="flex-1 overflow-y-auto p-4"> <div className="bg-theme-bg-secondary text-white rounded-xl p-4 overflow-y-scroll no-scroll"> {selectedView === "configs" ? ( <EmbedConfigsView /> ) : ( <EmbedChatsView /> )} </div> </div> </div> </div> )} </div> </WidgetLayout> ); } return ( <WidgetLayout> <div className="flex-1 flex gap-x-6 p-4 mt-10"> <div className="flex flex-col min-w-[360px] h-[calc(100vh-90px)]"> <div className="flex-none mb-4"> <div className="text-theme-text-primary flex items-center gap-x-2"> <p className="text-lg font-medium">Chat Embed</p> </div> </div> <div className="flex-1 overflow-y-auto pr-2 pb-4"> <div className="space-y-4"> <WidgetList selectedView={selectedView} handleClick={setSelectedView} /> </div> </div> </div> <div className="flex-[2] flex flex-col gap-y-[18px] mt-10"> <div className="bg-theme-bg-secondary text-white rounded-xl flex-1 p-4 overflow-y-scroll no-scroll"> {selectedView === "configs" ? ( <EmbedConfigsView /> ) : ( <EmbedChatsView /> )} </div> </div> </div> </WidgetLayout> ); } function WidgetLayout({ children }) { return ( <div id="workspace-widget-settings-container" className="w-screen h-screen overflow-hidden bg-theme-bg-container flex md:mt-0 mt-6" > <Sidebar /> <div style={{ height: isMobile ? "100%" : "calc(100% - 32px)" }} className="relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] w-full h-full flex" > {children} </div> </div> ); } function WidgetList({ selectedView, handleClick }) { const views = { configs: { title: "Widgets", }, chats: { title: "History", }, }; return ( <div className={`bg-theme-bg-secondary text-white rounded-xl ${isMobile ? "w-full" : "min-w-[360px] w-fit"}`} > {Object.entries(views).map(([view, settings], index) => ( <div key={view} className={`py-3 px-4 flex items-center justify-between ${ index === 0 ? "rounded-t-xl" : "" } ${ index === Object.keys(views).length - 1 ? "rounded-b-xl" : "border-b border-white/10" } cursor-pointer transition-all duration-300 hover:bg-theme-bg-primary ${ selectedView === view ? "bg-white/10 light:bg-theme-bg-sidebar" : "" }`} onClick={() => handleClick?.(view)} > <div className="text-sm font-light">{settings.title}</div> <CaretRight size={14} weight="bold" className="text-theme-text-secondary" /> </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/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/index.jsx
frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/index.jsx
import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; import { CodeBlock } from "@phosphor-icons/react"; import EmbedRow from "./EmbedRow"; import NewEmbedModal from "./NewEmbedModal"; import { useModal } from "@/hooks/useModal"; import ModalWrapper from "@/components/ModalWrapper"; import Embed from "@/models/embed"; import CTAButton from "@/components/lib/CTAButton"; export default function EmbedConfigsView() { const { isOpen, openModal, closeModal } = useModal(); const { t } = useTranslation(); const [loading, setLoading] = useState(true); const [embeds, setEmbeds] = useState([]); useEffect(() => { async function fetchUsers() { const _embeds = await Embed.embeds(); setEmbeds(_embeds); setLoading(false); } fetchUsers(); }, []); 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" containerClassName="flex w-full" /> ); } return ( <div className="flex flex-col w-full p-4"> <div className="w-full flex flex-col gap-y-1 pb-6"> <div className="items-center flex gap-x-4"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> {t("embeddable.title")} </p> </div> <div className="flex gap-x-10 mr-8"> <p className="text-xs leading-[18px] font-base text-theme-text-secondary mt-2"> {t("embeddable.description")} </p> <div> <CTAButton onClick={openModal} className="text-theme-bg-chat"> <CodeBlock className="h-4 w-4" weight="bold" />{" "} {t("embeddable.create")} </CTAButton> </div> </div> </div> <div className="overflow-x-auto"> <table className="w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0"> <thead className="text-theme-text-secondary text-xs leading-[18px] uppercase border-white/10 border-b"> <tr> <th scope="col" className="px-6 py-3"> {t("embeddable.table.workspace")} </th> <th scope="col" className="px-6 py-3"> {t("embeddable.table.chats")} </th> <th scope="col" className="px-6 py-3"> {t("embeddable.table.active")} </th> <th scope="col" className="px-6 py-3"> {t("embeddable.table.created")} </th> <th scope="col" className="px-6 py-3"> {" "} </th> </tr> </thead> <tbody> {embeds.map((embed) => ( <EmbedRow key={embed.id} embed={embed} /> ))} </tbody> </table> </div> <ModalWrapper isOpen={isOpen}> <NewEmbedModal closeModal={closeModal} /> </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/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/NewEmbedModal/index.jsx
frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/NewEmbedModal/index.jsx
import React, { useEffect, useState } from "react"; import { X } from "@phosphor-icons/react"; import Workspace from "@/models/workspace"; import { TagsInput } from "react-tag-input-component"; import Embed from "@/models/embed"; export function enforceSubmissionSchema(form) { const data = {}; for (var [key, value] of form.entries()) { if (!value || value === null) continue; data[key] = value; if (value === "on") data[key] = true; } // Always set value on nullable keys since empty or off will not send anything from form element. if (!data.hasOwnProperty("allowlist_domains")) data.allowlist_domains = null; if (!data.hasOwnProperty("allow_model_override")) data.allow_model_override = false; if (!data.hasOwnProperty("allow_temperature_override")) data.allow_temperature_override = false; if (!data.hasOwnProperty("allow_prompt_override")) data.allow_prompt_override = false; if (!data.hasOwnProperty("message_limit")) data.message_limit = 20; return data; } export default function NewEmbedModal({ closeModal }) { const [error, setError] = useState(null); const handleCreate = async (e) => { setError(null); e.preventDefault(); const form = new FormData(e.target); const data = enforceSubmissionSchema(form); const { embed, error } = await Embed.newEmbed(data); if (!!embed) window.location.reload(); setError(error); }; return ( <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"> Create new embed for workspace </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> <div className="px-7 py-6"> <form onSubmit={handleCreate}> <div className="space-y-6 max-h-[60vh] overflow-y-auto pr-2"> <WorkspaceSelection /> <ChatModeSelection /> <PermittedDomains /> <NumberInput name="max_chats_per_day" title="Max chats per day" hint="Limit the amount of chats this embedded chat can process in a 24 hour period. Zero is unlimited." /> <NumberInput name="max_chats_per_session" title="Max chats per session" hint="Limit the amount of chats a session user can send with this embed in a 24 hour period. Zero is unlimited." /> <NumberInput name="message_limit" title="Message History Limit" hint="The number of previous messages to include in the chat context. Default is 20." defaultValue={20} /> <BooleanInput name="allow_model_override" title="Enable dynamic model use" hint="Allow setting of the preferred LLM model to override the workspace default." /> <BooleanInput name="allow_temperature_override" title="Enable dynamic LLM temperature" hint="Allow setting of the LLM temperature to override the workspace default." /> <BooleanInput name="allow_prompt_override" title="Enable Prompt Override" hint="Allow setting of the system prompt to override the workspace default." /> {error && <p className="text-red-400 text-sm">Error: {error}</p>} <p className="text-white text-opacity-60 text-xs md:text-sm"> After creating an embed you will be provided a link that you can publish on your website with a simple <code className="light:bg-stone-300 bg-stone-900 text-white mx-1 px-1 rounded-sm"> &lt;script&gt; </code>{" "} tag. </p> </div> <div className="flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border"> <button onClick={closeModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > 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" > Create embed </button> </div> </form> </div> </div> </div> ); } export const WorkspaceSelection = ({ defaultValue = null }) => { const [workspaces, setWorkspaces] = useState([]); useEffect(() => { async function fetchWorkspaces() { const _workspaces = await Workspace.all(); setWorkspaces(_workspaces); } fetchWorkspaces(); }, []); return ( <div> <div className="flex flex-col mb-2"> <label htmlFor="workspace_id" className="block text-sm font-medium text-white" > Workspace </label> <p className="text-theme-text-secondary text-xs"> This is the workspace your chat window will be based on. All defaults will be inherited from the workspace unless overridden by this config. </p> </div> <select name="workspace_id" required={true} defaultValue={defaultValue} className="min-w-[15rem] rounded-lg bg-theme-settings-input-bg px-4 py-2 text-sm text-white focus:ring-blue-500 focus:border-blue-500" > {workspaces.map((workspace) => { return ( <option key={workspace.id} selected={defaultValue === workspace.id} value={workspace.id} > {workspace.name} </option> ); })} </select> </div> ); }; export const ChatModeSelection = ({ defaultValue = null }) => { const [chatMode, setChatMode] = useState(defaultValue ?? "query"); return ( <div> <div className="flex flex-col mb-2"> <label className="block text-sm font-medium text-white" htmlFor="chat_mode" > Allowed chat method </label> <p className="text-theme-text-secondary text-xs"> Set how your chatbot should operate. Query means it will only respond if a document helps answer the query. <br /> Chat opens the chat to even general questions and can answer totally unrelated queries to your workspace. </p> </div> <div className="mt-2 gap-y-3 flex flex-col"> <label className={`transition-all duration-300 w-full h-11 p-2.5 rounded-lg flex justify-start items-center gap-2.5 cursor-pointer border ${ chatMode === "chat" ? "border-theme-sidebar-item-workspace-active bg-theme-bg-secondary" : "border-theme-sidebar-border hover:border-theme-sidebar-border hover:bg-theme-bg-secondary" } `} > <input type="radio" name="chat_mode" value={"chat"} checked={chatMode === "chat"} onChange={(e) => setChatMode(e.target.value)} className="hidden" /> <div className={`w-4 h-4 rounded-full border-2 border-theme-sidebar-border mr-2 ${ chatMode === "chat" ? "bg-[var(--theme-sidebar-item-workspace-active)]" : "" }`} ></div> <div className="text-theme-text-primary text-sm font-medium font-['Plus Jakarta Sans'] leading-tight"> Chat: Respond to all questions regardless of context </div> </label> <label className={`transition-all duration-300 w-full h-11 p-2.5 rounded-lg flex justify-start items-center gap-2.5 cursor-pointer border ${ chatMode === "query" ? "border-theme-sidebar-item-workspace-active bg-theme-bg-secondary" : "border-theme-sidebar-border hover:border-theme-sidebar-border hover:bg-theme-bg-secondary" } `} > <input type="radio" name="chat_mode" value={"query"} checked={chatMode === "query"} onChange={(e) => setChatMode(e.target.value)} className="hidden" /> <div className={`w-4 h-4 rounded-full border-2 border-theme-sidebar-border mr-2 ${ chatMode === "query" ? "bg-[var(--theme-sidebar-item-workspace-active)]" : "" }`} ></div> <div className="text-theme-text-primary text-sm font-medium font-['Plus Jakarta Sans'] leading-tight"> Query: Only respond to chats related to documents in workspace </div> </label> </div> </div> ); }; export const PermittedDomains = ({ defaultValue = [] }) => { const [domains, setDomains] = useState(defaultValue); const handleChange = (data) => { const validDomains = data .map((input) => { let url = input; if (!url.includes("http://") && !url.includes("https://")) url = `https://${url}`; try { new URL(url); return url; } catch { return null; } }) .filter((u) => !!u); setDomains(validDomains); }; const handleBlur = (event) => { const currentInput = event.target.value; if (!currentInput) return; const validDomains = [...domains, currentInput].map((input) => { let url = input; if (!url.includes("http://") && !url.includes("https://")) url = `https://${url}`; try { new URL(url); return url; } catch { return null; } }); event.target.value = ""; setDomains(validDomains); }; return ( <div> <div className="flex flex-col mb-2"> <label htmlFor="allowlist_domains" className="block text-sm font-medium text-white" > Restrict requests from domains </label> <p className="text-theme-text-secondary text-xs"> This filter will block any requests that come from a domain other than the list below. <br /> Leaving this empty means anyone can use your embed on any site. </p> </div> <input type="hidden" name="allowlist_domains" value={domains.join(",")} /> <TagsInput value={domains} onChange={handleChange} onBlur={handleBlur} placeholder="https://mysite.com, https://anythingllm.com" classNames={{ tag: "bg-theme-settings-input-bg light:bg-black/10 bg-blue-300/10 text-zinc-800", input: "flex p-1 !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", }} /> </div> ); }; export const NumberInput = ({ name, title, hint, defaultValue = 0 }) => { return ( <div> <div className="flex flex-col mb-2"> <label htmlFor={name} className="block text-sm font-medium text-white"> {title} </label> <p className="text-theme-text-secondary text-xs">{hint}</p> </div> <input type="number" name={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-[15rem] p-2.5" min={0} defaultValue={defaultValue} onScroll={(e) => e.target.blur()} /> </div> ); }; export const BooleanInput = ({ name, title, hint, defaultValue = null }) => { const [status, setStatus] = useState(defaultValue ?? false); return ( <div> <div className="flex flex-col mb-2"> <label htmlFor={name} className="block text-sm font-medium text-white"> {title} </label> <p className="text-theme-text-secondary text-xs">{hint}</p> </div> <label className="relative inline-flex cursor-pointer items-center"> <input name={name} type="checkbox" onClick={() => setStatus(!status)} checked={status} className="peer sr-only pointer-events-none" /> <div className="peer-disabled:opacity-50 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> ); };
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/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/EmbedRow/index.jsx
frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/EmbedRow/index.jsx
import { useRef, useState } from "react"; import { DotsThreeOutline } from "@phosphor-icons/react"; import showToast from "@/utils/toast"; import { useModal } from "@/hooks/useModal"; import ModalWrapper from "@/components/ModalWrapper"; import Embed from "@/models/embed"; import paths from "@/utils/paths"; import { nFormatter } from "@/utils/numbers"; import EditEmbedModal from "./EditEmbedModal"; import CodeSnippetModal from "./CodeSnippetModal"; import moment from "moment"; import { safeJsonParse } from "@/utils/request"; export default function EmbedRow({ embed }) { const rowRef = useRef(null); const [enabled, setEnabled] = useState(Number(embed.enabled) === 1); const { isOpen: isSettingsOpen, openModal: openSettingsModal, closeModal: closeSettingsModal, } = useModal(); const { isOpen: isSnippetOpen, openModal: openSnippetModal, closeModal: closeSnippetModal, } = useModal(); const handleSuspend = async () => { if ( !window.confirm( `Are you sure you want to disabled this embed?\nOnce disabled the embed will no longer respond to any chat requests.` ) ) return false; const { success, error } = await Embed.updateEmbed(embed.id, { enabled: !enabled, }); if (!success) showToast(error, "error", { clear: true }); if (success) { showToast( `Embed ${enabled ? "has been disabled" : "is active"}.`, "success", { clear: true } ); setEnabled(!enabled); } }; const handleDelete = async () => { if ( !window.confirm( `Are you sure you want to delete this embed?\nOnce deleted this embed will no longer respond to chats or be active.\n\nThis action is irreversible.` ) ) return false; const { success, error } = await Embed.deleteEmbed(embed.id); if (!success) showToast(error, "error", { clear: true }); if (success) { rowRef?.current?.remove(); showToast("Embed deleted from system.", "success", { clear: true }); } }; return ( <> <tr ref={rowRef} className="bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10" > <th scope="row" className="px-6 whitespace-nowrap flex item-center gap-x-1" > <a href={paths.workspace.chat(embed.workspace.slug)} target="_blank" rel="noreferrer" className="text-white flex items-center hover:underline" > {embed.workspace.name} </a> </th> <th scope="row" className="px-6 whitespace-nowrap"> {nFormatter(embed._count.embed_chats)} </th> <th scope="row" className="px-6 whitespace-nowrap"> <ActiveDomains domainList={embed.allowlist_domains} /> </th> <th scope="row" className="px-6 whitespace-nowrap text-theme-text-secondary !font-normal" > { // If the embed was created more than a day ago, show the date, otherwise show the time ago moment(embed.createdAt).diff(moment(), "days") > 0 ? moment(embed.createdAt).format("MMM D, YYYY") : moment(embed.createdAt).fromNow() } </th> <td className="px-6 flex items-center gap-x-6 h-full mt-1"> <button onClick={openSnippetModal} className="group text-xs font-medium text-theme-text-secondary px-2 py-1 rounded-lg hover:bg-theme-button-code-hover-bg" > <span className="group-hover:text-theme-button-code-hover-text"> Code </span> </button> <button onClick={handleSuspend} className="group text-xs font-medium text-theme-text-secondary px-2 py-1 rounded-lg hover:bg-theme-button-disable-hover-bg" > <span className="group-hover:text-theme-button-disable-hover-text"> {enabled ? "Disable" : "Enable"} </span> </button> <button onClick={handleDelete} className="group text-xs font-medium text-theme-text-secondary px-2 py-1 rounded-lg hover:bg-theme-button-delete-hover-bg" > <span className="group-hover:text-theme-button-delete-hover-text"> Delete </span> </button> <button onClick={openSettingsModal} className="text-xs font-medium text-theme-button-text hover:text-theme-text-secondary hover:bg-theme-hover px-2 py-1 rounded-lg" > <DotsThreeOutline weight="fill" className="h-5 w-5" /> </button> </td> </tr> <ModalWrapper isOpen={isSettingsOpen}> <EditEmbedModal embed={embed} closeModal={closeSettingsModal} /> </ModalWrapper> <ModalWrapper isOpen={isSnippetOpen}> <CodeSnippetModal embed={embed} closeModal={closeSnippetModal} /> </ModalWrapper> </> ); } function ActiveDomains({ domainList }) { const domains = safeJsonParse(domainList, []); if (domains.length === 0) return <p>all</p>; return ( <div className="flex flex-col gap-y-2"> {domains.map((domain, index) => { return ( <p key={index} className="font-mono !font-normal"> {domain} </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/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/EmbedRow/EditEmbedModal/index.jsx
frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/EmbedRow/EditEmbedModal/index.jsx
import React, { useState } from "react"; import { X } from "@phosphor-icons/react"; import { BooleanInput, ChatModeSelection, NumberInput, PermittedDomains, WorkspaceSelection, enforceSubmissionSchema, } from "../../NewEmbedModal"; import Embed from "@/models/embed"; import showToast from "@/utils/toast"; import { safeJsonParse } from "@/utils/request"; export default function EditEmbedModal({ embed, closeModal }) { const [error, setError] = useState(null); const handleUpdate = async (e) => { setError(null); e.preventDefault(); const form = new FormData(e.target); const data = enforceSubmissionSchema(form); const { success, error } = await Embed.updateEmbed(embed.id, data); if (success) { showToast("Embed updated successfully.", "success", { clear: true }); setTimeout(() => { window.location.reload(); }, 800); } setError(error); }; return ( <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"> Update embed #{embed.id} </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> <div className="px-7 py-6"> <form onSubmit={handleUpdate}> <div className="space-y-6 max-h-[60vh] overflow-y-auto pr-2"> <WorkspaceSelection defaultValue={embed.workspace.id} /> <ChatModeSelection defaultValue={embed.chat_mode} /> <PermittedDomains defaultValue={ safeJsonParse(embed.allowlist_domains, null) || [] } /> <NumberInput name="max_chats_per_day" title="Max chats per day" hint="Limit the amount of chats this embedded chat can process in a 24 hour period. Zero is unlimited." defaultValue={embed.max_chats_per_day} /> <NumberInput name="max_chats_per_session" title="Max chats per session" hint="Limit the amount of chats a session user can send with this embed in a 24 hour period. Zero is unlimited." defaultValue={embed.max_chats_per_session} /> <NumberInput name="message_limit" title="Message History Limit" hint="The number of previous messages to include in the chat context. Default is 20." defaultValue={embed.message_limit} /> <BooleanInput name="allow_model_override" title="Enable dynamic model use" hint="Allow setting of the preferred LLM model to override the workspace default." defaultValue={embed.allow_model_override} /> <BooleanInput name="allow_temperature_override" title="Enable dynamic LLM temperature" hint="Allow setting of the LLM temperature to override the workspace default." defaultValue={embed.allow_temperature_override} /> <BooleanInput name="allow_prompt_override" title="Enable Prompt Override" hint="Allow setting of the system prompt to override the workspace default." defaultValue={embed.allow_prompt_override} /> {error && <p className="text-red-400 text-sm">Error: {error}</p>} <p className="text-white text-opacity-60 text-xs md:text-sm"> After creating an embed you will be provided a link that you can publish on your website with a simple <code className="border-none bg-theme-settings-input-bg text-white mx-1 px-1 rounded-sm"> &lt;script&gt; </code>{" "} tag. </p> </div> <div className="flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border"> <button onClick={closeModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > 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" > Update embed </button> </div> </form> </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/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/EmbedRow/CodeSnippetModal/index.jsx
frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/EmbedRow/CodeSnippetModal/index.jsx
import React, { useState } from "react"; import { CheckCircle, CopySimple, X } from "@phosphor-icons/react"; import showToast from "@/utils/toast"; import hljs from "highlight.js"; import "@/utils/chat/themes/github-dark.css"; import "@/utils/chat/themes/github.css"; export default function CodeSnippetModal({ embed, closeModal }) { return ( <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"> Copy your embed code </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> <div className="px-7 py-6"> <div className="space-y-6 max-h-[60vh] overflow-y-auto pr-2"> <ScriptTag embed={embed} /> </div> <div className="flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border"> <button onClick={closeModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > Close </button> <div hidden={true} /> </div> </div> </div> </div> ); } function createScriptTagSnippet(embed, scriptHost, serverHost) { return `<!-- Paste this script at the bottom of your HTML before the </body> tag. See more style and config options on our docs https://github.com/Mintplex-Labs/anythingllm-embed/blob/main/README.md --> <script data-embed-id="${embed.uuid}" data-base-api-url="${serverHost}/api/embed" src="${scriptHost}/embed/anythingllm-chat-widget.min.js"> </script> <!-- AnythingLLM (https://anythingllm.com) --> `; } const ScriptTag = ({ embed }) => { const [copied, setCopied] = useState(false); const scriptHost = import.meta.env.DEV ? "http://localhost:3000" : window.location.origin; const serverHost = import.meta.env.DEV ? "http://localhost:3001" : window.location.origin; const snippet = createScriptTagSnippet(embed, scriptHost, serverHost); const theme = window.localStorage.getItem("theme") === "light" ? "github" : "github-dark"; const handleClick = () => { window.navigator.clipboard.writeText(snippet); setCopied(true); setTimeout(() => { setCopied(false); }, 2500); showToast("Snippet copied to clipboard!", "success", { clear: true }); }; return ( <div> <div className="flex flex-col mb-2"> <label className="block text-sm font-medium text-white"> HTML Script Tag Embed Code </label> <p className="text-theme-text-secondary text-xs"> Have your workspace chat embed function like a help desk chat bottom in the corner of your website. </p> <a href="https://github.com/Mintplex-Labs/anythingllm-embed/blob/main/README.md" target="_blank" rel="noreferrer" className="text-blue-300 light:text-blue-500 hover:underline" > View all style and configuration options &rarr; </a> </div> <button disabled={copied} onClick={handleClick} className={`disabled:border disabled:border-green-300 disabled:light:border-green-600 border border-transparent relative w-full font-mono flex hljs ${theme} light:border light:border-gray-700 text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5 m-1`} > <div className="flex w-full text-left flex-col gap-y-1 pr-6 pl-4 whitespace-pre-line" dangerouslySetInnerHTML={{ __html: hljs.highlight(snippet, { language: "html", ignoreIllegals: true, }).value, }} /> {copied ? ( <CheckCircle size={14} className="text-green-300 light:text-green-600 absolute top-2 right-2" /> ) : ( <CopySimple size={14} className="absolute top-2 right-2" /> )} </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/GeneralSettings/ChatEmbedWidgets/EmbedChats/MarkdownRenderer.jsx
frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedChats/MarkdownRenderer.jsx
import { useState } from "react"; import MarkdownIt from "markdown-it"; import hljs from "highlight.js"; import { CaretDown } from "@phosphor-icons/react"; import "highlight.js/styles/github-dark.css"; import DOMPurify from "@/utils/chat/purify"; const md = new MarkdownIt({ html: true, breaks: true, highlight: function (str, lang) { if (lang && hljs.getLanguage(lang)) { try { return hljs.highlight(str, { language: lang }).value; } catch (__) {} } return ""; // use external default escaping }, }); const ThoughtBubble = ({ thought }) => { const [isExpanded, setIsExpanded] = useState(false); if (!thought) return null; const cleanThought = thought.replace(/<\/?think>/g, "").trim(); if (!cleanThought) return null; return ( <div className="mb-3"> <div onClick={() => setIsExpanded(!isExpanded)} className="cursor-pointer flex items-center gap-x-2 text-theme-text-secondary hover:text-theme-text-primary transition-colors mb-2" > <CaretDown size={14} weight="bold" className={`transition-transform ${isExpanded ? "rotate-180" : ""}`} /> <span className="text-xs font-medium">View thoughts</span> </div> {isExpanded && ( <div className="bg-theme-bg-chat-input rounded-md p-3 border-l-2 border-theme-text-secondary/30"> <div className="text-xs text-theme-text-secondary font-mono whitespace-pre-wrap"> {cleanThought} </div> </div> )} </div> ); }; function parseContent(content) { const parts = []; let lastIndex = 0; content.replace(/<think>([^]*?)<\/think>/g, (match, thinkContent, offset) => { if (offset > lastIndex) { parts.push({ type: "normal", text: content.slice(lastIndex, offset) }); } parts.push({ type: "think", text: thinkContent }); lastIndex = offset + match.length; }); if (lastIndex < content.length) { parts.push({ type: "normal", text: content.slice(lastIndex) }); } return parts; } export default function MarkdownRenderer({ content }) { if (!content) return null; const parts = parseContent(content); return ( <div className="whitespace-normal"> {parts.map((part, index) => { const html = md.render(part.text); if (part.type === "think") return <ThoughtBubble key={index} thought={part.text} />; return ( <div key={index} dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(html) }} /> ); })} </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/GeneralSettings/ChatEmbedWidgets/EmbedChats/index.jsx
frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedChats/index.jsx
import { useEffect, useState, useRef } from "react"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; import useQuery from "@/hooks/useQuery"; import ChatRow from "./ChatRow"; import Embed from "@/models/embed"; import { useTranslation } from "react-i18next"; import { CaretDown, Download } from "@phosphor-icons/react"; import showToast from "@/utils/toast"; import { saveAs } from "file-saver"; import System from "@/models/system"; const exportOptions = { csv: { name: "CSV", mimeType: "text/csv", fileExtension: "csv", filenameFunc: () => { return `anythingllm-embed-chats-${new Date().toLocaleDateString()}`; }, }, json: { name: "JSON", mimeType: "application/json", fileExtension: "json", filenameFunc: () => { return `anythingllm-embed-chats-${new Date().toLocaleDateString()}`; }, }, jsonl: { name: "JSONL", mimeType: "application/jsonl", fileExtension: "jsonl", filenameFunc: () => { return `anythingllm-embed-chats-${new Date().toLocaleDateString()}-lines`; }, }, jsonAlpaca: { name: "JSON (Alpaca)", mimeType: "application/json", fileExtension: "json", filenameFunc: () => { return `anythingllm-embed-chats-${new Date().toLocaleDateString()}-alpaca`; }, }, }; export default function EmbedChatsView() { const { t } = useTranslation(); const menuRef = useRef(); const query = useQuery(); const openMenuButton = useRef(); const [showMenu, setShowMenu] = useState(false); const [loading, setLoading] = useState(true); const [chats, setChats] = useState([]); const [offset, setOffset] = useState(Number(query.get("offset") || 0)); const [canNext, setCanNext] = useState(false); const handleDumpChats = async (exportType) => { const chats = await System.exportChats(exportType, "embed"); if (!!chats) { const { name, mimeType, fileExtension, filenameFunc } = exportOptions[exportType]; const blob = new Blob([chats], { type: mimeType }); saveAs(blob, `${filenameFunc()}.${fileExtension}`); showToast(`Embed chats exported successfully as ${name}.`, "success"); } else { showToast("Failed to export embed chats.", "error"); } }; const toggleMenu = () => { setShowMenu(!showMenu); }; useEffect(() => { function handleClickOutside(event) { if ( menuRef.current && !menuRef.current.contains(event.target) && !openMenuButton.current.contains(event.target) ) { setShowMenu(false); } } document.addEventListener("mousedown", handleClickOutside); return () => { document.removeEventListener("mousedown", handleClickOutside); }; }, []); useEffect(() => { async function fetchChats() { setLoading(true); await Embed.chats(offset) .then(({ chats: _chats, hasPages = false }) => { setChats(_chats); setCanNext(hasPages); }) .finally(() => { setLoading(false); }); } fetchChats(); }, [offset]); const handlePrevious = () => { setOffset(Math.max(offset - 1, 0)); }; const handleNext = () => { setOffset(offset + 1); }; const handleDeleteChat = (chatId) => { setChats((prevChats) => prevChats.filter((chat) => chat.id !== chatId)); }; 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" containerClassName="flex w-full" /> ); } return ( <div className="flex flex-col w-full p-4 overflow-none"> <div className="w-full flex flex-col gap-y-1"> <div className="flex flex-wrap gap-4 items-center"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> {t("embed-chats.title")} </p> <div className="relative"> <button ref={openMenuButton} onClick={toggleMenu} className="flex items-center gap-x-2 px-4 py-1 rounded-lg text-theme-bg-chat bg-primary-button hover:bg-secondary hover:text-white text-xs font-semibold h-[34px] w-fit" > <Download size={18} weight="bold" /> {t("embed-chats.export")} <CaretDown size={18} weight="bold" /> </button> <div ref={menuRef} className={`${ showMenu ? "slide-down" : "slide-up hidden" } z-20 w-fit rounded-lg absolute top-full right-0 bg-secondary light:bg-theme-bg-secondary mt-2 shadow-md`} > <div className="py-2"> {Object.entries(exportOptions).map(([key, data]) => ( <button key={key} onClick={() => { handleDumpChats(key); setShowMenu(false); }} className="w-full text-left px-4 py-2 text-white text-sm hover:bg-[#3D4147] light:hover:bg-theme-sidebar-item-hover" > {data.name} </button> ))} </div> </div> </div> </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary mt-2"> {t("embed-chats.description")} </p> </div> <div className="overflow-x-auto mt-6"> <table className="w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0"> <thead className="text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b"> <tr> <th scope="col" className="px-6 py-3 rounded-tl-lg"> {t("embed-chats.table.embed")} </th> <th scope="col" className="px-6 py-3"> {t("embed-chats.table.sender")} </th> <th scope="col" className="px-6 py-3"> {t("embed-chats.table.message")} </th> <th scope="col" className="px-6 py-3"> {t("embed-chats.table.response")} </th> <th scope="col" className="px-6 py-3"> {t("embed-chats.table.at")} </th> <th scope="col" className="px-6 py-3 rounded-tr-lg"> {" "} </th> </tr> </thead> <tbody> {chats.map((chat) => ( <ChatRow key={chat.id} chat={chat} onDelete={handleDeleteChat} /> ))} </tbody> </table> {(offset > 0 || canNext) && ( <div className="flex items-center justify-end gap-2 mt-4 pb-6"> <button onClick={handlePrevious} disabled={offset === 0} className={`px-4 py-2 text-sm rounded-lg ${ offset === 0 ? "bg-theme-bg-secondary text-theme-text-disabled cursor-not-allowed" : "bg-theme-bg-secondary text-theme-text-primary hover:bg-theme-hover" }`} > {t("common.previous")} </button> <button onClick={handleNext} disabled={!canNext} className={`px-4 py-2 text-sm rounded-lg ${ !canNext ? "bg-theme-bg-secondary text-theme-text-disabled cursor-not-allowed" : "bg-theme-bg-secondary text-theme-text-primary hover:bg-theme-hover" }`} > {t("common.next")} </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/GeneralSettings/ChatEmbedWidgets/EmbedChats/ChatRow/index.jsx
frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedChats/ChatRow/index.jsx
import truncate from "truncate"; import { X } from "@phosphor-icons/react"; import ModalWrapper from "@/components/ModalWrapper"; import { useModal } from "@/hooks/useModal"; import paths from "@/utils/paths"; import Embed from "@/models/embed"; import MarkdownRenderer from "../MarkdownRenderer"; import { safeJsonParse } from "@/utils/request"; export default function ChatRow({ chat, onDelete }) { const { isOpen: isPromptOpen, openModal: openPromptModal, closeModal: closePromptModal, } = useModal(); const { isOpen: isResponseOpen, openModal: openResponseModal, closeModal: closeResponseModal, } = useModal(); const { isOpen: isConnectionDetailsModalOpen, openModal: openConnectionDetailsModal, closeModal: closeConnectionDetailsModal, } = useModal(); const handleDelete = async () => { if ( !window.confirm( `Are you sure you want to delete this chat?\n\nThis action is irreversible.` ) ) return false; await Embed.deleteChat(chat.id); onDelete(chat.id); }; return ( <> <tr className="bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10"> <td className="px-6 font-medium whitespace-nowrap text-white"> <a href={paths.settings.embedChatWidgets()} target="_blank" rel="noreferrer" className="text-white flex items-center hover:underline" > {chat.embed_config.workspace.name} </a> </td> <td onClick={openConnectionDetailsModal} className="px-6 cursor-pointer hover:shadow-lg" > <div className="flex flex-col"> <p>{truncate(chat.session_id, 20)}</p> </div> </td> <td onClick={openPromptModal} className="px-6 border-transparent cursor-pointer hover:shadow-lg" > {truncate(chat.prompt, 40)} </td> <td onClick={openResponseModal} className="px-6 cursor-pointer hover:shadow-lg" > {truncate(safeJsonParse(chat.response, {})?.text, 40)} </td> <td className="px-6">{chat.createdAt}</td> <td className="px-6 flex items-center gap-x-6 h-full mt-1"> <button onClick={handleDelete} className="group text-xs font-medium text-theme-text-secondary px-2 py-1 rounded-lg hover:bg-theme-button-delete-hover-bg" > <span className="group-hover:text-theme-button-delete-hover-text"> Delete </span> </button> </td> </tr> <ModalWrapper isOpen={isPromptOpen}> <TextPreview text={chat.prompt} closeModal={closePromptModal} /> </ModalWrapper> <ModalWrapper isOpen={isResponseOpen}> <TextPreview text={ <MarkdownRenderer content={safeJsonParse(chat.response, {})?.text} /> } closeModal={closeResponseModal} /> </ModalWrapper> <ModalWrapper isOpen={isConnectionDetailsModalOpen}> <TextPreview text={ <ConnectionDetails sessionId={chat.session_id} verbose={true} connection_information={chat.connection_information} /> } closeModal={closeConnectionDetailsModal} /> </ModalWrapper> </> ); } const TextPreview = ({ text, closeModal }) => { return ( <div className="relative w-full md:max-w-2xl 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"> <h3 className="text-xl font-semibold text-white">Viewing Text</h3> <button onClick={closeModal} type="button" className="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> <div className="w-full p-6"> <div className="w-full h-[60vh] py-2 px-4 whitespace-pre-line overflow-auto rounded-lg bg-zinc-900 light:bg-theme-bg-secondary border border-gray-500 text-white text-sm"> {text} </div> </div> </div> </div> ); }; const ConnectionDetails = ({ sessionId, verbose = false, connection_information, }) => { const details = safeJsonParse(connection_information, {}); if (Object.keys(details).length === 0) return null; if (verbose) { return ( <> <p className="text-xs text-theme-text-secondary"> sessionID: {sessionId} </p> {details.username && ( <p className="text-xs text-theme-text-secondary"> username: {details.username} </p> )} {details.ip && ( <p className="text-xs text-theme-text-secondary"> client ip address: {details.ip} </p> )} {details.host && ( <p className="text-xs text-theme-text-secondary"> client host URL: {details.host} </p> )} </> ); } return ( <> {details.username && ( <p className="text-xs text-theme-text-secondary">{details.username}</p> )} {details.ip && ( <p className="text-xs text-theme-text-secondary">{details.ip}</p> )} {details.host && ( <p className="text-xs text-theme-text-secondary">{details.host}</p> )} </> ); };
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/GeneralSettings/VectorDatabase/index.jsx
frontend/src/pages/GeneralSettings/VectorDatabase/index.jsx
import React, { useState, useEffect, useRef } from "react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import System from "@/models/system"; import showToast from "@/utils/toast"; import { useModal } from "@/hooks/useModal"; import CTAButton from "@/components/lib/CTAButton"; import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react"; import { useTranslation } from "react-i18next"; import PreLoader from "@/components/Preloader"; import ChangeWarningModal from "@/components/ChangeWarning"; import ModalWrapper from "@/components/ModalWrapper"; import VectorDBItem from "@/components/VectorDBSelection/VectorDBItem"; import LanceDbLogo from "@/media/vectordbs/lancedb.png"; import ChromaLogo from "@/media/vectordbs/chroma.png"; import PineconeLogo from "@/media/vectordbs/pinecone.png"; import WeaviateLogo from "@/media/vectordbs/weaviate.png"; import QDrantLogo from "@/media/vectordbs/qdrant.png"; import MilvusLogo from "@/media/vectordbs/milvus.png"; import ZillizLogo from "@/media/vectordbs/zilliz.png"; import AstraDBLogo from "@/media/vectordbs/astraDB.png"; import PGVectorLogo from "@/media/vectordbs/pgvector.png"; import LanceDBOptions from "@/components/VectorDBSelection/LanceDBOptions"; import ChromaDBOptions from "@/components/VectorDBSelection/ChromaDBOptions"; import ChromaCloudOptions from "@/components/VectorDBSelection/ChromaCloudOptions"; import PineconeDBOptions from "@/components/VectorDBSelection/PineconeDBOptions"; import WeaviateDBOptions from "@/components/VectorDBSelection/WeaviateDBOptions"; import QDrantDBOptions from "@/components/VectorDBSelection/QDrantDBOptions"; import MilvusDBOptions from "@/components/VectorDBSelection/MilvusDBOptions"; import ZillizCloudOptions from "@/components/VectorDBSelection/ZillizCloudOptions"; import AstraDBOptions from "@/components/VectorDBSelection/AstraDBOptions"; import PGVectorOptions from "@/components/VectorDBSelection/PGVectorOptions"; const VECTOR_DBS = [ { name: "LanceDB", value: "lancedb", logo: LanceDbLogo, options: (_) => <LanceDBOptions />, description: "100% local vector DB that runs on the same instance as AnythingLLM.", }, { name: "PGVector", value: "pgvector", logo: PGVectorLogo, options: (settings) => <PGVectorOptions settings={settings} />, description: "Vector search powered by PostgreSQL.", }, { name: "Chroma", value: "chroma", logo: ChromaLogo, options: (settings) => <ChromaDBOptions settings={settings} />, description: "Open source vector database you can host yourself or on the cloud.", }, { name: "Chroma Cloud", value: "chromacloud", logo: ChromaLogo, options: (settings) => <ChromaCloudOptions settings={settings} />, description: "Fully managed Chroma cloud service with enterprise features and support.", }, { name: "Pinecone", value: "pinecone", logo: PineconeLogo, options: (settings) => <PineconeDBOptions settings={settings} />, description: "100% cloud-based vector database for enterprise use cases.", }, { name: "Zilliz Cloud", value: "zilliz", logo: ZillizLogo, options: (settings) => <ZillizCloudOptions settings={settings} />, description: "Cloud hosted vector database built for enterprise with SOC 2 compliance.", }, { name: "QDrant", value: "qdrant", logo: QDrantLogo, options: (settings) => <QDrantDBOptions settings={settings} />, description: "Open source local and distributed cloud vector database.", }, { name: "Weaviate", value: "weaviate", logo: WeaviateLogo, options: (settings) => <WeaviateDBOptions settings={settings} />, description: "Open source local and cloud hosted multi-modal vector database.", }, { name: "Milvus", value: "milvus", logo: MilvusLogo, options: (settings) => <MilvusDBOptions settings={settings} />, description: "Open-source, highly scalable, and blazing fast.", }, { name: "AstraDB", value: "astra", logo: AstraDBLogo, options: (settings) => <AstraDBOptions settings={settings} />, description: "Vector Search for Real-world GenAI.", }, ]; export default function GeneralVectorDatabase() { const [saving, setSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); const [hasEmbeddings, setHasEmbeddings] = useState(false); const [settings, setSettings] = useState({}); const [loading, setLoading] = useState(true); const [searchQuery, setSearchQuery] = useState(""); const [filteredVDBs, setFilteredVDBs] = useState([]); const [selectedVDB, setSelectedVDB] = useState(null); const [searchMenuOpen, setSearchMenuOpen] = useState(false); const searchInputRef = useRef(null); const { isOpen, openModal, closeModal } = useModal(); const { t } = useTranslation(); const handleSubmit = async (e) => { e.preventDefault(); if (selectedVDB !== settings?.VectorDB && hasChanges && hasEmbeddings) { openModal(); } else { await handleSaveSettings(); } }; const handleSaveSettings = async () => { setSaving(true); const form = document.getElementById("vectordb-form"); const settingsData = {}; const formData = new FormData(form); settingsData.VectorDB = selectedVDB; for (var [key, value] of formData.entries()) settingsData[key] = value; const { error } = await System.updateSystem(settingsData); if (error) { showToast(`Failed to save vector database settings: ${error}`, "error"); setHasChanges(true); } else { showToast("Vector database preferences saved successfully.", "success"); setHasChanges(false); } setSaving(false); closeModal(); }; const updateVectorChoice = (selection) => { setSearchQuery(""); setSelectedVDB(selection); setSearchMenuOpen(false); setHasChanges(true); }; const handleXButton = () => { if (searchQuery.length > 0) { setSearchQuery(""); if (searchInputRef.current) searchInputRef.current.value = ""; } else { setSearchMenuOpen(!searchMenuOpen); } }; useEffect(() => { async function fetchKeys() { const _settings = await System.keys(); setSettings(_settings); setSelectedVDB(_settings?.VectorDB || "lancedb"); setHasEmbeddings(_settings?.HasExistingEmbeddings || false); setLoading(false); } fetchKeys(); }, []); useEffect(() => { const filtered = VECTOR_DBS.filter((vdb) => vdb.name.toLowerCase().includes(searchQuery.toLowerCase()) ); setFilteredVDBs(filtered); }, [searchQuery, selectedVDB]); const selectedVDBObject = VECTOR_DBS.find((vdb) => vdb.value === selectedVDB) ?? VECTOR_DBS[0]; return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> {loading ? ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="w-full h-full flex justify-center items-center"> <PreLoader /> </div> </div> ) : ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <form id="vectordb-form" onSubmit={handleSubmit} className="flex w-full" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] py-16 md:py-6"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="flex gap-x-4 items-center"> <p className="text-lg leading-6 font-bold text-white"> {t("vector.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> {t("vector.description")} </p> </div> <div className="w-full justify-end flex"> {hasChanges && ( <CTAButton onClick={() => handleSubmit()} className="mt-3 mr-0 -mb-14 z-10" > {saving ? t("common.saving") : t("common.save")} </CTAButton> )} </div> <div className="text-base font-bold text-white mt-6 mb-4"> {t("vector.provider.title")} </div> <div className="relative"> {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="vdb-search" autoComplete="off" placeholder="Search all vector database 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-white 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]"> {filteredVDBs.map((vdb) => ( <VectorDBItem key={vdb.name} name={vdb.name} value={vdb.value} image={vdb.logo} description={vdb.description} checked={selectedVDB === vdb.value} onClick={() => updateVectorChoice(vdb.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={selectedVDBObject.logo} alt={`${selectedVDBObject.name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col text-left"> <div className="text-sm font-semibold text-white"> {selectedVDBObject.name} </div> <div className="mt-1 text-xs text-description"> {selectedVDBObject.description} </div> </div> </div> <CaretUpDown size={24} weight="bold" className="text-white" /> </button> )} </div> <div onChange={() => setHasChanges(true)} className="mt-4 flex flex-col gap-y-1" > {selectedVDB && VECTOR_DBS.find((vdb) => vdb.value === selectedVDB)?.options( settings )} </div> </div> </form> </div> )} <ModalWrapper isOpen={isOpen}> <ChangeWarningModal warningText="Switching the vector database will reset all previously embedded documents in all workspaces.\n\nConfirming will clear all embeddings from your vector database and remove all documents from your workspaces. Your uploaded documents will not be deleted, they will be available for re-embedding." onClose={closeModal} onConfirm={handleSaveSettings} /> </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/GeneralSettings/MobileConnections/index.jsx
frontend/src/pages/GeneralSettings/MobileConnections/index.jsx
import { useEffect, useState } from "react"; import Sidebar from "@/components/SettingsSidebar"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; import { QrCode } from "@phosphor-icons/react"; import { useModal } from "@/hooks/useModal"; import CTAButton from "@/components/lib/CTAButton"; import MobileConnection from "@/models/mobile"; import ConnectionModal from "./ConnectionModal"; import DeviceRow from "./DeviceRow"; import { isMobile } from "react-device-detect"; export default function MobileDevices() { const { isOpen, openModal, closeModal } = useModal(); const [loading, setLoading] = useState(true); const [devices, setDevices] = useState([]); const fetchDevices = async () => { const foundDevices = await MobileConnection.getDevices(); setDevices(foundDevices); if (foundDevices.length !== 0 && !isOpen) closeModal(); return foundDevices; }; useEffect(() => { fetchDevices() .then((devices) => { if (devices.length === 0) openModal(); return devices; }) .finally(() => { setLoading(false); }); const interval = setInterval(fetchDevices, 5_000); return () => clearInterval(interval); }, []); const removeDevice = (id) => { setDevices((prevDevices) => prevDevices.filter((device) => device.id !== id) ); }; return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex md:mt-0 mt-6"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2"> <div className="items-center flex gap-x-4"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> Connected Mobile Devices </p> </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary mt-2"> These are the devices that are connected to your desktop application to sync chats, workspaces, and more. </p> </div> <div className="w-full justify-end flex"> <CTAButton onClick={openModal} className="mt-3 mr-0 mb-4 md:-mb-14 z-10" > <QrCode className="h-4 w-4" weight="bold" /> Register New Device </CTAButton> </div> <div className="overflow-x-auto mt-6"> {loading ? ( <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" containerClassName="flex w-full" /> ) : ( <table className="w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0"> <thead className="text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b"> <tr> <th scope="col" className="px-6 py-3"> Device Name </th> <th scope="col" className="px-6 py-3"> Registered </th> <th scope="col" className="px-6 py-3"> {" "} </th> </tr> </thead> <tbody> {devices.length === 0 ? ( <tr className="bg-transparent text-theme-text-secondary text-sm font-medium"> <td colSpan="4" className="px-6 py-4 text-center"> No devices found </td> </tr> ) : ( devices.map((device) => ( <DeviceRow key={device.id} device={device} removeDevice={removeDevice} /> )) )} </tbody> </table> )} </div> </div> </div> <ConnectionModal isOpen={isOpen} onClose={closeModal} /> </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/GeneralSettings/MobileConnections/DeviceRow/index.jsx
frontend/src/pages/GeneralSettings/MobileConnections/DeviceRow/index.jsx
import showToast from "@/utils/toast"; import MobileConnection from "@/models/mobile"; import { useState } from "react"; import moment from "moment"; import { BugDroid, AppleLogo } from "@phosphor-icons/react"; import { Link } from "react-router-dom"; import paths from "@/utils/paths"; export default function DeviceRow({ device, removeDevice }) { const [status, setStatus] = useState(device.approved); const handleApprove = async () => { await MobileConnection.updateDevice(device.id, { approved: true }); showToast("Device access granted", "info"); setStatus(true); }; const handleDeny = async () => { await MobileConnection.deleteDevice(device.id); showToast("Device access denied", "info"); setStatus(false); removeDevice(device.id); }; return ( <> <tr className="bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10"> <td scope="row" className="px-6 whitespace-nowrap"> <div className="flex items-center gap-x-2"> {device.deviceOs === "ios" ? ( <AppleLogo weight="fill" size={16} className="fill-theme-text-primary" /> ) : ( <BugDroid weight="fill" size={16} className="fill-theme-text-primary" /> )} <span className="text-sm">{device.deviceName}</span> </div> </td> <td className="px-6"> <div className="flex items-center gap-x-2"> {moment(device.createdAt).format("lll")} {device.user && ( <div className="flex items-center gap-x-1"> <span className="text-xs text-theme-text-secondary">by</span> <Link to={paths.settings.users()} className="text-xs text-theme-text-secondary hover:underline hover:text-cta-button" > {device.user.username} </Link> </div> )} </div> </td> <td className="px-6 flex items-center gap-x-6 h-full mt-1"> {status ? ( <button onClick={handleDeny} className={`border-none flex items-center justify-center text-xs font-medium text-white/80 light:text-black/80 rounded-lg p-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10`} > Revoke </button> ) : ( <> <button onClick={handleApprove} className={`border-none flex items-center justify-center text-xs font-medium text-white/80 light:text-black/80 rounded-lg p-1 hover:bg-white hover:bg-opacity-10 hover:light:bg-green-50 hover:light:text-green-500 hover:text-green-300`} > Approve Access </button> <button onClick={handleDeny} className={`border-none flex items-center justify-center text-xs font-medium text-white/80 light:text-black/80 rounded-lg p-1 hover:bg-white hover:bg-opacity-10 hover:light:bg-red-50 hover:light:text-red-500 hover:text-red-300`} > Deny </button> </> )} </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/GeneralSettings/MobileConnections/ConnectionModal/index.jsx
frontend/src/pages/GeneralSettings/MobileConnections/ConnectionModal/index.jsx
import { X } from "@phosphor-icons/react"; import ModalWrapper from "@/components/ModalWrapper"; import BG from "./bg.png"; import { QRCodeSVG } from "qrcode.react"; import { Link } from "react-router-dom"; import { useEffect, useState } from "react"; import MobileConnection from "@/models/mobile"; import PreLoader from "@/components/Preloader"; import Logo from "@/media/logo/anything-llm-infinity.png"; import paths from "@/utils/paths"; export default function MobileConnectModal({ isOpen, onClose }) { return ( <ModalWrapper isOpen={isOpen}> <div className="relative w-full rounded-lg shadow" style={{ minHeight: "60vh", maxWidth: "70vw", backgroundImage: `url(${BG})`, backgroundSize: "cover", backgroundPosition: "center", }} > <button onClick={onClose} 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-[#FFF]" /> </button> <div className="flex w-full h-full justify-between p-[35px]"> {/* left column */} <div className="flex flex-col w-1/2 gap-y-[16px]"> <p className="text-[#FFF] text-xl font-bold"> Go mobile. Stay local. AnythingLLM Mobile. </p> <p className="text-[#FFF] text-lg"> AnythingLLM for mobile allows you to connect or clone your workspace's chats, threads and documents for you to use on the go. <br /> <br /> Run with local models on your phone privately or relay chats directly to this instance seamlessly. </p> </div> {/* right column */} <div className="flex flex-col items-center justify-center shrink-0 w-1/2 gap-y-[16px]"> <div className="bg-white/10 rounded-lg p-[40px] w-[300px] h-[300px] flex flex-col gap-y-[16px] items-center justify-center"> <ConnectionQrCode isOpen={isOpen} /> </div> <p className="text-[#FFF] text-sm w-[300px] text-center"> Scan the QR code with the AnythingLLM Mobile app to enable live sync of your workspaces, chats, threads and documents. <br /> <Link to={paths.documentation.mobileIntroduction()} className="text-cta-button font-semibold" > Learn more </Link> </p> </div> </div> </div> </ModalWrapper> ); } /** * Process the connection url to make it absolute if it is a relative path * @param {string} url * @returns {string} */ function processConnectionUrl(url) { /* * In dev mode, the connectionURL() method uses the `ip` module * see server/models/mobileDevice.js `connectionURL()` method. * * In prod mode, this method returns the absolute path since we will always want to use * the real instance hostname. If the domain changes, we should be able to inherit it from the client side * since the backend has no knowledge of the domain since typically it is run behind a reverse proxy or in a container - or both. * So `ip` is useless in prod mode since it would only resolve to the internal IP address of the container or if non-containerized, * the local IP address may not be the preferred instance access point (eg: using custom domain) * * If the url does not start with http, we assume it is a relative path and add the origin to it. * Then we check if the hostname is localhost, 127.0.0.1, or 0.0.0.0. If it is, we throw an error since that is not * a LAN resolvable address that other devices can use to connect to the instance. */ if (url.startsWith("http")) return new URL(url); const connectionUrl = new URL(`${window.location.origin}${url}`); if (["localhost", "127.0.0.1", "0.0.0.0"].includes(connectionUrl.hostname)) throw new Error( "Please open this page via your machines private IP address or custom domain. Localhost URLs will not work with the mobile app." ); return connectionUrl.toString(); } const ConnectionQrCode = ({ isOpen }) => { const [connectionInfo, setConnectionInfo] = useState(null); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); useEffect(() => { if (!isOpen) return; setIsLoading(true); MobileConnection.getConnectionInfo() .then((res) => { if (res.error) throw new Error(res.error); const url = processConnectionUrl(res.connectionUrl); setConnectionInfo(url); }) .catch((err) => { setError(err.message); }) .finally(() => { setIsLoading(false); }); }, [isOpen]); if (isLoading) return <PreLoader size="[100px]" />; if (error) return ( <p className="text-red-500 text-sm w-[300px] p-4 text-center">{error}</p> ); const size = { width: 35 * 1.5, height: 22 * 1.5, }; return ( <QRCodeSVG value={connectionInfo} size={300} bgColor="transparent" fgColor="white" level="L" imageSettings={{ src: Logo, x: 300 / 2 - size.width / 2, y: 300 / 2 - size.height / 2, height: size.height, width: size.width, excavate: 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/pages/GeneralSettings/CommunityHub/utils.js
frontend/src/pages/GeneralSettings/CommunityHub/utils.js
/** * Convert a type to a readable string for the community hub. * @param {("agentSkills" | "agentSkill" | "systemPrompts" | "systemPrompt" | "slashCommands" | "slashCommand" | "agentFlows" | "agentFlow")} type * @returns {string} */ export function readableType(type) { switch (type) { case "agentSkills": case "agentSkill": return "Agent Skills"; case "systemPrompt": case "systemPrompts": return "System Prompts"; case "slashCommand": case "slashCommands": return "Slash Commands"; case "agentFlows": case "agentFlow": return "Agent Flows"; } } /** * Convert a type to a path for the community hub. * @param {("agentSkill" | "agentSkills" | "systemPrompt" | "systemPrompts" | "slashCommand" | "slashCommands" | "agentFlow" | "agentFlows")} type * @returns {string} */ export function typeToPath(type) { switch (type) { case "agentSkill": case "agentSkills": return "agent-skills"; case "systemPrompt": case "systemPrompts": return "system-prompts"; case "slashCommand": case "slashCommands": return "slash-commands"; case "agentFlow": case "agentFlows": return "agent-flows"; } }
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/GeneralSettings/CommunityHub/ImportItem/index.jsx
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/index.jsx
import React, { useState } from "react"; import { isMobile } from "react-device-detect"; import CommunityHubImportItemSteps, { CommunityHubImportItemLayout, } from "./Steps"; function SideBarSelection({ setStep, currentStep }) { const currentIndex = Object.keys(CommunityHubImportItemSteps).indexOf( currentStep ); return ( <div className={`bg-white/5 light:bg-white text-theme-text-primary rounded-xl py-1 px-4 shadow-lg ${ isMobile ? "w-full" : "min-w-[360px] w-fit" }`} > {Object.entries(CommunityHubImportItemSteps).map( ([stepKey, props], index) => { const isSelected = currentStep === stepKey; const isLast = index === Object.keys(CommunityHubImportItemSteps).length - 1; const isDone = currentIndex === Object.keys(CommunityHubImportItemSteps).length - 1 || index < currentIndex; return ( <div key={stepKey} className={[ "py-3 flex items-center justify-between transition-all duration-300", isSelected ? "rounded-t-xl" : "", isLast ? "" : "border-b border-white/10 light:border-[#026AA2]/10", ].join(" ")} > {isDone || isSelected ? ( <button onClick={() => setStep(stepKey)} className="border-none hover:underline text-sm font-medium text-theme-text-primary" > {props.name} </button> ) : ( <div className="text-sm text-theme-text-secondary font-medium"> {props.name} </div> )} <div className="flex items-center gap-x-2"> {isDone ? ( <div className="w-[14px] h-[14px] rounded-full border border-[#32D583] flex items-center justify-center"> <div className="w-[5.6px] h-[5.6px] rounded-full bg-[#6CE9A6]"></div> </div> ) : ( <div className={`w-[14px] h-[14px] rounded-full border border-theme-text-primary ${ isSelected ? "animate-pulse" : "opacity-50" }`} /> )} </div> </div> ); } )} </div> ); } export default function CommunityHubImportItemFlow() { const [step, setStep] = useState("itemId"); const StepPage = CommunityHubImportItemSteps.hasOwnProperty(step) ? CommunityHubImportItemSteps[step] : CommunityHubImportItemSteps.itemId; return ( <CommunityHubImportItemLayout setStep={setStep}> {(settings, setSettings, setStep) => ( <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="items-center"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> Import a Community Item </p> </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary"> Import items from the AnythingLLM Community Hub to enhance your instance with community-created prompts, skills, and commands. </p> </div> <div className="flex-1 flex h-full"> <div className="flex flex-col gap-y-[18px] mt-10 w-[360px] flex-shrink-0"> <SideBarSelection setStep={setStep} currentStep={step} /> </div> <div className="overflow-y-auto pb-[200px] h-screen no-scroll"> <div className="ml-8"> {StepPage.component({ settings, setSettings, setStep })} </div> </div> </div> </div> )} </CommunityHubImportItemLayout> ); }
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/GeneralSettings/CommunityHub/ImportItem/Steps/index.jsx
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/index.jsx
import { isMobile } from "react-device-detect"; import { useEffect, useState } from "react"; import Sidebar from "@/components/SettingsSidebar"; import Introduction from "./Introduction"; import PullAndReview from "./PullAndReview"; import Completed from "./Completed"; import useQuery from "@/hooks/useQuery"; const CommunityHubImportItemSteps = { itemId: { key: "itemId", name: "1. Paste in Item ID", next: () => "validation", component: ({ settings, setSettings, setStep }) => ( <Introduction settings={settings} setSettings={setSettings} setStep={setStep} /> ), }, validation: { key: "validation", name: "2. Review item", next: () => "completed", component: ({ settings, setSettings, setStep }) => ( <PullAndReview settings={settings} setSettings={setSettings} setStep={setStep} /> ), }, completed: { key: "completed", name: "3. Completed", component: ({ settings, setSettings, setStep }) => ( <Completed settings={settings} setSettings={setSettings} setStep={setStep} /> ), }, }; export function CommunityHubImportItemLayout({ setStep, children }) { const query = useQuery(); const [settings, setSettings] = useState({ itemId: null, item: null, }); useEffect(() => { function autoForward() { if (query.get("id")) { setSettings({ itemId: query.get("id") }); setStep(CommunityHubImportItemSteps.itemId.next()); } } autoForward(); }, []); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex md:mt-0 mt-6"> <Sidebar /> <div style={{ height: isMobile ? "100%" : "calc(100% - 32px)" }} className="relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] w-full h-full flex" > {children(settings, setSettings, setStep)} </div> </div> ); } export default CommunityHubImportItemSteps;
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/GeneralSettings/CommunityHub/ImportItem/Steps/Introduction/index.jsx
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/Introduction/index.jsx
import CommunityHubImportItemSteps from ".."; import CTAButton from "@/components/lib/CTAButton"; import paths from "@/utils/paths"; import showToast from "@/utils/toast"; import { useState } from "react"; export default function Introduction({ settings, setSettings, setStep }) { const [itemId, setItemId] = useState(settings.itemId); const handleContinue = () => { if (!itemId) return showToast("Please enter an item ID", "error"); setSettings((prev) => ({ ...prev, itemId })); setStep(CommunityHubImportItemSteps.itemId.next()); }; return ( <div className="flex-[2] flex flex-col gap-y-[18px] mt-10"> <div className="bg-theme-bg-secondary rounded-xl flex-1 p-6"> <div className="w-full flex flex-col gap-y-2 max-w-[700px]"> <h2 className="text-base text-theme-text-primary font-semibold"> Import an item from the community hub </h2> <div className="flex flex-col gap-y-[25px] text-theme-text-secondary text-sm"> <p> The community hub is a place where you can find, share, and import agent-skills, system prompts, slash commands, and more! </p> <p> These items are created by the AnythingLLM team and community, and are a great way to get started with AnythingLLM as well as extend AnythingLLM in a way that is customized to your needs. </p> <p> There are both <b>private</b> and <b>public</b> items in the community hub. Private items are only visible to you, while public items are visible to everyone. </p> <p className="p-4 bg-yellow-800/30 light:bg-orange-100 light:text-orange-500 light:border-orange-500 rounded-lg border border-yellow-500 text-yellow-500"> If you are pulling in a private item, make sure it is{" "} <b>shared with a team</b> you belong to, and you have added a{" "} <a href={paths.communityHub.authentication()} className="underline text-yellow-100 light:text-orange-500 font-semibold" > Connection Key. </a> </p> </div> <div className="flex flex-col gap-y-2 mt-4"> <div className="w-full flex flex-col gap-y-4"> <div className="flex flex-col w-full"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Community Hub Item Import ID </label> <input type="text" value={itemId} onChange={(e) => setItemId(e.target.value)} placeholder="allm-community-id:agent-skill:1234567890" 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" /> </div> </div> </div> <CTAButton className="text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent" onClick={handleContinue} > Continue with import &rarr; </CTAButton> </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/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/index.jsx
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/index.jsx
import CommunityHub from "@/models/communityHub"; import CommunityHubImportItemSteps from ".."; import CTAButton from "@/components/lib/CTAButton"; import { useEffect, useState } from "react"; import HubItemComponent from "./HubItem"; function useGetCommunityHubItem({ importId, updateSettings }) { const [item, setItem] = useState(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); useEffect(() => { async function fetchItem() { if (!importId) return; setLoading(true); await new Promise((resolve) => setTimeout(resolve, 2000)); const { error, item } = await CommunityHub.getItemFromImportId(importId); if (error) setError(error); setItem(item); updateSettings((prev) => ({ ...prev, item })); setLoading(false); } fetchItem(); }, [importId]); return { item, loading, error }; } export default function PullAndReview({ settings, setSettings, setStep }) { const { item, loading, error } = useGetCommunityHubItem({ importId: settings.itemId, updateSettings: setSettings, }); const ItemComponent = HubItemComponent[item?.itemType] || HubItemComponent["unknown"]; return ( <div className="flex-[2] flex flex-col gap-y-[18px] mt-10"> <div className="bg-theme-bg-secondary rounded-xl flex-1 p-6"> <div className="w-full flex flex-col gap-y-2 max-w-[700px]"> <h2 className="text-base text-theme-text-primary font-semibold"> Review item </h2> {loading && ( <div className="flex h-[200px] min-w-[746px] rounded-lg animate-pulse"> <div className="w-full h-full flex items-center justify-center"> <p className="text-sm text-theme-text-secondary"> Pulling item details from community hub... </p> </div> </div> )} {!loading && error && ( <> <div className="flex flex-col gap-y-2 mt-8"> <p className="text-red-500"> An error occurred while fetching the item. Please try again later. </p> <p className="text-red-500/80 text-sm font-mono">{error}</p> </div> <CTAButton className="text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent" onClick={() => { setSettings({ itemId: null, item: null }); setStep(CommunityHubImportItemSteps.itemId.key); }} > Try another item </CTAButton> </> )} {!loading && !error && item && ( <ItemComponent item={item} settings={settings} setSettings={setSettings} setStep={setStep} /> )} </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/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/Unknown.jsx
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/Unknown.jsx
import CTAButton from "@/components/lib/CTAButton"; import CommunityHubImportItemSteps from "../.."; import { Warning } from "@phosphor-icons/react"; export default function UnknownItem({ item, setSettings, setStep }) { return ( <div className="flex flex-col mt-4 gap-y-4"> <div className="w-full flex items-center gap-x-2"> <Warning size={24} className="text-red-500" /> <h2 className="text-base text-red-500 font-semibold"> Unsupported item </h2> </div> <div className="flex flex-col gap-y-[25px] text-white/80 text-sm"> <p> We found an item in the community hub, but we don't know what it is or it is not yet supported for import into AnythingLLM. </p> <p> The item ID is: <b>{item.id}</b> <br /> The item type is: <b>{item.itemType}</b> </p> <p> Please contact support via email if you need help importing this item. </p> </div> <CTAButton className="text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent" onClick={() => { setSettings({ itemId: null, item: null }); setStep(CommunityHubImportItemSteps.itemId.key); }} > Try another item </CTAButton> </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/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/index.js
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/index.js
import SystemPrompt from "./SystemPrompt"; import SlashCommand from "./SlashCommand"; import UnknownItem from "./Unknown"; import AgentSkill from "./AgentSkill"; import AgentFlow from "./AgentFlow"; const HubItemComponent = { "agent-skill": AgentSkill, "system-prompt": SystemPrompt, "slash-command": SlashCommand, "agent-flow": AgentFlow, unknown: UnknownItem, }; export default HubItemComponent;
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/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/AgentFlow.jsx
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/AgentFlow.jsx
import CTAButton from "@/components/lib/CTAButton"; import CommunityHubImportItemSteps from "../.."; import showToast from "@/utils/toast"; import paths from "@/utils/paths"; import { CircleNotch } from "@phosphor-icons/react"; import { useState } from "react"; import AgentFlows from "@/models/agentFlows"; import { safeJsonParse } from "@/utils/request"; export default function AgentFlow({ item, setStep }) { const flowInfo = safeJsonParse(item.flow, { steps: [] }); const [loading, setLoading] = useState(false); async function importAgentFlow() { try { setLoading(true); const { success, error, flow } = await AgentFlows.saveFlow( item.name, flowInfo ); if (!success) throw new Error(error); if (!!flow?.uuid) await AgentFlows.toggleFlow(flow.uuid, true); // Enable the flow automatically after import showToast(`Agent flow imported successfully!`, "success"); setStep(CommunityHubImportItemSteps.completed.key); } catch (e) { console.error(e); showToast(`Failed to import agent flow. ${e.message}`, "error"); } finally { setLoading(false); } } return ( <div className="flex flex-col mt-4 gap-y-4"> <div className="flex flex-col gap-y-1"> <h2 className="text-base text-theme-text-primary font-semibold"> Import Agent Flow &quot;{item.name}&quot; </h2> {item.creatorUsername && ( <p className="text-white/60 light:text-theme-text-secondary text-xs font-mono"> Created by{" "} <a href={paths.communityHub.profile(item.creatorUsername)} target="_blank" className="hover:text-blue-500 hover:underline" rel="noreferrer" > @{item.creatorUsername} </a> </p> )} </div> <div className="flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm"> <p> Agent flows allow you to create reusable sequences of actions that can be triggered by your agent. </p> <div className="flex flex-col gap-y-2"> <p className="font-semibold">Flow Details:</p> <p>Description: {item.description}</p> <p className="font-semibold">Steps ({flowInfo.steps.length}):</p> <ul className="list-disc pl-6"> {flowInfo.steps.map((step, index) => ( <li key={index}>{step.type}</li> ))} </ul> </div> </div> <CTAButton disabled={loading} className="text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent" onClick={importAgentFlow} > {loading ? <CircleNotch size={16} className="animate-spin" /> : null} {loading ? "Importing..." : "Import agent flow"} </CTAButton> </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/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/SlashCommand.jsx
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/SlashCommand.jsx
import CTAButton from "@/components/lib/CTAButton"; import CommunityHubImportItemSteps from "../.."; import showToast from "@/utils/toast"; import paths from "@/utils/paths"; import CommunityHub from "@/models/communityHub"; export default function SlashCommand({ item, setStep }) { async function handleSubmit() { try { const { error } = await CommunityHub.applyItem(item.importId); if (error) throw new Error(error); showToast( `Slash command ${item.command} imported successfully!`, "success" ); setStep(CommunityHubImportItemSteps.completed.key); } catch (e) { console.error(e); showToast(`Failed to import slash command. ${e.message}`, "error"); } finally { setLoading(false); } } return ( <div className="flex flex-col mt-4 gap-y-4"> <div className="flex flex-col gap-y-1"> <h2 className="text-base text-theme-text-primary font-semibold"> Review Slash Command "{item.name}" </h2> {item.creatorUsername && ( <p className="text-white/60 text-xs font-mono"> Created by{" "} <a href={paths.communityHub.profile(item.creatorUsername)} target="_blank" className="hover:text-blue-500 hover:underline" rel="noreferrer" > @{item.creatorUsername} </a> </p> )} </div> <div className="flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm"> <p> Slash commands are used to prefill information into a prompt while chatting with a AnythingLLM workspace. <br /> <br /> The slash command will be available during chatting by simply invoking it with{" "} <code className="font-mono bg-zinc-900 light:bg-slate-200 px-1 py-0.5 rounded-md text-sm"> {item.command} </code>{" "} like you would any other command. </p> <div className="flex flex-col gap-y-2 mt-2"> <div className="w-full text-theme-text-primary text-md gap-x-2 flex items-center"> <p className="text-white/60 light:text-theme-text-secondary w-fit font-mono bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md text-sm whitespace-pre-line"> {item.command} </p> </div> <div className="w-full text-theme-text-primary text-md flex flex-col gap-y-2"> <p className="text-white/60 light:text-theme-text-secondary font-mono bg-zinc-900 light:bg-slate-200 p-4 rounded-md text-sm whitespace-pre-line max-h-[calc(200px)] overflow-y-auto"> {item.prompt} </p> </div> </div> </div> <CTAButton className="text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent" onClick={handleSubmit} > Import slash command </CTAButton> </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/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/AgentSkill.jsx
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/AgentSkill.jsx
import CTAButton from "@/components/lib/CTAButton"; import CommunityHubImportItemSteps from "../.."; import showToast from "@/utils/toast"; import paths from "@/utils/paths"; import { CaretLeft, CaretRight, CircleNotch, Warning, } from "@phosphor-icons/react"; import { useEffect, useState } from "react"; import renderMarkdown from "@/utils/chat/markdown"; import DOMPurify from "dompurify"; import CommunityHub from "@/models/communityHub"; import { setEventDelegatorForCodeSnippets } from "@/components/WorkspaceChat"; export default function AgentSkill({ item, settings, setStep }) { const [loading, setLoading] = useState(false); async function importAgentSkill() { try { setLoading(true); const { error } = await CommunityHub.importBundleItem(settings.itemId); if (error) throw new Error(error); showToast(`Agent skill imported successfully!`, "success"); setStep(CommunityHubImportItemSteps.completed.key); } catch (e) { console.error(e); showToast(`Failed to import agent skill. ${e.message}`, "error"); } finally { setLoading(false); } } useEffect(() => { setEventDelegatorForCodeSnippets(); }, []); return ( <div className="flex flex-col mt-4 gap-y-4"> <div className="border border-white/10 light:border-orange-500/20 my-2 flex flex-col md:flex-row md:items-center gap-x-2 text-theme-text-primary light:text-orange-600 mb-4 bg-orange-800/30 light:bg-orange-500/10 rounded-lg px-4 py-2"> <div className="flex flex-col gap-y-2"> <div className="gap-x-2 flex items-center"> <Warning size={25} /> <h1 className="text-lg font-semibold"> {" "} Only import agent skills you trust{" "} </h1> </div> <p className="text-sm"> Agent skills can execute code on your AnythingLLM instance, so only import agent skills from sources you trust. You should also review the code before importing. If you are unsure about what a skill does - don't import it! </p> </div> </div> <div className="flex flex-col gap-y-1"> <h2 className="text-base text-theme-text-primary font-semibold"> Review Agent Skill "{item.name}" </h2> {item.creatorUsername && ( <p className="text-white/60 light:text-theme-text-secondary text-xs font-mono"> Created by{" "} <a href={paths.communityHub.profile(item.creatorUsername)} target="_blank" className="hover:text-blue-500 hover:underline" rel="noreferrer" > @{item.creatorUsername} </a> </p> )} <div className="flex gap-x-1"> {item.verified ? ( <p className="text-green-500 text-xs font-mono">Verified code</p> ) : ( <p className="text-red-500 text-xs font-mono"> This skill is not verified. </p> )} <a href="https://docs.anythingllm.com/community-hub/faq#verification" target="_blank" className="text-xs font-mono text-blue-500 hover:underline" rel="noreferrer" > Learn more &rarr; </a> </div> </div> <div className="flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm"> <p> Agent skills unlock new capabilities for your AnythingLLM workspace via{" "} <code className="font-mono bg-zinc-900 light:bg-slate-200 px-1 py-0.5 rounded-md text-sm"> @agent </code>{" "} skills that can do specific tasks when invoked. </p> </div> <FileReview item={item} /> <CTAButton disabled={loading} className="text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent" onClick={importAgentSkill} > {loading ? <CircleNotch size={16} className="animate-spin" /> : null} {loading ? "Importing..." : "Import agent skill"} </CTAButton> </div> ); } function FileReview({ item }) { const files = item.manifest.files || []; const [index, setIndex] = useState(0); const [file, setFile] = useState(files[index]); function handlePrevious() { if (index > 0) setIndex(index - 1); } function handleNext() { if (index < files.length - 1) setIndex(index + 1); } function fileMarkup(file) { const extension = file.name.split(".").pop(); switch (extension) { case "js": return "javascript"; case "json": return "json"; case "md": return "markdown"; default: return "text"; } } useEffect(() => { if (files.length > 0) setFile(files?.[index] || files[0]); }, [index]); if (!file) return null; return ( <div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2"> <div className="flex justify-between items-center"> <button type="button" className={`border-none bg-black/70 light:bg-slate-200 rounded-md p-1 text-white/60 light:text-theme-text-secondary text-xs font-mono ${ index === 0 ? "opacity-50 cursor-not-allowed" : "" }`} onClick={handlePrevious} > <CaretLeft size={16} /> </button> <p className="text-white/60 light:text-theme-text-secondary text-xs font-mono"> {file.name} ({index + 1} of {files.length} files) </p> <button type="button" className={`border-none bg-black/70 light:bg-slate-200 rounded-md p-1 text-white/60 light:text-theme-text-secondary text-xs font-mono ${ index === files.length - 1 ? "opacity-50 cursor-not-allowed" : "" }`} onClick={handleNext} > <CaretRight size={16} /> </button> </div> <span className="whitespace-pre-line flex flex-col gap-y-1 text-sm leading-[20px] max-h-[500px] overflow-y-auto hljs text-theme-text-primary" dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize( renderMarkdown( `\`\`\`${fileMarkup(file)}\n${ fileMarkup(file) === "markdown" ? file.content.replace(/```/g, "~~~") // Escape triple backticks in markdown : file.content }\n\`\`\`` ) ), }} /> </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/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/SystemPrompt.jsx
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/SystemPrompt.jsx
import CTAButton from "@/components/lib/CTAButton"; import CommunityHubImportItemSteps from "../.."; import { useEffect, useState } from "react"; import Workspace from "@/models/workspace"; import showToast from "@/utils/toast"; import paths from "@/utils/paths"; import CommunityHub from "@/models/communityHub"; export default function SystemPrompt({ item, setStep }) { const [destinationWorkspaceSlug, setDestinationWorkspaceSlug] = useState(null); const [workspaces, setWorkspaces] = useState([]); useEffect(() => { async function getWorkspaces() { const workspaces = await Workspace.all(); setWorkspaces(workspaces); setDestinationWorkspaceSlug(workspaces[0].slug); } getWorkspaces(); }, []); async function handleSubmit() { showToast("Applying system prompt to workspace...", "info"); const { error } = await CommunityHub.applyItem(item.importId, { workspaceSlug: destinationWorkspaceSlug, }); if (error) { return showToast(`Failed to apply system prompt. ${error}`, "error", { clear: true, }); } showToast("System prompt applied to workspace.", "success", { clear: true, }); setStep(CommunityHubImportItemSteps.completed.key); } return ( <div className="flex flex-col mt-4 gap-y-4"> <div className="flex flex-col gap-y-1"> <h2 className="text-base text-theme-text-primary font-semibold"> Review System Prompt "{item.name}" </h2> {item.creatorUsername && ( <p className="text-white/60 light:text-theme-text-secondary text-xs font-mono"> Created by{" "} <a href={paths.communityHub.profile(item.creatorUsername)} target="_blank" className="hover:text-blue-500 hover:underline" rel="noreferrer" > @{item.creatorUsername} </a> </p> )} </div> <div className="flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm"> <p> System prompts are used to guide the behavior of the AI agents and can be applied to any existing workspace. </p> <div className="flex flex-col gap-y-2"> <p className="text-white/60 light:text-theme-text-secondary font-semibold"> Provided system prompt: </p> <div className="w-full text-theme-text-primary text-md flex flex-col max-h-[calc(300px)] overflow-y-auto"> <p className="text-white/60 light:text-theme-text-secondary font-mono bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md text-sm whitespace-pre-line"> {item.prompt} </p> </div> </div> <div className="flex flex-col w-60"> <label className="text-theme-text-primary text-sm font-semibold block mb-3"> Apply to Workspace </label> <select name="destinationWorkspaceSlug" required={true} onChange={(e) => setDestinationWorkspaceSlug(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" > <optgroup label="Available workspaces"> {workspaces.map((workspace) => ( <option key={workspace.id} value={workspace.slug}> {workspace.name} </option> ))} </optgroup> </select> </div> </div> {destinationWorkspaceSlug && ( <CTAButton className="text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent" onClick={handleSubmit} > Apply system prompt to workspace </CTAButton> )} </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/GeneralSettings/CommunityHub/ImportItem/Steps/Completed/index.jsx
frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/Completed/index.jsx
import CommunityHubImportItemSteps from ".."; import CTAButton from "@/components/lib/CTAButton"; import { Link } from "react-router-dom"; import paths from "@/utils/paths"; export default function Completed({ settings, setSettings, setStep }) { return ( <div className="flex-[2] flex flex-col gap-y-[18px] mt-10"> <div className="bg-theme-bg-secondary rounded-xl flex-1 p-6"> <div className="w-full flex flex-col gap-y-2 max-w-[700px]"> <h2 className="text-base text-theme-text-primary font-semibold"> Community Hub Item Imported </h2> <div className="flex flex-col gap-y-[25px] text-theme-text-secondary text-sm"> <p> The "{settings.item.name}" {settings.item.itemType} has been imported successfully! It is now available in your AnythingLLM instance. </p> {settings.item.itemType === "agent-flow" && ( <Link to={paths.settings.agentSkills()} className="text-theme-text-primary hover:text-blue-500 hover:underline" > View "{settings.item.name}" in Agent Skills </Link> )} <p> Any changes you make to this {settings.item.itemType} will not be reflected in the community hub. You can now modify as needed. </p> </div> <CTAButton className="text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent" onClick={() => { setSettings({ item: null, itemId: null }); setStep(CommunityHubImportItemSteps.itemId.key); }} > Import another item </CTAButton> </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/GeneralSettings/CommunityHub/Authentication/index.jsx
frontend/src/pages/GeneralSettings/CommunityHub/Authentication/index.jsx
import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import { useEffect, useState } from "react"; import CommunityHub from "@/models/communityHub"; import ContextualSaveBar from "@/components/ContextualSaveBar"; import showToast from "@/utils/toast"; import { FullScreenLoader } from "@/components/Preloader"; import paths from "@/utils/paths"; import { Info } from "@phosphor-icons/react"; import UserItems from "./UserItems"; function useCommunityHubAuthentication() { const [originalConnectionKey, setOriginalConnectionKey] = useState(""); const [hasChanges, setHasChanges] = useState(false); const [connectionKey, setConnectionKey] = useState(""); const [loading, setLoading] = useState(true); async function resetChanges() { setConnectionKey(originalConnectionKey); setHasChanges(false); } async function onConnectionKeyChange(e) { const newConnectionKey = e.target.value; setConnectionKey(newConnectionKey); setHasChanges(true); } async function updateConnectionKey() { if (connectionKey === originalConnectionKey) return; setLoading(true); try { const response = await CommunityHub.updateSettings({ hub_api_key: connectionKey, }); if (!response.success) return showToast("Failed to save API key", "error"); setHasChanges(false); showToast("API key saved successfully", "success"); setOriginalConnectionKey(connectionKey); } catch (error) { console.error(error); showToast("Failed to save API key", "error"); } finally { setLoading(false); } } async function disconnectHub() { setLoading(true); try { const response = await CommunityHub.updateSettings({ hub_api_key: "", }); if (!response.success) return showToast("Failed to disconnect from hub", "error"); setHasChanges(false); showToast("Disconnected from AnythingLLM Community Hub", "success"); setOriginalConnectionKey(""); setConnectionKey(""); } catch (error) { console.error(error); showToast("Failed to disconnect from hub", "error"); } finally { setLoading(false); } } useEffect(() => { const fetchData = async () => { setLoading(true); try { const { connectionKey } = await CommunityHub.getSettings(); setOriginalConnectionKey(connectionKey || ""); setConnectionKey(connectionKey || ""); } catch (error) { console.error("Error fetching data:", error); } finally { setLoading(false); } }; fetchData(); }, []); return { connectionKey, originalConnectionKey, loading, onConnectionKeyChange, updateConnectionKey, hasChanges, resetChanges, disconnectHub, }; } export default function CommunityHubAuthentication() { const { connectionKey, originalConnectionKey, loading, onConnectionKeyChange, updateConnectionKey, hasChanges, resetChanges, disconnectHub, } = useCommunityHubAuthentication(); if (loading) return <FullScreenLoader />; return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <ContextualSaveBar showing={hasChanges} onSave={updateConnectionKey} onCancel={resetChanges} /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="items-center"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> Your AnythingLLM Community Hub Account </p> </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary"> Connecting your AnythingLLM Community Hub account allows you to access your <b>private</b> AnythingLLM Community Hub items as well as upload your own items to the AnythingLLM Community Hub. </p> </div> {!connectionKey && ( <div className="border border-theme-border my-2 flex flex-col md:flex-row md:items-center gap-x-2 text-theme-text-primary mb-4 bg-theme-settings-input-bg w-1/2 rounded-lg px-4 py-2"> <div className="flex flex-col gap-y-2"> <div className="gap-x-2 flex items-center"> <Info size={25} /> <h1 className="text-lg font-semibold"> Why connect my AnythingLLM Community Hub account? </h1> </div> <p className="text-sm text-theme-text-secondary"> Connecting your AnythingLLM Community Hub account allows you to pull in your <b>private</b> items from the AnythingLLM Community Hub as well as upload your own items to the AnythingLLM Community Hub. <br /> <br /> <i> You do not need to connect your AnythingLLM Community Hub account to pull in public items from the AnythingLLM Community Hub. </i> </p> </div> </div> )} {/* API Key Section */} <div className="mt-6 mb-12"> <div className="flex flex-col w-full max-w-[400px]"> <label className="text-theme-text-primary text-sm font-semibold block mb-2"> AnythingLLM Hub API Key </label> <input type="password" value={connectionKey || ""} onChange={onConnectionKeyChange} 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="Enter your AnythingLLM Hub API key" /> <div className="flex items-center justify-between mt-2"> <p className="text-theme-text-secondary text-xs"> You can get your API key from your{" "} <a href={paths.communityHub.profile()} className="underline text-primary-button" > AnythingLLM Community Hub profile page </a> . </p> {!!originalConnectionKey && ( <button onClick={disconnectHub} className="border-none text-red-500 hover:text-red-600 text-sm font-medium transition-colors duration-200" > Disconnect </button> )} </div> </div> </div> {!!originalConnectionKey && ( <div className="mt-6"> <UserItems connectionKey={originalConnectionKey} /> </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/pages/GeneralSettings/CommunityHub/Authentication/useUserItems.js
frontend/src/pages/GeneralSettings/CommunityHub/Authentication/useUserItems.js
import { useState, useEffect } from "react"; import CommunityHub from "@/models/communityHub"; const DEFAULT_USER_ITEMS = { createdByMe: { agentSkills: { items: [] }, systemPrompts: { items: [] }, slashCommands: { items: [] }, agentFlows: { items: [] }, }, teamItems: [], }; export function useUserItems({ connectionKey }) { const [loading, setLoading] = useState(true); const [userItems, setUserItems] = useState(DEFAULT_USER_ITEMS); useEffect(() => { const fetchData = async () => { console.log("fetching user items", connectionKey); if (!connectionKey) return; setLoading(true); try { const { success, createdByMe, teamItems } = await CommunityHub.fetchUserItems(); if (success) { setUserItems({ createdByMe, teamItems }); } } catch (error) { console.error("Error fetching user items:", error); } finally { setLoading(false); } }; fetchData(); }, [connectionKey]); return { loading, userItems }; }
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/GeneralSettings/CommunityHub/Authentication/UserItems/index.jsx
frontend/src/pages/GeneralSettings/CommunityHub/Authentication/UserItems/index.jsx
import paths from "@/utils/paths"; import HubItemCard from "../../Trending/HubItems/HubItemCard"; import { useUserItems } from "../useUserItems"; import { HubItemCardSkeleton } from "../../Trending/HubItems"; import { readableType } from "../../utils"; export default function UserItems({ connectionKey }) { const { loading, userItems } = useUserItems({ connectionKey }); const { createdByMe = {}, teamItems = [] } = userItems || {}; if (loading) return <HubItemCardSkeleton />; const hasItems = (items) => { return Object.values(items).some((category) => category?.items?.length > 0); }; return ( <div className="flex flex-col gap-y-8"> {/* Created By Me Section */} <div className="w-full flex flex-col gap-y-1 pb-6 border-white border-b-2 border-opacity-10"> <div className="flex items-center justify-between"> <p className="text-lg leading-6 font-bold text-white"> Created by me </p> <a href={paths.communityHub.noPrivateItems()} target="_blank" rel="noreferrer" className="text-primary-button hover:text-primary-button/80 text-sm" > Why can't I see my private items? </a> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> Items you have created and shared publicly on the AnythingLLM Community Hub. </p> <div className="flex flex-col gap-4 mt-4"> {Object.keys(createdByMe).map((type) => { if (!createdByMe[type]?.items?.length) return null; return ( <div key={type} className="rounded-lg w-full"> <h3 className="text-white capitalize font-medium mb-3"> {readableType(type)} </h3> <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2"> {createdByMe[type].items.map((item) => ( <HubItemCard key={item.id} type={type} item={item} /> ))} </div> </div> ); })} {!hasItems(createdByMe) && ( <p className="text-white/60 text-xs text-center mt-4"> You haven&apos;t created any items yet. </p> )} </div> </div> {/* Team Items Section */} <div className="w-full flex flex-col gap-y-1 pb-6 border-white border-b-2 border-opacity-10"> <div className="items-center"> <p className="text-lg leading-6 font-bold text-white"> Items by team </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> Public and private items shared with teams you belong to. </p> <div className="flex flex-col gap-4 mt-4"> {teamItems.map((team) => ( <div key={team.teamId} className="flex flex-col gap-y-4"> <h3 className="text-white text-sm font-medium"> {team.teamName} </h3> {Object.keys(team.items).map((type) => { if (!team.items[type]?.items?.length) return null; return ( <div key={type} className="rounded-lg w-full"> <h3 className="text-white capitalize font-medium mb-3"> {readableType(type)} </h3> <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2"> {team.items[type].items.map((item) => ( <HubItemCard key={item.id} type={type} item={item} /> ))} </div> </div> ); })} {!hasItems(team.items) && ( <p className="text-white/60 text-xs text-center mt-4"> No items shared with this team yet. </p> )} </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/pages/GeneralSettings/CommunityHub/Trending/index.jsx
frontend/src/pages/GeneralSettings/CommunityHub/Trending/index.jsx
import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import HubItems from "./HubItems"; export default function CommunityHub() { return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="items-center"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> Community Hub </p> </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary"> Share and collaborate with the AnythingLLM community. </p> </div> <HubItems /> </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/GeneralSettings/CommunityHub/Trending/HubItems/index.jsx
frontend/src/pages/GeneralSettings/CommunityHub/Trending/HubItems/index.jsx
import { useEffect, useState } from "react"; import CommunityHub from "@/models/communityHub"; import paths from "@/utils/paths"; import HubItemCard from "./HubItemCard"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; import { readableType, typeToPath } from "../../utils"; const DEFAULT_EXPLORE_ITEMS = { agentSkills: { items: [], hasMore: false, totalCount: 0 }, systemPrompts: { items: [], hasMore: false, totalCount: 0 }, slashCommands: { items: [], hasMore: false, totalCount: 0 }, }; function useCommunityHubExploreItems() { const [loading, setLoading] = useState(true); const [exploreItems, setExploreItems] = useState(DEFAULT_EXPLORE_ITEMS); useEffect(() => { const fetchData = async () => { setLoading(true); try { const { success, result } = await CommunityHub.fetchExploreItems(); if (success) setExploreItems(result || DEFAULT_EXPLORE_ITEMS); } catch (error) { console.error("Error fetching data:", error); } finally { setLoading(false); } }; fetchData(); }, []); return { loading, exploreItems }; } export default function HubItems() { const { loading, exploreItems } = useCommunityHubExploreItems(); return ( <div className="w-full flex flex-col gap-y-1 pb-6 pt-6"> <div className="flex flex-col gap-y-2 mb-4"> <p className="text-base font-semibold text-theme-text-primary"> Recently Added on AnythingLLM Community Hub </p> <p className="text-xs text-theme-text-secondary"> Explore the latest additions to the AnythingLLM Community Hub </p> </div> <HubCategory loading={loading} exploreItems={exploreItems} /> </div> ); } function HubCategory({ loading, exploreItems }) { if (loading) return <HubItemCardSkeleton />; return ( <div className="flex flex-col gap-4"> {Object.keys(exploreItems).map((type) => { const path = typeToPath(type); if (exploreItems[type].items.length === 0) return null; return ( <div key={type} className="rounded-lg w-full"> <div className="flex justify-between items-center"> <h3 className="text-theme-text-primary capitalize font-medium mb-3"> {readableType(type)} </h3> {exploreItems[type].hasMore && ( <a href={paths.communityHub.viewMoreOfType(path)} target="_blank" rel="noopener noreferrer" className="text-primary-button hover:text-primary-button/80 text-sm" > Explore More → </a> )} </div> <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2"> {exploreItems[type].items.map((item) => ( <HubItemCard key={item.id} type={type} item={item} /> ))} </div> </div> ); })} </div> ); } export function HubItemCardSkeleton() { return ( <div className="flex flex-col gap-4"> <div className="rounded-lg w-full"> <div className="flex justify-between items-center"> <Skeleton.default height="40px" width="300px" highlightColor="var(--theme-settings-input-active)" baseColor="var(--theme-settings-input-bg)" count={1} /> </div> <Skeleton.default height="200px" width="300px" highlightColor="var(--theme-settings-input-active)" baseColor="var(--theme-settings-input-bg)" count={4} className="rounded-lg" containerClassName="flex flex-wrap gap-2 mt-1" /> </div> <div className="rounded-lg w-full"> <div className="flex justify-between items-center"> <Skeleton.default height="40px" width="300px" highlightColor="var(--theme-settings-input-active)" baseColor="var(--theme-settings-input-bg)" count={1} /> </div> <Skeleton.default height="200px" width="300px" highlightColor="var(--theme-settings-input-active)" baseColor="var(--theme-settings-input-bg)" count={4} className="rounded-lg" containerClassName="flex flex-wrap gap-2 mt-1" /> </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/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/agentSkill.jsx
frontend/src/pages/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/agentSkill.jsx
import { Link } from "react-router-dom"; import paths from "@/utils/paths"; import pluralize from "pluralize"; import { VisibilityIcon } from "./generic"; export default function AgentSkillHubCard({ item }) { return ( <> <Link key={item.id} to={paths.communityHub.importItem(item.importId)} className="bg-black/70 light:bg-slate-100 rounded-lg p-3 hover:bg-black/60 light:hover:bg-slate-200 transition-all duration-200 cursor-pointer group border border-transparent hover:border-slate-400" > <div className="flex gap-x-2 items-center"> <p className="text-white text-sm font-medium">{item.name}</p> <VisibilityIcon visibility={item.visibility} /> </div> <div className="flex flex-col gap-2"> <p className="text-white/60 text-xs mt-1">{item.description}</p> <p className="font-mono text-xs mt-1 text-white/60"> {item.verified ? ( <span className="text-green-500">Verified</span> ) : ( <span className="text-red-500">Unverified</span> )}{" "} Skill </p> <p className="font-mono text-xs mt-1 text-white/60"> {item.manifest.files?.length || 0}{" "} {pluralize("file", item.manifest.files?.length || 0)} found </p> </div> <div className="flex justify-end mt-2"> <Link to={paths.communityHub.importItem(item.importId)} className="text-primary-button hover:text-primary-button/80 text-sm font-medium px-3 py-1.5 rounded-md bg-black/30 light:bg-slate-200 group-hover:bg-black/50 light:group-hover:bg-slate-300 transition-all" > Import → </Link> </div> </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/pages/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/index.jsx
frontend/src/pages/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/index.jsx
import GenericHubCard from "./generic"; import SystemPromptHubCard from "./systemPrompt"; import SlashCommandHubCard from "./slashCommand"; import AgentSkillHubCard from "./agentSkill"; import AgentFlowHubCard from "./agentFlow"; export default function HubItemCard({ type, item }) { switch (type) { case "systemPrompts": return <SystemPromptHubCard item={item} />; case "slashCommands": return <SlashCommandHubCard item={item} />; case "agentSkills": return <AgentSkillHubCard item={item} />; case "agentFlows": return <AgentFlowHubCard item={item} />; default: return <GenericHubCard item={item} />; } }
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/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/slashCommand.jsx
frontend/src/pages/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/slashCommand.jsx
import truncate from "truncate"; import { Link } from "react-router-dom"; import paths from "@/utils/paths"; import { VisibilityIcon } from "./generic"; export default function SlashCommandHubCard({ item }) { return ( <> <Link key={item.id} to={paths.communityHub.importItem(item.importId)} className="bg-black/70 light:bg-slate-100 rounded-lg p-3 hover:bg-black/60 light:hover:bg-slate-200 transition-all duration-200 cursor-pointer group border border-transparent hover:border-slate-400" > <div className="flex gap-x-2 items-center"> <p className="text-white text-sm font-medium">{item.name}</p> <VisibilityIcon visibility={item.visibility} /> </div> <div className="flex flex-col gap-2"> <p className="text-white/60 text-xs mt-1">{item.description}</p> <label className="text-white/60 text-xs font-semibold mt-4"> Command </label> <p className="text-white/60 text-xs bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md font-mono border border-slate-800 light:border-slate-300"> {item.command} </p> <label className="text-white/60 text-xs font-semibold mt-4"> Prompt </label> <p className="text-white/60 text-xs bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md font-mono border border-slate-800 light:border-slate-300"> {truncate(item.prompt, 90)} </p> </div> <div className="flex justify-end mt-2"> <Link to={paths.communityHub.importItem(item.importId)} className="text-primary-button hover:text-primary-button/80 text-sm font-medium px-3 py-1.5 rounded-md bg-black/30 light:bg-slate-200 group-hover:bg-black/50 light:group-hover:bg-slate-300 transition-all" > Import → </Link> </div> </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/pages/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/generic.jsx
frontend/src/pages/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/generic.jsx
import paths from "@/utils/paths"; import { Eye, LockSimple } from "@phosphor-icons/react"; import { Link } from "react-router-dom"; import { Tooltip } from "react-tooltip"; export default function GenericHubCard({ item }) { return ( <div key={item.id} className="bg-zinc-800 light:bg-slate-100 rounded-lg p-3 hover:bg-zinc-700 light:hover:bg-slate-200 transition-all duration-200" > <p className="text-white text-sm font-medium">{item.name}</p> <p className="text-white/60 text-xs mt-1">{item.description}</p> <div className="flex justify-end mt-2"> <Link className="text-primary-button hover:text-primary-button/80 text-xs" to={paths.communityHub.importItem(item.importId)} > Import → </Link> </div> </div> ); } export function VisibilityIcon({ visibility = "public" }) { const Icon = visibility === "private" ? LockSimple : Eye; return ( <> <div data-tooltip-id="visibility-icon" data-tooltip-content={`This item is ${visibility === "private" ? "private" : "public"}`} > <Icon className="w-4 h-4 text-white/60" /> </div> <Tooltip id="visibility-icon" place="top" delayShow={300} className="allm-tooltip !allm-text-xs" /> </> ); }
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/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/systemPrompt.jsx
frontend/src/pages/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/systemPrompt.jsx
import truncate from "truncate"; import { Link } from "react-router-dom"; import paths from "@/utils/paths"; import { VisibilityIcon } from "./generic"; export default function SystemPromptHubCard({ item }) { return ( <> <Link key={item.id} to={paths.communityHub.importItem(item.importId)} className="bg-black/70 light:bg-slate-100 rounded-lg p-3 hover:bg-black/60 light:hover:bg-slate-200 transition-all duration-200 cursor-pointer group border border-transparent hover:border-slate-400" > <div className="flex gap-x-2 items-center"> <p className="text-white text-sm font-medium">{item.name}</p> <VisibilityIcon visibility={item.visibility} /> </div> <div className="flex flex-col gap-2"> <p className="text-white/60 text-xs mt-1">{item.description}</p> <label className="text-white/60 text-xs font-semibold mt-4"> Prompt </label> <p className="text-white/60 text-xs bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md font-mono border border-slate-800 light:border-slate-300"> {truncate(item.prompt, 90)} </p> </div> <div className="flex justify-end mt-2"> <Link to={paths.communityHub.importItem(item.importId)} className="text-primary-button hover:text-primary-button/80 text-sm font-medium px-3 py-1.5 rounded-md bg-black/30 light:bg-slate-200 group-hover:bg-black/50 light:group-hover:bg-slate-300 transition-all" > Import → </Link> </div> </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/pages/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/agentFlow.jsx
frontend/src/pages/GeneralSettings/CommunityHub/Trending/HubItems/HubItemCard/agentFlow.jsx
import { Link } from "react-router-dom"; import paths from "@/utils/paths"; import { VisibilityIcon } from "./generic"; import { safeJsonParse } from "@/utils/request"; export default function AgentFlowHubCard({ item }) { const flow = safeJsonParse(item.flow, { steps: [] }); return ( <Link to={paths.communityHub.importItem(item.importId)} className="bg-black/70 light:bg-slate-100 rounded-lg p-3 hover:bg-black/60 light:hover:bg-slate-200 transition-all duration-200 cursor-pointer group border border-transparent hover:border-slate-400 flex flex-col h-full" > <div className="flex gap-x-2 items-center"> <p className="text-white text-sm font-medium">{item.name}</p> <VisibilityIcon visibility={item.visibility} /> </div> <div className="flex flex-col gap-2 flex-1"> <p className="text-white/60 text-xs mt-1">{item.description}</p> <label className="text-white/60 text-xs font-semibold mt-4"> Steps ({flow.steps.length}): </label> <p className="text-white/60 text-xs bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md font-mono border border-slate-800 light:border-slate-300"> <ul className="list-disc pl-4"> {flow.steps.map((step, index) => ( <li key={index}>{step.type}</li> ))} </ul> </p> </div> <div className="flex justify-end mt-2"> <Link to={paths.communityHub.importItem(item.importId)} className="text-primary-button hover:text-primary-button/80 text-sm font-medium px-3 py-1.5 rounded-md bg-black/30 light:bg-slate-200 group-hover:bg-black/50 light:group-hover:bg-slate-300 transition-all" > Import → </Link> </div> </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/pages/GeneralSettings/EmbeddingTextSplitterPreference/index.jsx
frontend/src/pages/GeneralSettings/EmbeddingTextSplitterPreference/index.jsx
import React, { useEffect, useState } from "react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import PreLoader from "@/components/Preloader"; import CTAButton from "@/components/lib/CTAButton"; import Admin from "@/models/admin"; import showToast from "@/utils/toast"; import { numberWithCommas } from "@/utils/numbers"; import { useTranslation } from "react-i18next"; import { useModal } from "@/hooks/useModal"; import ModalWrapper from "@/components/ModalWrapper"; import ChangeWarningModal from "@/components/ChangeWarning"; function isNullOrNaN(value) { if (value === null) return true; return isNaN(value); } export default function EmbeddingTextSplitterPreference() { const [settings, setSettings] = useState({}); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); const { isOpen, openModal, closeModal } = useModal(); const { t } = useTranslation(); const handleSubmit = async (e) => { e.preventDefault(); const form = new FormData(e.target); if ( Number(form.get("text_splitter_chunk_overlap")) >= Number(form.get("text_splitter_chunk_size")) ) { showToast( "Chunk overlap cannot be larger or equal to chunk size.", "error" ); return; } openModal(); }; const handleSaveSettings = async () => { setSaving(true); try { const form = new FormData( document.getElementById("text-splitter-chunking-form") ); await Admin.updateSystemPreferences({ text_splitter_chunk_size: isNullOrNaN( form.get("text_splitter_chunk_size") ) ? 1000 : Number(form.get("text_splitter_chunk_size")), text_splitter_chunk_overlap: isNullOrNaN( form.get("text_splitter_chunk_overlap") ) ? 1000 : Number(form.get("text_splitter_chunk_overlap")), }); setHasChanges(false); closeModal(); showToast("Text chunking strategy settings saved.", "success"); } catch (error) { showToast("Failed to save text chunking strategy settings.", "error"); } finally { setSaving(false); } }; useEffect(() => { async function fetchSettings() { const _settings = (await Admin.systemPreferences())?.settings; setSettings(_settings ?? {}); setLoading(false); } fetchSettings(); }, []); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> {loading ? ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="w-full h-full flex justify-center items-center"> <PreLoader /> </div> </div> ) : ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <form onSubmit={handleSubmit} onChange={() => setHasChanges(true)} className="flex w-full" id="text-splitter-chunking-form" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-4 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="flex gap-x-4 items-center"> <p className="text-lg leading-6 font-bold text-white"> {t("text.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> {t("text.desc-start")} <br /> {t("text.desc-end")} </p> </div> <div className="w-full justify-end flex"> {hasChanges && ( <CTAButton className="mt-3 mr-0 -mb-14 z-10"> {saving ? t("common.saving") : t("common.save")} </CTAButton> )} </div> <div className="flex flex-col gap-y-4 mt-8"> <div className="flex flex-col max-w-[300px]"> <div className="flex flex-col gap-y-2 mb-4"> <label className="text-white text-sm font-semibold block"> {t("text.size.title")} </label> <p className="text-xs text-white/60"> {t("text.size.description")} </p> </div> <input type="number" name="text_splitter_chunk_size" min={1} max={settings?.max_embed_chunk_size || 1000} onWheel={(e) => e?.currentTarget?.blur()} 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="maximum length of vectorized text" defaultValue={ isNullOrNaN(settings?.text_splitter_chunk_size) ? 1000 : Number(settings?.text_splitter_chunk_size) } required={true} autoComplete="off" /> <p className="text-xs text-white/40 mt-2"> {t("text.size.recommend")}{" "} {numberWithCommas(settings?.max_embed_chunk_size || 1000)}. </p> </div> </div> <div className="flex flex-col gap-y-4 mt-8"> <div className="flex flex-col max-w-[300px]"> <div className="flex flex-col gap-y-2 mb-4"> <label className="text-white text-sm font-semibold block"> {t("text.overlap.title")} </label> <p className="text-xs text-white/60"> {t("text.overlap.description")} </p> </div> <input type="number" name="text_splitter_chunk_overlap" min={0} onWheel={(e) => e?.currentTarget?.blur()} 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="maximum length of vectorized text" defaultValue={ isNullOrNaN(settings?.text_splitter_chunk_overlap) ? 20 : Number(settings?.text_splitter_chunk_overlap) } required={true} autoComplete="off" /> </div> </div> </div> </form> </div> )} <ModalWrapper isOpen={isOpen}> <ChangeWarningModal warningText="Changing text splitter settings will clear any previously cached documents.\n\nThese new settings will be applied to all documents when embedding them into a workspace." onClose={closeModal} onConfirm={handleSaveSettings} /> </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/GeneralSettings/EmbeddingPreference/index.jsx
frontend/src/pages/GeneralSettings/EmbeddingPreference/index.jsx
import React, { useEffect, useState, useRef } from "react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import System from "@/models/system"; import showToast from "@/utils/toast"; import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png"; import OpenAiLogo from "@/media/llmprovider/openai.png"; import AzureOpenAiLogo from "@/media/llmprovider/azure.png"; import GeminiAiLogo from "@/media/llmprovider/gemini.png"; import LocalAiLogo from "@/media/llmprovider/localai.png"; import OllamaLogo from "@/media/llmprovider/ollama.png"; import LMStudioLogo from "@/media/llmprovider/lmstudio.png"; import CohereLogo from "@/media/llmprovider/cohere.png"; import VoyageAiLogo from "@/media/embeddingprovider/voyageai.png"; import LiteLLMLogo from "@/media/llmprovider/litellm.png"; import GenericOpenAiLogo from "@/media/llmprovider/generic-openai.png"; import MistralAiLogo from "@/media/llmprovider/mistral.jpeg"; import OpenRouterLogo from "@/media/llmprovider/openrouter.jpeg"; import PreLoader from "@/components/Preloader"; import ChangeWarningModal from "@/components/ChangeWarning"; import OpenAiOptions from "@/components/EmbeddingSelection/OpenAiOptions"; import AzureAiOptions from "@/components/EmbeddingSelection/AzureAiOptions"; import GeminiOptions from "@/components/EmbeddingSelection/GeminiOptions"; import LocalAiOptions from "@/components/EmbeddingSelection/LocalAiOptions"; import NativeEmbeddingOptions from "@/components/EmbeddingSelection/NativeEmbeddingOptions"; import OllamaEmbeddingOptions from "@/components/EmbeddingSelection/OllamaOptions"; import LMStudioEmbeddingOptions from "@/components/EmbeddingSelection/LMStudioOptions"; import CohereEmbeddingOptions from "@/components/EmbeddingSelection/CohereOptions"; import VoyageAiOptions from "@/components/EmbeddingSelection/VoyageAiOptions"; import LiteLLMOptions from "@/components/EmbeddingSelection/LiteLLMOptions"; import GenericOpenAiEmbeddingOptions from "@/components/EmbeddingSelection/GenericOpenAiOptions"; import OpenRouterOptions from "@/components/EmbeddingSelection/OpenRouterOptions"; import EmbedderItem from "@/components/EmbeddingSelection/EmbedderItem"; import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react"; import { useModal } from "@/hooks/useModal"; import ModalWrapper from "@/components/ModalWrapper"; import CTAButton from "@/components/lib/CTAButton"; import { useTranslation } from "react-i18next"; import MistralAiOptions from "@/components/EmbeddingSelection/MistralAiOptions"; const EMBEDDERS = [ { name: "AnythingLLM Embedder", value: "native", logo: AnythingLLMIcon, options: (settings) => <NativeEmbeddingOptions settings={settings} />, description: "Use the built-in embedding provider for AnythingLLM. Zero setup!", }, { name: "OpenAI", value: "openai", logo: OpenAiLogo, options: (settings) => <OpenAiOptions settings={settings} />, description: "The standard option for most non-commercial use.", }, { name: "Azure OpenAI", value: "azure", logo: AzureOpenAiLogo, options: (settings) => <AzureAiOptions settings={settings} />, description: "The enterprise option of OpenAI hosted on Azure services.", }, { name: "Gemini", value: "gemini", logo: GeminiAiLogo, options: (settings) => <GeminiOptions settings={settings} />, description: "Run powerful embedding models from Google AI.", }, { name: "Local AI", value: "localai", logo: LocalAiLogo, options: (settings) => <LocalAiOptions settings={settings} />, description: "Run embedding models locally on your own machine.", }, { name: "Ollama", value: "ollama", logo: OllamaLogo, options: (settings) => <OllamaEmbeddingOptions settings={settings} />, description: "Run embedding models locally on your own machine.", }, { name: "LM Studio", value: "lmstudio", logo: LMStudioLogo, options: (settings) => <LMStudioEmbeddingOptions settings={settings} />, description: "Discover, download, and run thousands of cutting edge LLMs in a few clicks.", }, { name: "OpenRouter", value: "openrouter", logo: OpenRouterLogo, options: (settings) => <OpenRouterOptions settings={settings} />, description: "Run embedding models from OpenRouter.", }, { name: "LiteLLM", value: "litellm", logo: LiteLLMLogo, options: (settings) => <LiteLLMOptions settings={settings} />, description: "Run powerful embedding models from LiteLLM.", }, { name: "Cohere", value: "cohere", logo: CohereLogo, options: (settings) => <CohereEmbeddingOptions settings={settings} />, description: "Run powerful embedding models from Cohere.", }, { name: "Voyage AI", value: "voyageai", logo: VoyageAiLogo, options: (settings) => <VoyageAiOptions settings={settings} />, description: "Run powerful embedding models from Voyage AI.", }, { name: "Mistral AI", value: "mistral", logo: MistralAiLogo, options: (settings) => <MistralAiOptions settings={settings} />, description: "Run powerful embedding models from Mistral AI.", }, { name: "Generic OpenAI", value: "generic-openai", logo: GenericOpenAiLogo, options: (settings) => ( <GenericOpenAiEmbeddingOptions settings={settings} /> ), description: "Run embedding models from any OpenAI compatible API service.", }, ]; export default function GeneralEmbeddingPreference() { const [saving, setSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); const [hasEmbeddings, setHasEmbeddings] = useState(false); const [hasCachedEmbeddings, setHasCachedEmbeddings] = useState(false); const [settings, setSettings] = useState(null); const [loading, setLoading] = useState(true); const [searchQuery, setSearchQuery] = useState(""); const [filteredEmbedders, setFilteredEmbedders] = useState([]); const [selectedEmbedder, setSelectedEmbedder] = useState(null); const [searchMenuOpen, setSearchMenuOpen] = useState(false); const searchInputRef = useRef(null); const { isOpen, openModal, closeModal } = useModal(); const { t } = useTranslation(); function embedderModelChanged(formEl) { try { const newModel = new FormData(formEl).get("EmbeddingModelPref") ?? null; if (newModel === null) return false; return settings?.EmbeddingModelPref !== newModel; } catch (error) { console.error(error); } return false; } const handleSubmit = async (e) => { e.preventDefault(); if ( (selectedEmbedder !== settings?.EmbeddingEngine || embedderModelChanged(e.target)) && hasChanges && (hasEmbeddings || hasCachedEmbeddings) ) { openModal(); } else { await handleSaveSettings(); } }; const handleSaveSettings = async () => { setSaving(true); const form = document.getElementById("embedding-form"); const settingsData = {}; const formData = new FormData(form); settingsData.EmbeddingEngine = selectedEmbedder; for (var [key, value] of formData.entries()) settingsData[key] = value; const { error } = await System.updateSystem(settingsData); if (error) { showToast(`Failed to save embedding settings: ${error}`, "error"); setHasChanges(true); } else { showToast("Embedding preferences saved successfully.", "success"); setHasChanges(false); } setSaving(false); closeModal(); }; const updateChoice = (selection) => { setSearchQuery(""); setSelectedEmbedder(selection); setSearchMenuOpen(false); setHasChanges(true); }; const handleXButton = () => { if (searchQuery.length > 0) { setSearchQuery(""); if (searchInputRef.current) searchInputRef.current.value = ""; } else { setSearchMenuOpen(!searchMenuOpen); } }; useEffect(() => { async function fetchKeys() { const _settings = await System.keys(); setSettings(_settings); setSelectedEmbedder(_settings?.EmbeddingEngine || "native"); setHasEmbeddings(_settings?.HasExistingEmbeddings || false); setHasCachedEmbeddings(_settings?.HasCachedEmbeddings || false); setLoading(false); } fetchKeys(); }, []); useEffect(() => { const filtered = EMBEDDERS.filter((embedder) => embedder.name.toLowerCase().includes(searchQuery.toLowerCase()) ); setFilteredEmbedders(filtered); }, [searchQuery, selectedEmbedder]); const selectedEmbedderObject = EMBEDDERS.find( (embedder) => embedder.value === selectedEmbedder ); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> {loading ? ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="w-full h-full flex justify-center items-center"> <PreLoader /> </div> </div> ) : ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <form id="embedding-form" onSubmit={handleSubmit} className="flex w-full" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] py-16 md:py-6"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="flex gap-x-4 items-center"> <p className="text-lg leading-6 font-bold text-white"> {t("embedding.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> {t("embedding.desc-start")} <br /> {t("embedding.desc-end")} </p> </div> <div className="w-full justify-end flex"> {hasChanges && ( <CTAButton onClick={() => handleSubmit()} className="mt-3 mr-0 -mb-14 z-10" > {saving ? t("common.saving") : t("common.save")} </CTAButton> )} </div> <div className="text-base font-bold text-white mt-6 mb-4"> {t("embedding.provider.title")} </div> <div className="relative"> {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="embedder-search" autoComplete="off" placeholder="Search all embedding 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-white 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]"> {filteredEmbedders.map((embedder) => ( <EmbedderItem key={embedder.name} name={embedder.name} value={embedder.value} image={embedder.logo} description={embedder.description} checked={selectedEmbedder === embedder.value} onClick={() => updateChoice(embedder.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={selectedEmbedderObject.logo} alt={`${selectedEmbedderObject.name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col text-left"> <div className="text-sm font-semibold text-white"> {selectedEmbedderObject.name} </div> <div className="mt-1 text-xs text-description"> {selectedEmbedderObject.description} </div> </div> </div> <CaretUpDown size={24} weight="bold" className="text-white" /> </button> )} </div> <div onChange={() => setHasChanges(true)} className="mt-4 flex flex-col gap-y-1" > {selectedEmbedder && EMBEDDERS.find( (embedder) => embedder.value === selectedEmbedder )?.options(settings)} </div> </div> </form> </div> )} <ModalWrapper isOpen={isOpen}> <ChangeWarningModal warningText="Switching the embedding model will reset all previously embedded documents in all workspaces.\n\nConfirming will clear all embeddings from your vector database and remove all documents from your workspaces. Your uploaded documents will not be deleted, they will be available for re-embedding." onClose={closeModal} onConfirm={handleSaveSettings} /> </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/GeneralSettings/AudioPreference/index.jsx
frontend/src/pages/GeneralSettings/AudioPreference/index.jsx
import React, { useEffect, useState, useRef } from "react"; import { isMobile } from "react-device-detect"; import Sidebar from "@/components/SettingsSidebar"; import System from "@/models/system"; import PreLoader from "@/components/Preloader"; import SpeechToTextProvider from "./stt"; import TextToSpeechProvider from "./tts"; export default function AudioPreference() { const [settings, setSettings] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { async function fetchKeys() { const _settings = await System.keys(); setSettings(_settings); setLoading(false); } fetchKeys(); }, []); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> {loading ? ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="w-full h-full flex justify-center items-center"> <PreLoader /> </div> </div> ) : ( <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <SpeechToTextProvider settings={settings} /> <TextToSpeechProvider settings={settings} /> </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/GeneralSettings/AudioPreference/stt.jsx
frontend/src/pages/GeneralSettings/AudioPreference/stt.jsx
import React, { useEffect, useState, useRef } from "react"; import System from "@/models/system"; import showToast from "@/utils/toast"; import LLMItem from "@/components/LLMSelection/LLMItem"; import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react"; import CTAButton from "@/components/lib/CTAButton"; import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png"; import BrowserNative from "@/components/SpeechToText/BrowserNative"; const PROVIDERS = [ { name: "System native", value: "native", logo: AnythingLLMIcon, options: (settings) => <BrowserNative settings={settings} />, description: "Uses your browser's built in STT service if supported.", }, ]; export default function SpeechToTextProvider({ settings }) { const [saving, setSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); const [searchQuery, setSearchQuery] = useState(""); const [filteredProviders, setFilteredProviders] = useState([]); const [selectedProvider, setSelectedProvider] = useState( settings?.SpeechToTextProvider || "native" ); const [searchMenuOpen, setSearchMenuOpen] = useState(false); const searchInputRef = useRef(null); const handleSubmit = async (e) => { e.preventDefault(); const form = e.target; const data = { SpeechToTextProvider: selectedProvider }; const formData = new FormData(form); for (var [key, value] of formData.entries()) data[key] = value; const { error } = await System.updateSystem(data); setSaving(true); if (error) { showToast(`Failed to save preferences: ${error}`, "error"); } else { showToast("Speech-to-text preferences saved successfully.", "success"); } setSaving(false); setHasChanges(!!error); }; const updateProviderChoice = (selection) => { setSearchQuery(""); setSelectedProvider(selection); setSearchMenuOpen(false); setHasChanges(true); }; const handleXButton = () => { if (searchQuery.length > 0) { setSearchQuery(""); if (searchInputRef.current) searchInputRef.current.value = ""; } else { setSearchMenuOpen(!searchMenuOpen); } }; useEffect(() => { const filtered = PROVIDERS.filter((provider) => provider.name.toLowerCase().includes(searchQuery.toLowerCase()) ); setFilteredProviders(filtered); }, [searchQuery, selectedProvider]); const selectedProviderObject = PROVIDERS.find( (provider) => provider.value === selectedProvider ); return ( <form onSubmit={handleSubmit} className="flex w-full"> <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="flex gap-x-4 items-center"> <p className="text-lg leading-6 font-bold text-white"> Speech-to-text Preference </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> Here you can specify what kind of text-to-speech and speech-to-text providers you would want to use in your AnythingLLM experience. By default, we use the browser's built in support for these services, but you may want to use others. </p> </div> <div className="w-full justify-end flex"> {hasChanges && ( <CTAButton onClick={() => handleSubmit()} className="mt-3 mr-0 -mb-14 z-10" > {saving ? "Saving..." : "Save changes"} </CTAButton> )} </div> <div className="text-base font-bold text-white mt-6 mb-4">Provider</div> <div className="relative"> {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="stt-provider-search" autoComplete="off" placeholder="Search speech to text 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-white 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]"> {filteredProviders.map((provider) => ( <LLMItem key={provider.name} name={provider.name} value={provider.value} image={provider.logo} description={provider.description} checked={selectedProvider === provider.value} onClick={() => updateProviderChoice(provider.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={selectedProviderObject.logo} alt={`${selectedProviderObject.name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col text-left"> <div className="text-sm font-semibold text-white"> {selectedProviderObject.name} </div> <div className="mt-1 text-xs text-description"> {selectedProviderObject.description} </div> </div> </div> <CaretUpDown size={24} weight="bold" className="text-white" /> </button> )} </div> <div onChange={() => setHasChanges(true)} className="mt-4 flex flex-col gap-y-1" > {selectedProvider && PROVIDERS.find( (provider) => provider.value === selectedProvider )?.options(settings)} </div> </div> </form> ); }
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/GeneralSettings/AudioPreference/tts.jsx
frontend/src/pages/GeneralSettings/AudioPreference/tts.jsx
import React, { useEffect, useState, useRef } from "react"; import System from "@/models/system"; import showToast from "@/utils/toast"; import LLMItem from "@/components/LLMSelection/LLMItem"; import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react"; import CTAButton from "@/components/lib/CTAButton"; import OpenAiLogo from "@/media/llmprovider/openai.png"; import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png"; import ElevenLabsIcon from "@/media/ttsproviders/elevenlabs.png"; import PiperTTSIcon from "@/media/ttsproviders/piper.png"; import GenericOpenAiLogo from "@/media/ttsproviders/generic-openai.png"; import BrowserNative from "@/components/TextToSpeech/BrowserNative"; import OpenAiTTSOptions from "@/components/TextToSpeech/OpenAiOptions"; import ElevenLabsTTSOptions from "@/components/TextToSpeech/ElevenLabsOptions"; import PiperTTSOptions from "@/components/TextToSpeech/PiperTTSOptions"; import OpenAiGenericTTSOptions from "@/components/TextToSpeech/OpenAiGenericOptions"; const PROVIDERS = [ { name: "System native", value: "native", logo: AnythingLLMIcon, options: (settings) => <BrowserNative settings={settings} />, description: "Uses your browser's built in TTS service if supported.", }, { name: "OpenAI", value: "openai", logo: OpenAiLogo, options: (settings) => <OpenAiTTSOptions settings={settings} />, description: "Use OpenAI's text to speech voices.", }, { name: "ElevenLabs", value: "elevenlabs", logo: ElevenLabsIcon, options: (settings) => <ElevenLabsTTSOptions settings={settings} />, description: "Use ElevenLabs's text to speech voices and technology.", }, { name: "PiperTTS", value: "piper_local", logo: PiperTTSIcon, options: (settings) => <PiperTTSOptions settings={settings} />, description: "Run TTS models locally in your browser privately.", }, { name: "OpenAI Compatible", value: "generic-openai", logo: GenericOpenAiLogo, options: (settings) => <OpenAiGenericTTSOptions settings={settings} />, description: "Connect to an OpenAI compatible TTS service running locally or remotely.", }, ]; export default function TextToSpeechProvider({ settings }) { const [saving, setSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); const [searchQuery, setSearchQuery] = useState(""); const [filteredProviders, setFilteredProviders] = useState([]); const [selectedProvider, setSelectedProvider] = useState( settings?.TextToSpeechProvider || "native" ); const [searchMenuOpen, setSearchMenuOpen] = useState(false); const searchInputRef = useRef(null); const handleSubmit = async (e) => { e?.preventDefault(); const form = e.target; const data = { TextToSpeechProvider: selectedProvider }; const formData = new FormData(form); for (var [key, value] of formData.entries()) data[key] = value; const { error } = await System.updateSystem(data); setSaving(true); if (error) { showToast(`Failed to save preferences: ${error}`, "error"); } else { showToast("Text-to-speech preferences saved successfully.", "success"); } setSaving(false); setHasChanges(!!error); }; const updateProviderChoice = (selection) => { setSearchQuery(""); setSelectedProvider(selection); setSearchMenuOpen(false); setHasChanges(true); }; const handleXButton = () => { if (searchQuery.length > 0) { setSearchQuery(""); if (searchInputRef.current) searchInputRef.current.value = ""; } else { setSearchMenuOpen(!searchMenuOpen); } }; useEffect(() => { const filtered = PROVIDERS.filter((provider) => provider.name.toLowerCase().includes(searchQuery.toLowerCase()) ); setFilteredProviders(filtered); }, [searchQuery, selectedProvider]); const selectedProviderObject = PROVIDERS.find( (provider) => provider.value === selectedProvider ); return ( <form onSubmit={handleSubmit} className="flex w-full"> <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="flex gap-x-4 items-center"> <p className="text-lg leading-6 font-bold text-white"> Text-to-speech Preference </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> Here you can specify what kind of text-to-speech providers you would want to use in your AnythingLLM experience. By default, we use the browser's built in support for these services, but you may want to use others. </p> </div> <div className="w-full justify-end flex"> {hasChanges && ( <CTAButton className="mt-3 mr-0 -mb-14 z-10"> {saving ? "Saving..." : "Save changes"} </CTAButton> )} </div> <div className="text-base font-bold text-white mt-6 mb-4">Provider</div> <div className="relative"> {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="tts-provider-search" autoComplete="off" placeholder="Search text to speech 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-white 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]"> {filteredProviders.map((provider) => ( <LLMItem key={provider.name} name={provider.name} value={provider.value} image={provider.logo} description={provider.description} checked={selectedProvider === provider.value} onClick={() => updateProviderChoice(provider.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={selectedProviderObject.logo} alt={`${selectedProviderObject.name} logo`} className="w-10 h-10 rounded-md" /> <div className="flex flex-col text-left"> <div className="text-sm font-semibold text-white"> {selectedProviderObject.name} </div> <div className="mt-1 text-xs text-description"> {selectedProviderObject.description} </div> </div> </div> <CaretUpDown size={24} weight="bold" className="text-white" /> </button> )} </div> <div onChange={() => setHasChanges(true)} className="mt-4 flex flex-col gap-y-1" > {selectedProvider && PROVIDERS.find( (provider) => provider.value === selectedProvider )?.options(settings)} </div> </div> </form> ); }
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/GeneralSettings/PrivacyAndData/index.jsx
frontend/src/pages/GeneralSettings/PrivacyAndData/index.jsx
import { useEffect, useState } from "react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import showToast from "@/utils/toast"; import System from "@/models/system"; import PreLoader from "@/components/Preloader"; import { useTranslation } from "react-i18next"; import ProviderPrivacy from "@/components/ProviderPrivacy"; export default function PrivacyAndDataHandling() { const [settings, setSettings] = useState({}); const [loading, setLoading] = useState(true); const { t } = useTranslation(); useEffect(() => { async function fetchSettings() { setLoading(true); const settings = await System.keys(); setSettings(settings); setLoading(false); } fetchSettings(); }, []); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <div style={{ height: isMobile ? "100%" : "calc(100% - 32px)" }} className="relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] light:border light:border-theme-sidebar-border bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2"> <div className="items-center flex gap-x-4"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> {t("privacy.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary"> {t("privacy.description")} </p> </div> {loading ? ( <div className="h-1/2 transition-all duration-500 relative md:ml-[2px] md:mr-[8px] md:my-[16px] md:rounded-[26px] p-[18px] h-full overflow-y-scroll"> <div className="w-full h-full flex justify-center items-center"> <PreLoader /> </div> </div> ) : ( <div className="overflow-x-auto flex flex-col gap-y-6 pt-6"> <ProviderPrivacy /> <TelemetryLogs settings={settings} /> </div> )} </div> </div> </div> ); } function TelemetryLogs({ settings }) { const [telemetry, setTelemetry] = useState( settings?.DisableTelemetry !== "true" ); const { t } = useTranslation(); async function toggleTelemetry() { await System.updateSystem({ DisableTelemetry: !telemetry ? "false" : "true", }); setTelemetry(!telemetry); showToast( `Anonymous Telemetry has been ${!telemetry ? "enabled" : "disabled"}.`, "info", { clear: true } ); } return ( <div className="relative w-full max-h-full"> <div className="relative rounded-lg"> <div className="space-y-6 flex h-full w-full"> <div className="w-full flex flex-col gap-y-4"> <div className=""> <label className="mb-2.5 block font-medium text-theme-text-primary"> {t("privacy.anonymous")} </label> <label className="relative inline-flex cursor-pointer items-center"> <input type="checkbox" onClick={toggleTelemetry} checked={telemetry} className="peer sr-only pointer-events-none" /> <div className="peer-disabled:opacity-50 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> </div> </div> <div className="flex flex-col items-left space-y-2"> <p className="text-theme-text-secondary text-xs rounded-lg w-96"> All events do not record IP-address and contain{" "} <b>no identifying</b> content, settings, chats, or other non-usage based information. To see the list of event tags collected you can look on{" "} <a href="https://github.com/search?q=repo%3AMintplex-Labs%2Fanything-llm%20.sendTelemetry(&type=code" className="underline text-blue-400" target="_blank" > GitHub here </a> . </p> <p className="text-theme-text-secondary text-xs rounded-lg w-96"> As an open-source project we respect your right to privacy. We are dedicated to building the best solution for integrating AI and documents privately and securely. If you do decide to turn off telemetry all we ask is to consider sending us feedback and thoughts so that we can continue to improve AnythingLLM for you.{" "} <a href="mailto:[email protected]" className="underline text-blue-400" target="_blank" > [email protected] </a> . </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/pages/GeneralSettings/ApiKeys/index.jsx
frontend/src/pages/GeneralSettings/ApiKeys/index.jsx
import { useEffect, useState } from "react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; import { PlusCircle } from "@phosphor-icons/react"; import Admin from "@/models/admin"; import ApiKeyRow from "./ApiKeyRow"; import NewApiKeyModal from "./NewApiKeyModal"; import paths from "@/utils/paths"; import { userFromStorage } from "@/utils/request"; import System from "@/models/system"; import ModalWrapper from "@/components/ModalWrapper"; import { useModal } from "@/hooks/useModal"; import CTAButton from "@/components/lib/CTAButton"; import { useTranslation } from "react-i18next"; export default function AdminApiKeys() { const { isOpen, openModal, closeModal } = useModal(); const { t } = useTranslation(); const [loading, setLoading] = useState(true); const [apiKeys, setApiKeys] = useState([]); const fetchExistingKeys = async () => { const user = userFromStorage(); const Model = !!user ? Admin : System; const { apiKeys: foundKeys } = await Model.getApiKeys(); setApiKeys(foundKeys); setLoading(false); }; useEffect(() => { fetchExistingKeys(); }, []); const removeApiKey = (id) => { setApiKeys((prevKeys) => prevKeys.filter((apiKey) => apiKey.id !== id)); }; return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2"> <div className="items-center flex gap-x-4"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> {t("api.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary mt-2"> {t("api.description")} </p> <a href={paths.apiDocs()} target="_blank" rel="noreferrer" className="text-xs leading-[18px] font-base text-blue-300 light:text-blue-500 hover:underline mt-1" > {t("api.link")} &rarr; </a> </div> <div className="w-full justify-end flex"> <CTAButton onClick={openModal} className="mt-3 mr-0 mb-4 md:-mb-14 z-10" > <PlusCircle className="h-4 w-4" weight="bold" />{" "} {t("api.generate")} </CTAButton> </div> <div className="overflow-x-auto mt-6"> {loading ? ( <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" containerClassName="flex w-full" /> ) : ( <table className="w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0"> <thead className="text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b"> <tr> <th scope="col" className="px-6 py-3 rounded-tl-lg"> {t("api.table.key")} </th> <th scope="col" className="px-6 py-3"> {t("api.table.by")} </th> <th scope="col" className="px-6 py-3"> {t("api.table.created")} </th> <th scope="col" className="px-6 py-3 rounded-tr-lg"> {" "} </th> </tr> </thead> <tbody> {apiKeys.length === 0 ? ( <tr className="bg-transparent text-theme-text-secondary text-sm font-medium"> <td colSpan="4" className="px-6 py-4 text-center"> No API keys found </td> </tr> ) : ( apiKeys.map((apiKey) => ( <ApiKeyRow key={apiKey.id} apiKey={apiKey} removeApiKey={removeApiKey} /> )) )} </tbody> </table> )} </div> </div> <ModalWrapper isOpen={isOpen}> <NewApiKeyModal closeModal={closeModal} onSuccess={fetchExistingKeys} /> </ModalWrapper> </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/GeneralSettings/ApiKeys/ApiKeyRow/index.jsx
frontend/src/pages/GeneralSettings/ApiKeys/ApiKeyRow/index.jsx
import { useEffect, useState } from "react"; import Admin from "@/models/admin"; import showToast from "@/utils/toast"; import { Trash } from "@phosphor-icons/react"; import { userFromStorage } from "@/utils/request"; import System from "@/models/system"; export default function ApiKeyRow({ apiKey, removeApiKey }) { const [copied, setCopied] = useState(false); const handleDelete = async () => { if ( !window.confirm( `Are you sure you want to deactivate this api key?\nAfter you do this it will not longer be useable.\n\nThis action is irreversible.` ) ) return false; const user = userFromStorage(); const Model = !!user ? Admin : System; await Model.deleteApiKey(apiKey.id); showToast("API Key permanently deleted", "info"); removeApiKey(apiKey.id); }; const copyApiKey = () => { if (!apiKey) return false; window.navigator.clipboard.writeText(apiKey.secret); showToast("API Key copied to clipboard", "success"); setCopied(true); }; useEffect(() => { function resetStatus() { if (!copied) return false; setTimeout(() => { setCopied(false); }, 3000); } resetStatus(); }, [copied]); return ( <> <tr className="bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10"> <td scope="row" className="px-6 whitespace-nowrap"> {apiKey.secret} </td> <td className="px-6 text-left">{apiKey.createdBy?.username || "--"}</td> <td className="px-6">{apiKey.createdAt}</td> <td className="px-6 flex items-center gap-x-6 h-full mt-1"> <button onClick={copyApiKey} disabled={copied} className="text-xs font-medium text-blue-300 rounded-lg hover:text-white hover:light:text-blue-500 hover:text-opacity-60 hover:underline" > {copied ? "Copied" : "Copy API Key"} </button> <button onClick={handleDelete} className="text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10" > <Trash className="h-5 w-5" /> </button> </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/GeneralSettings/ApiKeys/NewApiKeyModal/index.jsx
frontend/src/pages/GeneralSettings/ApiKeys/NewApiKeyModal/index.jsx
import React, { useEffect, useState } from "react"; import { X, Copy, Check } from "@phosphor-icons/react"; import Admin from "@/models/admin"; import paths from "@/utils/paths"; import { userFromStorage } from "@/utils/request"; import System from "@/models/system"; import showToast from "@/utils/toast"; export default function NewApiKeyModal({ closeModal, onSuccess }) { const [apiKey, setApiKey] = useState(null); const [error, setError] = useState(null); const [copied, setCopied] = useState(false); const handleCreate = async (e) => { setError(null); e.preventDefault(); const user = userFromStorage(); const Model = !!user ? Admin : System; const { apiKey: newApiKey, error } = await Model.generateApiKey(); if (!!newApiKey) { setApiKey(newApiKey); onSuccess(); } setError(error); }; const copyApiKey = () => { if (!apiKey) return false; window.navigator.clipboard.writeText(apiKey.secret); setCopied(true); showToast("API key copied to clipboard", "success", { clear: true, }); }; useEffect(() => { function resetStatus() { if (!copied) return false; setTimeout(() => { setCopied(false); }, 3000); } resetStatus(); }, [copied]); return ( <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"> Create new API key </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> <div className="px-7 py-6"> <form onSubmit={handleCreate}> <div className="space-y-6 max-h-[60vh] overflow-y-auto pr-2"> {error && <p className="text-red-400 text-sm">Error: {error}</p>} {apiKey && ( <div className="relative"> <input type="text" defaultValue={`${apiKey.secret}`} disabled={true} className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg outline-none block w-full p-2.5 pr-10" /> <button type="button" onClick={copyApiKey} disabled={copied} className="absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded-md hover:bg-theme-modal-border transition-all duration-300" > {copied ? ( <Check size={20} className="text-green-400" weight="bold" /> ) : ( <Copy size={20} className="text-white" weight="bold" /> )} </button> </div> )} <p className="text-white text-opacity-60 text-xs md:text-sm"> Once created the API key can be used to programmatically access and configure this AnythingLLM instance. </p> <a href={paths.apiDocs()} target="_blank" rel="noreferrer" className="text-blue-400 hover:underline" > Read the API documentation &rarr; </a> </div> <div className="flex justify-end items-center mt-6 pt-6 border-t border-theme-modal-border"> {!apiKey ? ( <> <button onClick={closeModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm mr-2" > 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" > Create API Key </button> </> ) : ( <button onClick={closeModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > Close </button> )} </div> </form> </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/GeneralSettings/BrowserExtensionApiKey/index.jsx
frontend/src/pages/GeneralSettings/BrowserExtensionApiKey/index.jsx
import { useEffect, useState } from "react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import * as Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; import { PlusCircle } from "@phosphor-icons/react"; import BrowserExtensionApiKey from "@/models/browserExtensionApiKey"; import BrowserExtensionApiKeyRow from "./BrowserExtensionApiKeyRow"; import CTAButton from "@/components/lib/CTAButton"; import NewBrowserExtensionApiKeyModal from "./NewBrowserExtensionApiKeyModal"; import ModalWrapper from "@/components/ModalWrapper"; import { useModal } from "@/hooks/useModal"; import { fullApiUrl } from "@/utils/constants"; import { Tooltip } from "react-tooltip"; export default function BrowserExtensionApiKeys() { const [loading, setLoading] = useState(true); const [apiKeys, setApiKeys] = useState([]); const [error, setError] = useState(null); const { isOpen, openModal, closeModal } = useModal(); const [isMultiUser, setIsMultiUser] = useState(false); useEffect(() => { fetchExistingKeys(); }, []); const fetchExistingKeys = async () => { const result = await BrowserExtensionApiKey.getAll(); if (result.success) { setApiKeys(result.apiKeys); setIsMultiUser(result.apiKeys.some((key) => key.user !== null)); } else { setError(result.error || "Failed to fetch API keys"); } setLoading(false); }; const removeApiKey = (id) => { setApiKeys((prevKeys) => prevKeys.filter((apiKey) => apiKey.id !== id)); }; return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2"> <div className="items-center flex gap-x-4"> <p className="text-lg leading-6 font-bold text-theme-text-primary"> Browser Extension API Keys </p> </div> <p className="text-xs leading-[18px] font-base text-theme-text-secondary mt-2"> Manage API keys for browser extensions connecting to your AnythingLLM instance. </p> </div> <div className="w-full justify-end flex"> <CTAButton onClick={openModal} className="mt-3 mr-0 mb-4 md:-mb-14 z-10" > <PlusCircle className="h-4 w-4" weight="bold" /> Generate New API Key </CTAButton> </div> <div className="overflow-x-auto mt-6"> {loading ? ( <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" containerClassName="flex w-full" /> ) : error ? ( <div className="text-red-500 mt-6">Error: {error}</div> ) : ( <table className="w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0 md:mt-6 mt-0"> <thead className="text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b"> <tr> <th scope="col" className="px-6 py-2 rounded-tl-lg"> Extension Connection String </th> {isMultiUser && ( <th scope="col" className="px-6 py-2"> Created By </th> )} <th scope="col" className="px-6 py-2"> Created At </th> <th scope="col" className="px-6 py-2 rounded-tr-lg"> Actions </th> </tr> </thead> <tbody> {apiKeys.length === 0 ? ( <tr className="bg-transparent text-theme-text-secondary text-sm font-medium"> <td colSpan={isMultiUser ? "4" : "3"} className="px-6 py-4 text-center" > No API keys found </td> </tr> ) : ( apiKeys.map((apiKey) => ( <BrowserExtensionApiKeyRow key={apiKey.id} apiKey={apiKey} removeApiKey={removeApiKey} connectionString={`${fullApiUrl()}|${apiKey.key}`} isMultiUser={isMultiUser} /> )) )} </tbody> </table> )} </div> </div> </div> <ModalWrapper isOpen={isOpen}> <NewBrowserExtensionApiKeyModal closeModal={closeModal} onSuccess={fetchExistingKeys} isMultiUser={isMultiUser} /> </ModalWrapper> <Tooltip id="auto-connection" place="bottom" delayShow={300} className="allm-tooltip !allm-text-xs" /> <Tooltip id="copy-connection-text" 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/pages/GeneralSettings/BrowserExtensionApiKey/NewBrowserExtensionApiKeyModal/index.jsx
frontend/src/pages/GeneralSettings/BrowserExtensionApiKey/NewBrowserExtensionApiKeyModal/index.jsx
import React, { useEffect, useState } from "react"; import { X } from "@phosphor-icons/react"; import BrowserExtensionApiKey from "@/models/browserExtensionApiKey"; import { fullApiUrl, POPUP_BROWSER_EXTENSION_EVENT } from "@/utils/constants"; export default function NewBrowserExtensionApiKeyModal({ closeModal, onSuccess, isMultiUser, }) { const [apiKey, setApiKey] = useState(null); const [error, setError] = useState(null); const [copied, setCopied] = useState(false); const handleCreate = async (e) => { setError(null); e.preventDefault(); const { apiKey: newApiKey, error } = await BrowserExtensionApiKey.generateKey(); if (!!newApiKey) { const fullApiKey = `${fullApiUrl()}|${newApiKey}`; setApiKey(fullApiKey); onSuccess(); window.postMessage( { type: POPUP_BROWSER_EXTENSION_EVENT, apiKey: fullApiKey }, "*" ); } setError(error); }; const copyApiKey = () => { if (!apiKey) return false; window.navigator.clipboard.writeText(apiKey); setCopied(true); }; useEffect(() => { function resetStatus() { if (!copied) return false; setTimeout(() => { setCopied(false); }, 3000); } resetStatus(); }, [copied]); return ( <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"> New Browser Extension API Key </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> <div className="px-7 py-6"> <form onSubmit={handleCreate}> <div className="space-y-6 max-h-[60vh] overflow-y-auto pr-2"> {error && <p className="text-red-400 text-sm">Error: {error}</p>} {apiKey && ( <input type="text" defaultValue={apiKey} disabled={true} className="border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg block w-full p-2.5" /> )} {isMultiUser && ( <p className="text-yellow-300 light:text-orange-500 text-xs md:text-sm font-semibold"> Warning: You are in multi-user mode, this API key will allow access to all workspaces associated with your account. Please share it cautiously. </p> )} <p className="text-white text-opacity-60 text-xs md:text-sm"> After clicking "Create API Key", AnythingLLM will attempt to connect to your browser extension automatically. </p> <p className="text-white text-opacity-60 text-xs md:text-sm"> If you see "Connected to AnythingLLM" in the extension, the connection was successful. If not, please copy the connection string and paste it into the extension manually. </p> </div> <div className="flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border"> {!apiKey ? ( <> <button onClick={closeModal} type="button" className="transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm" > 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" > Create API Key </button> </> ) : ( <button onClick={copyApiKey} type="button" disabled={copied} className="w-full transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm cursor-pointer" > {copied ? "API Key Copied!" : "Copy API Key"} </button> )} </div> </form> </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/GeneralSettings/BrowserExtensionApiKey/BrowserExtensionApiKeyRow/index.jsx
frontend/src/pages/GeneralSettings/BrowserExtensionApiKey/BrowserExtensionApiKeyRow/index.jsx
import { useRef, useState } from "react"; import BrowserExtensionApiKey from "@/models/browserExtensionApiKey"; import showToast from "@/utils/toast"; import { Trash, Copy, Check, Plug } from "@phosphor-icons/react"; import { POPUP_BROWSER_EXTENSION_EVENT } from "@/utils/constants"; export default function BrowserExtensionApiKeyRow({ apiKey, removeApiKey, connectionString, isMultiUser, }) { const rowRef = useRef(null); const [copied, setCopied] = useState(false); const handleRevoke = async () => { if ( !window.confirm( `Are you sure you want to revoke this browser extension API key?\nAfter you do this it will no longer be useable.\n\nThis action is irreversible.` ) ) return false; const result = await BrowserExtensionApiKey.revoke(apiKey.id); if (result.success) { removeApiKey(apiKey.id); showToast("Browser Extension API Key permanently revoked", "info", { clear: true, }); } else { showToast("Failed to revoke API Key", "error", { clear: true, }); } }; const handleCopy = () => { navigator.clipboard.writeText(connectionString); showToast("Connection string copied to clipboard", "success", { clear: true, }); setCopied(true); setTimeout(() => setCopied(false), 2000); }; const handleConnect = () => { // Sending a message to Chrome extension to pop up the extension window // This will open the extension window and attempt to connect with the API key window.postMessage( { type: POPUP_BROWSER_EXTENSION_EVENT, apiKey: connectionString }, "*" ); showToast("Attempting to connect to browser extension...", "info", { clear: true, }); }; return ( <tr ref={rowRef} className="bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10" > <td scope="row" className="px-6 py-2 whitespace-nowrap"> <div className="flex items-center"> <span className="mr-2 font-mono">{connectionString}</span> <div className="flex items-center space-x-2"> <button onClick={handleCopy} data-tooltip-id="copy-connection-text" data-tooltip-content="Copy connection string" className="border-none text-theme-text-primary hover:text-theme-text-secondary transition-colors duration-200 p-1 rounded" > {copied ? ( <Check className="h-4 w-4 text-green-500" /> ) : ( <Copy className="h-4 w-4" /> )} </button> <button onClick={handleConnect} data-tooltip-id="auto-connection" data-tooltip-content="Automatically connect to extension" className="border-none text-theme-text-primary hover:text-theme-text-secondary transition-colors duration-200 p-1 rounded" > <Plug className="h-4 w-4" /> </button> </div> </div> </td> {isMultiUser && ( <td className="px-6 py-2"> {apiKey.user ? apiKey.user.username : "N/A"} </td> )} <td className="px-6 py-2"> {new Date(apiKey.createdAt).toLocaleString()} </td> <td className="px-6 py-2"> <button onClick={handleRevoke} className="text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10" > <Trash className="h-4 w-4" /> </button> </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/GeneralSettings/Security/index.jsx
frontend/src/pages/GeneralSettings/Security/index.jsx
import { useEffect, useState } from "react"; import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import showToast from "@/utils/toast"; import System from "@/models/system"; import paths from "@/utils/paths"; import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "@/utils/constants"; import PreLoader from "@/components/Preloader"; import CTAButton from "@/components/lib/CTAButton"; import { useTranslation } from "react-i18next"; export default function GeneralSecurity() { const { t } = useTranslation(); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:pt-6"> <p className="text-lg leading-6 font-bold text-theme-text-primary md-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10 py-4"> {t("security.title")} </p> </div> <MultiUserMode /> <PasswordProtection /> </div> </div> ); } function MultiUserMode() { const [saving, setSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); const [useMultiUserMode, setUseMultiUserMode] = useState(false); const [multiUserModeEnabled, setMultiUserModeEnabled] = useState(false); const [loading, setLoading] = useState(true); const { t } = useTranslation(); const handleSubmit = async (e) => { e.preventDefault(); setSaving(true); setHasChanges(false); if (useMultiUserMode) { const form = new FormData(e.target); const data = { username: form.get("username"), password: form.get("password"), }; const { success, error } = await System.setupMultiUser(data); if (success) { showToast("Multi-User mode enabled successfully.", "success"); setSaving(false); setTimeout(() => { window.localStorage.removeItem(AUTH_USER); window.localStorage.removeItem(AUTH_TOKEN); window.localStorage.removeItem(AUTH_TIMESTAMP); window.location = paths.settings.users(); }, 2_000); return; } showToast(`Failed to enable Multi-User mode: ${error}`, "error"); setSaving(false); return; } }; useEffect(() => { async function fetchIsMultiUserMode() { setLoading(true); const multiUserModeEnabled = await System.isMultiUserMode(); setMultiUserModeEnabled(multiUserModeEnabled); setLoading(false); } fetchIsMultiUserMode(); }, []); if (loading) { return ( <div className="h-1/2 transition-all duration-500 relative md:ml-[2px] md:mr-[8px] md:my-[16px] md:rounded-[26px] p-[18px] h-full overflow-y-scroll"> <div className="w-full h-full flex justify-center items-center"> <PreLoader /> </div> </div> ); } return ( <form onSubmit={handleSubmit} onChange={() => setHasChanges(true)} className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px]" > <div className="w-full flex flex-col gap-y-1 w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="w-full flex flex-col gap-y-1"> <div className="items-center flex gap-x-4"> <p className="text-base font-bold text-white mt-6"> {t("security.multiuser.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> {t("security.multiuser.description")} </p> </div> {hasChanges && ( <div className="flex justify-end"> <CTAButton onClick={() => handleSubmit()} className="mt-3 mr-0 -mb-20 z-10" > {saving ? t("common.saving") : t("common.save")} </CTAButton> </div> )} <div className="relative w-full max-h-full"> <div className="relative rounded-lg"> <div className="flex items-start justify-between px-6 py-4"></div> <div className="space-y-6 flex h-full w-full"> <div className="w-full flex flex-col gap-y-4"> <div className=""> <label className="text-white text-sm font-semibold block mb-3"> {multiUserModeEnabled ? t("security.multiuser.enable.is-enable") : t("security.multiuser.enable.enable")} </label> <label className="relative inline-flex cursor-pointer items-center"> <input type="checkbox" onClick={() => setUseMultiUserMode(!useMultiUserMode)} defaultChecked={useMultiUserMode} className="peer sr-only pointer-events-none" /> <div hidden={multiUserModeEnabled} className="peer-disabled:opacity-50 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" /> </label> </div> {useMultiUserMode && ( <div className="w-full flex flex-col gap-y-2 my-5"> <div className="w-80"> <label htmlFor="username" className="text-white text-sm font-semibold block mb-3" > {t("security.multiuser.enable.username")} </label> <input name="username" type="text" 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 placeholder:text-theme-settings-input-placeholder focus:ring-blue-500" placeholder="Your admin username" minLength={2} required={true} autoComplete="off" disabled={multiUserModeEnabled} defaultValue={multiUserModeEnabled ? "********" : ""} /> </div> <div className="mt-4 w-80"> <label htmlFor="password" className="text-white text-sm font-semibold block mb-3" > {t("security.multiuser.enable.password")} </label> <input name="password" type="text" 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 placeholder:text-theme-settings-input-placeholder focus:ring-blue-500" placeholder="Your admin password" minLength={8} required={true} autoComplete="off" defaultValue={multiUserModeEnabled ? "********" : ""} /> </div> </div> )} </div> </div> <div className="flex items-center justify-between space-x-14"> <p className="text-white text-opacity-80 text-xs rounded-lg w-96"> {t("security.multiuser.enable.description")} </p> </div> </div> </div> </div> </form> ); } const PW_REGEX = new RegExp(/^[a-zA-Z0-9_\-!@$%^&*();]+$/); function PasswordProtection() { const [saving, setSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); const [multiUserModeEnabled, setMultiUserModeEnabled] = useState(false); const [usePassword, setUsePassword] = useState(false); const [loading, setLoading] = useState(true); const { t } = useTranslation(); const handleSubmit = async (e) => { e.preventDefault(); if (multiUserModeEnabled) return false; const form = new FormData(e.target); if (!PW_REGEX.test(form.get("password"))) { showToast( `Your password has restricted characters in it. Allowed symbols are _,-,!,@,$,%,^,&,*,(,),;`, "error" ); setSaving(false); return; } setSaving(true); setHasChanges(false); const data = { usePassword, newPassword: form.get("password"), }; const { success, error } = await System.updateSystemPassword(data); if (success) { showToast("Your page will refresh in a few seconds.", "success"); setSaving(false); setTimeout(() => { window.localStorage.removeItem(AUTH_USER); window.localStorage.removeItem(AUTH_TOKEN); window.localStorage.removeItem(AUTH_TIMESTAMP); window.location.reload(); }, 3_000); return; } else { showToast(`Failed to update password: ${error}`, "error"); setSaving(false); } }; useEffect(() => { async function fetchIsMultiUserMode() { setLoading(true); const multiUserModeEnabled = await System.isMultiUserMode(); const settings = await System.keys(); setMultiUserModeEnabled(multiUserModeEnabled); setUsePassword(settings?.RequiresAuth); setLoading(false); } fetchIsMultiUserMode(); }, []); if (loading) { return ( <div className="h-1/2 transition-all duration-500 relative md:ml-[2px] md:mr-[8px] md:my-[16px] md:rounded-[26px] p-[18px] h-full overflow-y-scroll"> <div className="w-full h-full flex justify-center items-center"> <PreLoader /> </div> </div> ); } if (multiUserModeEnabled) return null; return ( <form onSubmit={handleSubmit} onChange={() => setHasChanges(true)} className="flex flex-col w-full px-1 md:pl-6 md:pr-[50px]" > <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="w-full flex flex-col gap-y-1"> <div className="items-center flex gap-x-4"> <p className="text-base font-bold text-white mt-6"> {t("security.password.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> {t("security.password.description")} </p> </div> {hasChanges && ( <div className="flex justify-end"> <CTAButton onClick={() => handleSubmit()} className="mt-3 mr-0 -mb-20 z-10" > {saving ? t("common.saving") : t("common.save")} </CTAButton> </div> )} <div className="relative w-full max-h-full"> <div className="relative rounded-lg"> <div className="flex items-start justify-between px-6 py-4"></div> <div className="space-y-6 flex h-full w-full"> <div className="w-full flex flex-col gap-y-4"> <div className=""> <label className="text-white text-sm font-semibold block mb-3"> {t("security.password.title")} </label> <label className="relative inline-flex cursor-pointer items-center"> <input type="checkbox" onClick={() => setUsePassword(!usePassword)} defaultChecked={usePassword} className="peer sr-only pointer-events-none" /> <div className="peer-disabled:opacity-50 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" /> </label> </div> {usePassword && ( <div className="w-full flex flex-col gap-y-2 my-5"> <div className="mt-4 w-80"> <label htmlFor="password" className="text-white text-sm font-semibold block mb-3" > {t("security.password.password-label")} </label> <input name="password" type="text" 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 placeholder:text-theme-settings-input-placeholder" placeholder="Your Instance Password" minLength={8} required={true} autoComplete="off" defaultValue={usePassword ? "********" : ""} /> </div> </div> )} </div> </div> <div className="flex items-center justify-between space-x-14"> <p className="text-white text-opacity-80 light:text-theme-text text-xs rounded-lg w-96"> {t("security.password.description")} </p> </div> </div> </div> </div> </form> ); }
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/GeneralSettings/Settings/Branding/index.jsx
frontend/src/pages/GeneralSettings/Settings/Branding/index.jsx
import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import FooterCustomization from "../components/FooterCustomization"; import SupportEmail from "../components/SupportEmail"; import CustomLogo from "../components/CustomLogo"; import CustomMessages from "../components/CustomMessages"; import { useTranslation } from "react-i18next"; import CustomAppName from "../components/CustomAppName"; import CustomSiteSettings from "../components/CustomSiteSettings"; export default function BrandingSettings() { const { t } = useTranslation(); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="items-center"> <p className="text-lg leading-6 font-bold text-white"> {t("customization.branding.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> {t("customization.branding.description")} </p> </div> <CustomAppName /> <CustomLogo /> <CustomMessages /> <FooterCustomization /> <SupportEmail /> <CustomSiteSettings /> </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/GeneralSettings/Settings/Chat/index.jsx
frontend/src/pages/GeneralSettings/Settings/Chat/index.jsx
import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import { useTranslation } from "react-i18next"; import AutoSubmit from "../components/AutoSubmit"; import AutoSpeak from "../components/AutoSpeak"; import SpellCheck from "../components/SpellCheck"; import ShowScrollbar from "../components/ShowScrollbar"; import ChatRenderHTML from "../components/ChatRenderHTML"; export default function ChatSettings() { const { t } = useTranslation(); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="items-center"> <p className="text-lg leading-6 font-bold text-white"> {t("customization.chat.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> {t("customization.chat.description")} </p> </div> <AutoSubmit /> <AutoSpeak /> <SpellCheck /> <ShowScrollbar /> <ChatRenderHTML /> </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/GeneralSettings/Settings/Interface/index.jsx
frontend/src/pages/GeneralSettings/Settings/Interface/index.jsx
import Sidebar from "@/components/SettingsSidebar"; import { isMobile } from "react-device-detect"; import { useTranslation } from "react-i18next"; import LanguagePreference from "../components/LanguagePreference"; import ThemePreference from "../components/ThemePreference"; import { MessageDirection } from "../components/MessageDirection"; export default function InterfaceSettings() { const { t } = useTranslation(); return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> <Sidebar /> <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 w-full h-full overflow-y-scroll p-4 md:p-0" > <div className="flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16"> <div className="w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10"> <div className="items-center"> <p className="text-lg leading-6 font-bold text-white"> {t("customization.interface.title")} </p> </div> <p className="text-xs leading-[18px] font-base text-white text-opacity-60"> {t("customization.interface.description")} </p> </div> <ThemePreference /> <LanguagePreference /> <MessageDirection /> </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/GeneralSettings/Settings/components/CustomSiteSettings/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/CustomSiteSettings/index.jsx
import { useEffect, useState } from "react"; import Admin from "@/models/admin"; import showToast from "@/utils/toast"; import { useTranslation } from "react-i18next"; export default function CustomSiteSettings() { const { t } = useTranslation(); const [hasChanges, setHasChanges] = useState(false); const [settings, setSettings] = useState({ title: null, faviconUrl: null, }); useEffect(() => { Admin.systemPreferences().then(({ settings }) => { setSettings({ title: settings?.meta_page_title, faviconUrl: settings?.meta_page_favicon, }); }); }, []); async function handleSiteSettingUpdate(e) { e.preventDefault(); await Admin.updateSystemPreferences({ meta_page_title: settings.title ?? null, meta_page_favicon: settings.faviconUrl ?? null, }); showToast( "Site preferences updated! They will reflect on page reload.", "success", { clear: true } ); setHasChanges(false); return; } return ( <form className="flex flex-col gap-y-0.5 my-4 border-t border-white border-opacity-20 light:border-black/20 pt-6" onChange={() => setHasChanges(true)} onSubmit={handleSiteSettingUpdate} > <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.browser-appearance.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.browser-appearance.description")} </p> <div className="w-fit"> <p className="text-sm leading-6 font-medium text-white mt-2"> {t("customization.items.browser-appearance.tab.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.browser-appearance.tab.description")} </p> <div className="flex items-center gap-x-4"> <input name="meta_page_title" type="text" className="border-none bg-theme-settings-input-bg mt-2 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 py-2 px-4" placeholder="AnythingLLM | Your personal LLM trained on anything" autoComplete="off" onChange={(e) => { setSettings((prev) => { return { ...prev, title: e.target.value }; }); }} value={ settings.title ?? "AnythingLLM | Your personal LLM trained on anything" } /> </div> </div> <div className="w-fit"> <p className="text-sm leading-6 font-medium text-white mt-2"> {t("customization.items.browser-appearance.favicon.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.browser-appearance.favicon.description")} </p> <div className="flex items-center gap-x-2"> <img src={settings.faviconUrl ?? "/favicon.png"} onError={(e) => (e.target.src = "/favicon.png")} className="h-10 w-10 rounded-lg mt-2" alt="Site favicon" /> <input name="meta_page_favicon" type="url" className="border-none bg-theme-settings-input-bg mt-2 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 py-2 px-4" placeholder="url to your image" onChange={(e) => { setSettings((prev) => { return { ...prev, faviconUrl: e.target.value }; }); }} autoComplete="off" value={settings.faviconUrl ?? ""} /> </div> </div> {hasChanges && ( <button type="submit" className="transition-all mt-2 w-fit 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" > Save </button> )} </form> ); }
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/GeneralSettings/Settings/components/AutoSpeak/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/AutoSpeak/index.jsx
import React, { useState, useEffect } from "react"; import Appearance from "@/models/appearance"; import { useTranslation } from "react-i18next"; export default function AutoSpeak() { const [saving, setSaving] = useState(false); const [autoPlayAssistantTtsResponse, setAutoPlayAssistantTtsResponse] = useState(false); const { t } = useTranslation(); const handleChange = async (e) => { const newValue = e.target.checked; setAutoPlayAssistantTtsResponse(newValue); setSaving(true); try { Appearance.updateSettings({ autoPlayAssistantTtsResponse: newValue }); } catch (error) { console.error("Failed to update appearance settings:", error); setAutoPlayAssistantTtsResponse(!newValue); } setSaving(false); }; useEffect(() => { function fetchSettings() { const settings = Appearance.getSettings(); setAutoPlayAssistantTtsResponse( settings.autoPlayAssistantTtsResponse ?? false ); } fetchSettings(); }, []); return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.chat.auto_speak.title")} </p> <p className="text-xs text-white/60"> {t("customization.chat.auto_speak.description")} </p> <div className="flex items-center gap-x-4"> <label className="relative inline-flex cursor-pointer items-center"> <input id="auto_speak" type="checkbox" name="auto_speak" value="yes" checked={autoPlayAssistantTtsResponse} onChange={handleChange} disabled={saving} 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> </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/GeneralSettings/Settings/components/SpellCheck/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/SpellCheck/index.jsx
import React, { useState, useEffect } from "react"; import Appearance from "@/models/appearance"; import { useTranslation } from "react-i18next"; export default function SpellCheck() { const { t } = useTranslation(); const [saving, setSaving] = useState(false); const [enableSpellCheck, setEnableSpellCheck] = useState( Appearance.get("enableSpellCheck") ); const handleChange = async (e) => { const newValue = e.target.checked; setEnableSpellCheck(newValue); setSaving(true); try { Appearance.set("enableSpellCheck", newValue); } catch (error) { console.error("Failed to update appearance settings:", error); setEnableSpellCheck(!newValue); } setSaving(false); }; return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.chat.spellcheck.title")} </p> <p className="text-xs text-white/60"> {t("customization.chat.spellcheck.description")} </p> <div className="flex items-center gap-x-4"> <label className="relative inline-flex cursor-pointer items-center"> <input id="spellcheck" type="checkbox" name="spellcheck" value="yes" checked={enableSpellCheck} onChange={handleChange} disabled={saving} 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> </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/GeneralSettings/Settings/components/CustomAppName/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/CustomAppName/index.jsx
import Admin from "@/models/admin"; import System from "@/models/system"; import showToast from "@/utils/toast"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; export default function CustomAppName() { const { t } = useTranslation(); const [loading, setLoading] = useState(true); const [hasChanges, setHasChanges] = useState(false); const [customAppName, setCustomAppName] = useState(""); const [originalAppName, setOriginalAppName] = useState(""); const [canCustomize, setCanCustomize] = useState(false); useEffect(() => { const fetchInitialParams = async () => { const settings = await System.keys(); if (!settings?.MultiUserMode && !settings?.RequiresAuth) { setCanCustomize(false); return false; } const { appName } = await System.fetchCustomAppName(); setCustomAppName(appName || ""); setOriginalAppName(appName || ""); setCanCustomize(true); setLoading(false); }; fetchInitialParams(); }, []); const updateCustomAppName = async (e, newValue = null) => { e.preventDefault(); let custom_app_name = newValue; if (newValue === null) { const form = new FormData(e.target); custom_app_name = form.get("customAppName"); } const { success, error } = await Admin.updateSystemPreferences({ custom_app_name, }); if (!success) { showToast(`Failed to update custom app name: ${error}`, "error"); return; } else { showToast("Successfully updated custom app name.", "success"); window.localStorage.removeItem(System.cacheKeys.customAppName); setCustomAppName(custom_app_name); setOriginalAppName(custom_app_name); setHasChanges(false); } }; const handleChange = (e) => { setCustomAppName(e.target.value); setHasChanges(true); }; if (!canCustomize || loading) return null; return ( <form className="flex flex-col gap-y-0.5 mt-4" onSubmit={updateCustomAppName} > <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.app-name.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.app-name.description")} </p> <div className="flex items-center gap-x-4"> <input name="customAppName" type="text" className="border-none bg-theme-settings-input-bg mt-2 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 py-2 px-4" placeholder="AnythingLLM" required={true} autoComplete="off" onChange={handleChange} value={customAppName} /> {originalAppName !== "" && ( <button type="button" onClick={(e) => updateCustomAppName(e, "")} className="text-white text-base font-medium hover:text-opacity-60" > Clear </button> )} </div> {hasChanges && ( <button type="submit" className="transition-all mt-2 w-fit 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" > Save </button> )} </form> ); }
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/GeneralSettings/Settings/components/LanguagePreference/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/LanguagePreference/index.jsx
import { useLanguageOptions } from "@/hooks/useLanguageOptions"; import { useTranslation } from "react-i18next"; export default function LanguagePreference() { const { t } = useTranslation(); const { currentLanguage, supportedLanguages, getLanguageName, changeLanguage, } = useLanguageOptions(); return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.display-language.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.display-language.description")} </p> <div className="flex items-center gap-x-4"> <select name="userLang" className="border-none bg-theme-settings-input-bg mt-2 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 py-2 px-4" defaultValue={currentLanguage || "en"} onChange={(e) => changeLanguage(e.target.value)} > {supportedLanguages.map((lang) => { return ( <option key={lang} value={lang}> {getLanguageName(lang)} </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/pages/GeneralSettings/Settings/components/ChatRenderHTML/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/ChatRenderHTML/index.jsx
import React, { useState, useEffect } from "react"; import Appearance from "@/models/appearance"; import { useTranslation } from "react-i18next"; export default function ChatRenderHTML() { const { t } = useTranslation(); const [saving, setSaving] = useState(false); const [renderHTML, setRenderHTML] = useState(false); const handleChange = async (e) => { const newValue = e.target.checked; setRenderHTML(newValue); setSaving(true); try { Appearance.updateSettings({ renderHTML: newValue }); } catch (error) { console.error("Failed to update appearance settings:", error); setRenderHTML(!newValue); } setSaving(false); }; useEffect(() => { function fetchSettings() { const settings = Appearance.getSettings(); setRenderHTML(settings.renderHTML); } fetchSettings(); }, []); return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.render-html.title")} </p> <p className="text-xs text-white/60 w-1/2 whitespace-pre-line"> {t("customization.items.render-html.description")} </p> <div className="flex items-center gap-x-4 pt-1"> <label className="relative inline-flex cursor-pointer items-center"> <input id="render_html" type="checkbox" name="render_html" value="yes" checked={renderHTML} onChange={handleChange} disabled={saving} 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> </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/GeneralSettings/Settings/components/FooterCustomization/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/FooterCustomization/index.jsx
import React, { useState, useEffect } from "react"; import showToast from "@/utils/toast"; import { safeJsonParse } from "@/utils/request"; import NewIconForm from "./NewIconForm"; import Admin from "@/models/admin"; import System from "@/models/system"; import { useTranslation } from "react-i18next"; export default function FooterCustomization() { const [footerIcons, setFooterIcons] = useState(Array(3).fill(null)); const { t } = useTranslation(); useEffect(() => { async function fetchFooterIcons() { const settings = (await Admin.systemPreferences())?.settings; if (settings && settings.footer_data) { const parsedIcons = safeJsonParse(settings.footer_data, []); setFooterIcons((prevIcons) => { const updatedIcons = [...prevIcons]; parsedIcons.forEach((icon, index) => { updatedIcons[index] = icon; }); return updatedIcons; }); } } fetchFooterIcons(); }, []); const updateFooterIcons = async (updatedIcons) => { const { success, error } = await Admin.updateSystemPreferences({ footer_data: JSON.stringify(updatedIcons.filter((icon) => icon !== null)), }); if (!success) { showToast(`Failed to update footer icons - ${error}`, "error", { clear: true, }); return; } window.localStorage.removeItem(System.cacheKeys.footerIcons); setFooterIcons(updatedIcons); showToast("Successfully updated footer icons.", "success", { clear: true }); }; const handleRemoveIcon = (index) => { const updatedIcons = [...footerIcons]; updatedIcons[index] = null; updateFooterIcons(updatedIcons); }; return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.sidebar-footer.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.sidebar-footer.description")} </p> <div className="mt-2 flex gap-x-3 font-medium text-white text-sm"> <div>{t("customization.items.sidebar-footer.icon")}</div> <div>{t("customization.items.sidebar-footer.link")}</div> </div> <div className="mt-2 flex flex-col gap-y-[10px]"> {footerIcons.map((icon, index) => ( <NewIconForm key={index} icon={icon?.icon} url={icon?.url} onSave={(newIcon, newUrl) => { const updatedIcons = [...footerIcons]; updatedIcons[index] = { icon: newIcon, url: newUrl }; updateFooterIcons(updatedIcons); }} onRemove={() => handleRemoveIcon(index)} /> ))} </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/GeneralSettings/Settings/components/FooterCustomization/NewIconForm/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/FooterCustomization/NewIconForm/index.jsx
import { ICON_COMPONENTS } from "@/components/Footer"; import React, { useEffect, useRef, useState } from "react"; import { Plus, X } from "@phosphor-icons/react"; export default function NewIconForm({ icon, url, onSave, onRemove }) { const [selectedIcon, setSelectedIcon] = useState(icon || "Plus"); const [selectedUrl, setSelectedUrl] = useState(url || ""); const [isDropdownOpen, setIsDropdownOpen] = useState(false); const [isEdited, setIsEdited] = useState(false); const dropdownRef = useRef(null); useEffect(() => { setSelectedIcon(icon || "Plus"); setSelectedUrl(url || ""); setIsEdited(false); }, [icon, url]); useEffect(() => { function handleClickOutside(event) { if (dropdownRef.current && !dropdownRef.current.contains(event.target)) { setIsDropdownOpen(false); } } document.addEventListener("mousedown", handleClickOutside); return () => document.removeEventListener("mousedown", handleClickOutside); }, [dropdownRef]); const handleSubmit = (e) => { e.preventDefault(); if (selectedIcon !== "Plus" && selectedUrl) { onSave(selectedIcon, selectedUrl); setIsEdited(false); } }; const handleRemove = () => { onRemove(); setSelectedIcon("Plus"); setSelectedUrl(""); setIsEdited(false); }; const handleIconChange = (iconName) => { setSelectedIcon(iconName); setIsDropdownOpen(false); setIsEdited(true); }; const handleUrlChange = (e) => { setSelectedUrl(e.target.value); setIsEdited(true); }; return ( <form onSubmit={handleSubmit} className="flex items-center gap-x-1.5"> <div className="relative" ref={dropdownRef}> <div className="h-[34px] w-[34px] bg-theme-settings-input-bg rounded-full flex items-center justify-center cursor-pointer hover:outline-primary-button hover:outline" onClick={() => setIsDropdownOpen(!isDropdownOpen)} > {React.createElement(ICON_COMPONENTS[selectedIcon] || Plus, { className: "h-5 w-5", weight: selectedIcon === "Plus" ? "bold" : "fill", color: "var(--theme-sidebar-footer-icon-fill)", })} </div> {isDropdownOpen && ( <div className="absolute z-10 grid grid-cols-4 bg-theme-settings-input-bg mt-2 rounded-md w-[150px] h-[78px] overflow-y-auto border border-white/20 shadow-lg"> {Object.keys(ICON_COMPONENTS).map((iconName) => ( <button key={iconName} type="button" className="flex justify-center items-center border border-transparent hover:bg-theme-sidebar-footer-icon-hover hover:border-slate-100 light:hover:border-black/80 rounded-full p-2" onClick={() => handleIconChange(iconName)} > {React.createElement(ICON_COMPONENTS[iconName], { className: "h-5 w-5", weight: "fill", color: "var(--theme-sidebar-footer-icon-fill)", })} </button> ))} </div> )} </div> <input type="url" value={selectedUrl} onChange={handleUrlChange} placeholder="https://example.com" className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-md p-2.5 w-[300px] h-[32px] focus:outline-primary-button active:outline-primary-button outline-none" required /> {selectedIcon !== "Plus" && ( <> {isEdited ? ( <button type="submit" className="text-sky-400 px-2 py-2 rounded-md text-sm font-bold hover:text-sky-500" > Save </button> ) : ( <button type="button" onClick={handleRemove} className="hover:text-red-500 text-white/80 px-2 py-2 rounded-md text-sm font-bold" > <X size={20} /> </button> )} </> )} </form> ); }
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/GeneralSettings/Settings/components/ShowScrollbar/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/ShowScrollbar/index.jsx
import React, { useState, useEffect } from "react"; import Appearance from "@/models/appearance"; import { useTranslation } from "react-i18next"; export default function ShowScrollbar() { const { t } = useTranslation(); const [saving, setSaving] = useState(false); const [showScrollbar, setShowScrollbar] = useState(false); const handleChange = async (e) => { const newValue = e.target.checked; setShowScrollbar(newValue); setSaving(true); try { Appearance.updateSettings({ showScrollbar: newValue }); } catch (error) { console.error("Failed to update appearance settings:", error); setShowScrollbar(!newValue); } setSaving(false); }; useEffect(() => { function fetchSettings() { const settings = Appearance.getSettings(); setShowScrollbar(settings.showScrollbar); } fetchSettings(); }, []); return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.show-scrollbar.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.show-scrollbar.description")} </p> <div className="flex items-center gap-x-4"> <label className="relative inline-flex cursor-pointer items-center"> <input id="show_scrollbar" type="checkbox" name="show_scrollbar" value="yes" checked={showScrollbar} onChange={handleChange} disabled={saving} 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> </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/GeneralSettings/Settings/components/CustomLogo/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/CustomLogo/index.jsx
import useLogo from "@/hooks/useLogo"; import System from "@/models/system"; import showToast from "@/utils/toast"; import { useEffect, useRef, useState } from "react"; import { Plus } from "@phosphor-icons/react"; import { useTranslation } from "react-i18next"; export default function CustomLogo() { const { t } = useTranslation(); const { logo: _initLogo, setLogo: _setLogo } = useLogo(); const [logo, setLogo] = useState(""); const [isDefaultLogo, setIsDefaultLogo] = useState(true); const fileInputRef = useRef(null); useEffect(() => { async function logoInit() { setLogo(_initLogo || ""); const _isDefaultLogo = await System.isDefaultLogo(); setIsDefaultLogo(_isDefaultLogo); } logoInit(); }, [_initLogo]); const handleFileUpload = async (event) => { const file = event.target.files[0]; if (!file) return false; const objectURL = URL.createObjectURL(file); setLogo(objectURL); const formData = new FormData(); formData.append("logo", file); const { success, error } = await System.uploadLogo(formData); if (!success) { showToast(`Failed to upload logo: ${error}`, "error"); setLogo(_initLogo); return; } const { logoURL } = await System.fetchLogo(); _setLogo(logoURL); showToast("Image uploaded successfully.", "success"); setIsDefaultLogo(false); }; const handleRemoveLogo = async () => { setLogo(""); setIsDefaultLogo(true); const { success, error } = await System.removeCustomLogo(); if (!success) { console.error("Failed to remove logo:", error); showToast(`Failed to remove logo: ${error}`, "error"); const { logoURL } = await System.fetchLogo(); setLogo(logoURL); setIsDefaultLogo(false); return; } const { logoURL } = await System.fetchLogo(); _setLogo(logoURL); showToast("Image successfully removed.", "success"); }; const triggerFileInputClick = () => { fileInputRef.current?.click(); }; return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.logo.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.logo.description")} </p> {isDefaultLogo ? ( <div className="flex md:flex-row flex-col items-center"> <div className="flex flex-row gap-x-8"> <label className="mt-3 transition-all duration-300 hover:opacity-60" hidden={!isDefaultLogo} > <input id="logo-upload" type="file" accept="image/*" className="hidden" onChange={handleFileUpload} /> <div className="w-80 py-4 bg-theme-settings-input-bg rounded-2xl border-2 border-dashed border-theme-text-secondary border-opacity-60 justify-center items-center inline-flex cursor-pointer" htmlFor="logo-upload" > <div className="flex flex-col items-center justify-center"> <div className="rounded-full bg-white/40"> <Plus className="w-6 h-6 text-black/80 m-2" /> </div> <div className="text-theme-text-primary text-opacity-80 text-sm font-semibold py-1"> {t("customization.items.logo.add")} </div> <div className="text-theme-text-secondary text-opacity-60 text-xs font-medium py-1"> {t("customization.items.logo.recommended")} </div> </div> </div> </label> </div> </div> ) : ( <div className="flex md:flex-row flex-col items-center relative"> <div className="group w-80 h-[130px] mt-3 overflow-hidden"> <img src={logo} alt="Uploaded Logo" className="w-full h-full object-cover border-2 border-theme-text-secondary border-opacity-60 p-1 rounded-2xl" /> <div className="absolute w-80 top-0 left-0 right-0 bottom-0 flex flex-col gap-y-3 justify-center items-center rounded-2xl mt-3 bg-black bg-opacity-80 opacity-0 group-hover:opacity-100 transition-opacity duration-300 ease-in-out border-2 border-transparent hover:border-white"> <button onClick={triggerFileInputClick} className="text-[#FFFFFF] text-base font-medium hover:text-opacity-60 mx-2" > {t("customization.items.logo.replace")} </button> <input id="logo-upload" type="file" accept="image/*" className="hidden" onChange={handleFileUpload} ref={fileInputRef} /> <button onClick={handleRemoveLogo} className="text-[#FFFFFF] text-base font-medium hover:text-opacity-60 mx-2" > {t("customization.items.logo.remove")} </button> </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/pages/GeneralSettings/Settings/components/ThemePreference/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/ThemePreference/index.jsx
import { useTheme } from "@/hooks/useTheme"; import { useTranslation } from "react-i18next"; export default function ThemePreference() { const { t } = useTranslation(); const { theme, setTheme, availableThemes } = useTheme(); return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.theme.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.theme.description")} </p> <div className="flex items-center gap-x-4"> <select value={theme} onChange={(e) => setTheme(e.target.value)} className="border-none bg-theme-settings-input-bg mt-2 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 py-2 px-4" > {Object.entries(availableThemes).map(([key, value]) => ( <option key={key} value={key}> {value} </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/pages/GeneralSettings/Settings/components/SupportEmail/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/SupportEmail/index.jsx
import useUser from "@/hooks/useUser"; import Admin from "@/models/admin"; import System from "@/models/system"; import showToast from "@/utils/toast"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; export default function SupportEmail() { const { user } = useUser(); const [loading, setLoading] = useState(true); const [hasChanges, setHasChanges] = useState(false); const [supportEmail, setSupportEmail] = useState(""); const [originalEmail, setOriginalEmail] = useState(""); const { t } = useTranslation(); useEffect(() => { const fetchSupportEmail = async () => { const supportEmail = await System.fetchSupportEmail(); setSupportEmail(supportEmail.email || ""); setOriginalEmail(supportEmail.email || ""); setLoading(false); }; fetchSupportEmail(); }, []); const updateSupportEmail = async (e, newValue = null) => { e.preventDefault(); let support_email = newValue; if (newValue === null) { const form = new FormData(e.target); support_email = form.get("supportEmail"); } const { success, error } = await Admin.updateSystemPreferences({ support_email, }); if (!success) { showToast(`Failed to update support email: ${error}`, "error"); return; } else { showToast("Successfully updated support email.", "success"); window.localStorage.removeItem(System.cacheKeys.supportEmail); setSupportEmail(support_email); setOriginalEmail(support_email); setHasChanges(false); } }; const handleChange = (e) => { setSupportEmail(e.target.value); setHasChanges(true); }; if (loading || !user?.role) return null; return ( <form className="flex flex-col gap-y-0.5 mt-4" onSubmit={updateSupportEmail} > <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.support-email.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.support-email.description")} </p> <div className="flex items-center gap-x-4"> <input name="supportEmail" type="email" className="border-none bg-theme-settings-input-bg mt-2 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 py-2 px-4" placeholder="[email protected]" required={true} autoComplete="off" onChange={handleChange} value={supportEmail} /> {originalEmail !== "" && ( <button type="button" onClick={(e) => updateSupportEmail(e, "")} className="text-white text-base font-medium hover:text-opacity-60" > Clear </button> )} </div> {hasChanges && ( <button type="submit" className="transition-all mt-2 w-fit 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" > Save </button> )} </form> ); }
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/GeneralSettings/Settings/components/CustomMessages/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/CustomMessages/index.jsx
import EditingChatBubble from "@/components/EditingChatBubble"; import System from "@/models/system"; import showToast from "@/utils/toast"; import { Plus } from "@phosphor-icons/react"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; export default function CustomMessages() { const { t } = useTranslation(); const [hasChanges, setHasChanges] = useState(false); const [messages, setMessages] = useState([]); useEffect(() => { async function fetchMessages() { const messages = await System.getWelcomeMessages(); setMessages(messages); } fetchMessages(); }, []); const addMessage = (type) => { if (type === "user") { setMessages([ ...messages, { user: t("customization.items.welcome-messages.double-click"), response: "", }, ]); } else { setMessages([ ...messages, { user: "", response: t("customization.items.welcome-messages.double-click"), }, ]); } }; const removeMessage = (index) => { setHasChanges(true); setMessages(messages.filter((_, i) => i !== index)); }; const handleMessageChange = (index, type, value) => { setHasChanges(true); const newMessages = [...messages]; newMessages[index][type] = value; setMessages(newMessages); }; const handleMessageSave = async () => { const { success, error } = await System.setWelcomeMessages(messages); if (!success) { showToast(`Failed to update welcome messages: ${error}`, "error"); return; } showToast("Successfully updated welcome messages.", "success"); setHasChanges(false); }; return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.welcome-messages.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.welcome-messages.description")} </p> <div className="mt-2 flex flex-col gap-y-6 bg-theme-settings-input-bg rounded-lg pr-[31px] pl-[12px] pt-4 max-w-[700px]"> {messages.map((message, index) => ( <div key={index} className="flex flex-col gap-y-2"> {message.user && ( <EditingChatBubble message={message} index={index} type="user" handleMessageChange={handleMessageChange} removeMessage={removeMessage} /> )} {message.response && ( <EditingChatBubble message={message} index={index} type="response" handleMessageChange={handleMessageChange} removeMessage={removeMessage} /> )} </div> ))} <div className="flex gap-4 mt-12 justify-between pb-[15px]"> <button className="border-none self-end text-white hover:text-white/60 light:hover:text-black/60 transition" onClick={() => addMessage("response")} > <div className="flex items-center justify-start text-sm font-normal -ml-2"> <Plus className="m-2" size={16} weight="bold" /> <span className="leading-5"> {t("customization.items.welcome-messages.new")}{" "} <span className="font-bold italic mr-1"> {t("customization.items.welcome-messages.system")} </span>{" "} {t("customization.items.welcome-messages.message")} </span> </div> </button> <button className="border-none self-end text-white hover:text-white/60 light:hover:text-black/60 transition" onClick={() => addMessage("user")} > <div className="flex items-center justify-start text-sm font-normal"> <Plus className="m-2" size={16} weight="bold" /> <span className="leading-5"> {t("customization.items.welcome-messages.new")}{" "} <span className="font-bold italic mr-1"> {t("customization.items.welcome-messages.user")} </span>{" "} {t("customization.items.welcome-messages.message")} </span> </div> </button> </div> </div> {hasChanges && ( <div className="flex justify-start pt-2"> <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={handleMessageSave} > {t("customization.items.welcome-messages.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/GeneralSettings/Settings/components/AutoSubmit/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/AutoSubmit/index.jsx
import React, { useState, useEffect } from "react"; import Appearance from "@/models/appearance"; import { useTranslation } from "react-i18next"; export default function AutoSubmit() { const [saving, setSaving] = useState(false); const [autoSubmitSttInput, setAutoSubmitSttInput] = useState(true); const { t } = useTranslation(); const handleChange = async (e) => { const newValue = e.target.checked; setAutoSubmitSttInput(newValue); setSaving(true); try { Appearance.updateSettings({ autoSubmitSttInput: newValue }); } catch (error) { console.error("Failed to update appearance settings:", error); setAutoSubmitSttInput(!newValue); } setSaving(false); }; useEffect(() => { function fetchSettings() { const settings = Appearance.getSettings(); setAutoSubmitSttInput(settings.autoSubmitSttInput ?? true); } fetchSettings(); }, []); return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.chat.auto_submit.title")} </p> <p className="text-xs text-white/60"> {t("customization.chat.auto_submit.description")} </p> <div className="flex items-center gap-x-4"> <label className="relative inline-flex cursor-pointer items-center"> <input id="auto_submit" type="checkbox" name="auto_submit" value="yes" checked={autoSubmitSttInput} onChange={handleChange} disabled={saving} 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> </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/GeneralSettings/Settings/components/MessageDirection/index.jsx
frontend/src/pages/GeneralSettings/Settings/components/MessageDirection/index.jsx
import { useChatMessageAlignment } from "@/hooks/useChatMessageAlignment"; import { Tooltip } from "react-tooltip"; import { useTranslation } from "react-i18next"; export function MessageDirection() { const { t } = useTranslation(); const { msgDirection, setMsgDirection } = useChatMessageAlignment(); return ( <div className="flex flex-col gap-y-0.5 my-4"> <p className="text-sm leading-6 font-semibold text-white"> {t("customization.items.chat-message-alignment.title")} </p> <p className="text-xs text-white/60"> {t("customization.items.chat-message-alignment.description")} </p> <div className="flex flex-row flex-wrap gap-x-4 pt-1 gap-y-4 md:gap-y-0"> <ItemDirection active={msgDirection === "left"} reverse={false} msg="User and AI messages are aligned to the left (default)" onSelect={() => { setMsgDirection("left"); }} /> <ItemDirection active={msgDirection === "left_right"} reverse={true} msg="User and AI messages are distributed left and right alternating each message" onSelect={() => { setMsgDirection("left_right"); }} /> </div> <Tooltip id="alignment-choice-item" place="top" delayShow={300} className="tooltip !text-xs z-99" /> </div> ); } function ItemDirection({ active, reverse, onSelect, msg }) { return ( <button data-tooltip-id="alignment-choice-item" data-tooltip-content={msg} type="button" className={`flex:1 p-4 bg-transparent hover:light:bg-gray-100 hover:bg-gray-700/20 rounded-xl border w-[250px] ${active ? "border-primary-button" : " border-theme-sidebar-border"}`} onClick={onSelect} > <div className="space-y-4"> {Array.from({ length: 3 }).map((_, index) => ( <div key={index} className={`flex items-center justify-end gap-2 ${reverse && index % 2 === 0 ? "flex-row-reverse" : ""}`} > <div className={`w-4 h-4 rounded-full ${index % 2 === 0 ? "bg-primary-button" : "bg-white light:bg-black"} flex-shrink-0`} /> <div className="bg-gray-600 light:bg-gray-200 rounded-2xl px-4 py-2 h-[20px] w-full" /> </div> ))} </div> </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/WorkspaceChat/index.jsx
frontend/src/pages/WorkspaceChat/index.jsx
import React, { useEffect, useState } from "react"; import { default as WorkspaceChatContainer } from "@/components/WorkspaceChat"; import Sidebar from "@/components/Sidebar"; import { useParams } from "react-router-dom"; import Workspace from "@/models/workspace"; import PasswordModal, { usePasswordModal } from "@/components/Modals/Password"; import { isMobile } from "react-device-detect"; import { FullScreenLoader } from "@/components/Preloader"; import { LAST_VISITED_WORKSPACE } from "@/utils/constants"; export default function WorkspaceChat() { const { loading, requiresAuth, mode } = usePasswordModal(); if (loading) return <FullScreenLoader />; if (requiresAuth !== false) { return <>{requiresAuth !== null && <PasswordModal mode={mode} />}</>; } return <ShowWorkspaceChat />; } function ShowWorkspaceChat() { const { slug } = useParams(); const [workspace, setWorkspace] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { async function getWorkspace() { if (!slug) return; const _workspace = await Workspace.bySlug(slug); if (!_workspace) return setLoading(false); const suggestedMessages = await Workspace.getSuggestedMessages(slug); const pfpUrl = await Workspace.fetchPfp(slug); setWorkspace({ ..._workspace, suggestedMessages, pfpUrl, }); setLoading(false); localStorage.setItem( LAST_VISITED_WORKSPACE, JSON.stringify({ slug: _workspace.slug, name: _workspace.name, }) ); } getWorkspace(); }, []); return ( <> <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> {!isMobile && <Sidebar />} <WorkspaceChatContainer loading={loading} 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/Login/index.jsx
frontend/src/pages/Login/index.jsx
import React from "react"; import PasswordModal, { usePasswordModal } from "@/components/Modals/Password"; import { FullScreenLoader } from "@/components/Preloader"; import { Navigate } from "react-router-dom"; import paths from "@/utils/paths"; import useQuery from "@/hooks/useQuery"; import useSimpleSSO from "@/hooks/useSimpleSSO"; /** * Login page that handles both single and multi-user login. * * If Simple SSO is enabled and no login is allowed, the user will be redirected to the SSO login page * which may not have a token so the login will fail. * * @returns {JSX.Element} */ export default function Login() { const query = useQuery(); const { loading: ssoLoading, ssoConfig } = useSimpleSSO(); const { loading, requiresAuth, mode } = usePasswordModal(!!query.get("nt")); if (loading || ssoLoading) return <FullScreenLoader />; // If simple SSO is enabled and no login is allowed, redirect to the SSO login page. if (ssoConfig.enabled && ssoConfig.noLogin) { // If a noLoginRedirect is provided and no token is provided, redirect to that webpage. if (!!ssoConfig.noLoginRedirect && !query.has("token")) return window.location.replace(ssoConfig.noLoginRedirect); // Otherwise, redirect to the SSO login page. else return <Navigate to={paths.sso.login()} />; } if (requiresAuth === false) return <Navigate to={paths.home()} />; return <PasswordModal mode={mode} />; }
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/Login/SSO/simple.jsx
frontend/src/pages/Login/SSO/simple.jsx
import React, { useEffect, useState } from "react"; import { FullScreenLoader } from "@/components/Preloader"; import paths from "@/utils/paths"; import useQuery from "@/hooks/useQuery"; import System from "@/models/system"; import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "@/utils/constants"; export default function SimpleSSOPassthrough() { const query = useQuery(); const redirectPath = query.get("redirectTo") || paths.home(); const [ready, setReady] = useState(false); const [error, setError] = useState(null); useEffect(() => { try { if (!query.get("token")) throw new Error("No token provided."); // Clear any existing auth data window.localStorage.removeItem(AUTH_USER); window.localStorage.removeItem(AUTH_TOKEN); window.localStorage.removeItem(AUTH_TIMESTAMP); System.simpleSSOLogin(query.get("token")) .then((res) => { if (!res.valid) throw new Error(res.message); window.localStorage.setItem(AUTH_USER, JSON.stringify(res.user)); window.localStorage.setItem(AUTH_TOKEN, res.token); window.localStorage.setItem(AUTH_TIMESTAMP, Number(new Date())); setReady(res.valid); }) .catch((e) => { setError(e.message); }); } catch (e) { setError(e.message); } }, []); if (error) return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-primary flex items-center justify-center flex-col gap-4"> <p className="text-theme-text-primary font-mono text-lg">{error}</p> <p className="text-theme-text-secondary font-mono text-sm"> Please contact the system administrator about this error. </p> </div> ); if (ready) return window.location.replace(redirectPath); // Loading state by default return <FullScreenLoader />; }
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/index.jsx
frontend/src/pages/WorkspaceSettings/index.jsx
import React, { useEffect, useState } from "react"; import { useParams } from "react-router-dom"; import Sidebar from "@/components/Sidebar"; import Workspace from "@/models/workspace"; import PasswordModal, { usePasswordModal } from "@/components/Modals/Password"; import { isMobile } from "react-device-detect"; import { FullScreenLoader } from "@/components/Preloader"; import { ArrowUUpLeft, ChatText, Database, Robot, User, Wrench, } from "@phosphor-icons/react"; import paths from "@/utils/paths"; import { Link } from "react-router-dom"; import { NavLink } from "react-router-dom"; import GeneralAppearance from "./GeneralAppearance"; import ChatSettings from "./ChatSettings"; import VectorDatabase from "./VectorDatabase"; import Members from "./Members"; import WorkspaceAgentConfiguration from "./AgentConfig"; import useUser from "@/hooks/useUser"; import { useTranslation } from "react-i18next"; import System from "@/models/system"; const TABS = { "general-appearance": GeneralAppearance, "chat-settings": ChatSettings, "vector-database": VectorDatabase, members: Members, "agent-config": WorkspaceAgentConfiguration, }; export default function WorkspaceSettings() { const { loading, requiresAuth, mode } = usePasswordModal(); if (loading) return <FullScreenLoader />; if (requiresAuth !== false) { return <>{requiresAuth !== null && <PasswordModal mode={mode} />}</>; } return <ShowWorkspaceChat />; } function ShowWorkspaceChat() { const { t } = useTranslation(); const { slug, tab } = useParams(); const { user } = useUser(); const [workspace, setWorkspace] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { async function getWorkspace() { if (!slug) return; const _workspace = await Workspace.bySlug(slug); if (!_workspace) { setLoading(false); return; } const _settings = await System.keys(); const suggestedMessages = await Workspace.getSuggestedMessages(slug); setWorkspace({ ..._workspace, vectorDB: _settings?.VectorDB, suggestedMessages, }); setLoading(false); } getWorkspace(); }, [slug, tab]); if (loading) return <FullScreenLoader />; const TabContent = TABS[tab]; return ( <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex"> {!isMobile && <Sidebar />} <div style={{ height: isMobile ? "100%" : "calc(100% - 32px)" }} className="transition-all duration-500 relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll" > <div className="flex gap-x-10 pt-6 pb-4 ml-16 mr-8 border-b-2 border-white light:border-theme-chat-input-border border-opacity-10"> <Link to={paths.workspace.chat(slug)} className="absolute top-2 left-2 md:top-4 md:left-4 transition-all duration-300 p-2 rounded-full text-white bg-theme-sidebar-footer-icon hover:bg-theme-sidebar-footer-icon-hover z-10" > <ArrowUUpLeft className="h-5 w-5" weight="fill" /> </Link> <TabItem title={t("workspaces—settings.general")} icon={<Wrench className="h-6 w-6" />} to={paths.workspace.settings.generalAppearance(slug)} /> <TabItem title={t("workspaces—settings.chat")} icon={<ChatText className="h-6 w-6" />} to={paths.workspace.settings.chatSettings(slug)} /> <TabItem title={t("workspaces—settings.vector")} icon={<Database className="h-6 w-6" />} to={paths.workspace.settings.vectorDatabase(slug)} /> <TabItem title={t("workspaces—settings.members")} icon={<User className="h-6 w-6" />} to={paths.workspace.settings.members(slug)} visible={["admin", "manager"].includes(user?.role)} /> <TabItem title={t("workspaces—settings.agent")} icon={<Robot className="h-6 w-6" />} to={paths.workspace.settings.agentConfig(slug)} /> </div> <div className="px-16 py-6"> <TabContent slug={slug} workspace={workspace} /> </div> </div> </div> ); } function TabItem({ title, icon, to, visible = true }) { if (!visible) return null; return ( <NavLink to={to} className={({ isActive }) => `${ isActive ? "text-sky-400 pb-4 border-b-[4px] -mb-[19px] border-sky-400" : "text-white/60 hover:text-sky-400" } ` + " flex gap-x-2 items-center font-medium" } > {icon} <div>{title}</div> </NavLink> ); }
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/index.jsx
frontend/src/pages/WorkspaceSettings/VectorDatabase/index.jsx
import Workspace from "@/models/workspace"; import showToast from "@/utils/toast"; import { castToType } from "@/utils/types"; import { useRef, useState } from "react"; import VectorDBIdentifier from "./VectorDBIdentifier"; import MaxContextSnippets from "./MaxContextSnippets"; import DocumentSimilarityThreshold from "./DocumentSimilarityThreshold"; import ResetDatabase from "./ResetDatabase"; import VectorCount from "./VectorCount"; import VectorSearchMode from "./VectorSearchMode"; import CTAButton from "@/components/lib/CTAButton"; export default function VectorDatabase({ workspace }) { const [hasChanges, setHasChanges] = useState(false); const [saving, setSaving] = useState(false); const formEl = useRef(null); 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) 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> )} <div className="flex items-start gap-x-5"> <VectorDBIdentifier workspace={workspace} /> <VectorCount reload={true} workspace={workspace} /> </div> <VectorSearchMode workspace={workspace} setHasChanges={setHasChanges} /> <MaxContextSnippets workspace={workspace} setHasChanges={setHasChanges} /> <DocumentSimilarityThreshold workspace={workspace} setHasChanges={setHasChanges} /> <ResetDatabase workspace={workspace} /> </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/VectorDatabase/VectorSearchMode/index.jsx
frontend/src/pages/WorkspaceSettings/VectorDatabase/VectorSearchMode/index.jsx
import { useState } from "react"; // We dont support all vectorDBs yet for reranking due to complexities of how each provider // returns information. We need to normalize the response data so Reranker can be used for each provider. const supportedVectorDBs = ["lancedb"]; const hint = { default: { title: "Default", description: "This is the fastest performance, but may not return the most relevant results leading to model hallucinations.", }, rerank: { title: "Accuracy Optimized", description: "LLM responses may take longer to generate, but your responses will be more accurate and relevant.", }, }; export default function VectorSearchMode({ workspace, setHasChanges }) { const [selection, setSelection] = useState( workspace?.vectorSearchMode ?? "default" ); if (!workspace?.vectorDB || !supportedVectorDBs.includes(workspace?.vectorDB)) return null; return ( <div> <div className="flex flex-col"> <label htmlFor="name" className="block input-label"> Search Preference </label> </div> <select name="vectorSearchMode" value={selection} 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={(e) => { setSelection(e.target.value); setHasChanges(true); }} required={true} > <option value="default">Default</option> <option value="rerank">Accuracy Optimized</option> </select> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {hint[selection]?.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/pages/WorkspaceSettings/VectorDatabase/MaxContextSnippets/index.jsx
frontend/src/pages/WorkspaceSettings/VectorDatabase/MaxContextSnippets/index.jsx
import { useTranslation } from "react-i18next"; export default function MaxContextSnippets({ workspace, setHasChanges }) { const { t } = useTranslation(); return ( <div> <div className="flex flex-col"> <label htmlFor="name" className="block input-label"> {t("vector-workspace.snippets.title")} </label> <p className="text-white text-opacity-60 text-xs font-medium py-1.5"> {t("vector-workspace.snippets.description")} <br /> <i>{t("vector-workspace.snippets.recommend")}</i> </p> </div> <input name="topN" type="number" min={1} max={200} step={1} onWheel={(e) => e.target.blur()} defaultValue={workspace?.topN ?? 4} 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 mt-2" placeholder="4" 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/VectorDatabase/VectorDBIdentifier/index.jsx
frontend/src/pages/WorkspaceSettings/VectorDatabase/VectorDBIdentifier/index.jsx
import { useTranslation } from "react-i18next"; export default function VectorDBIdentifier({ workspace }) { const { t } = useTranslation(); return ( <div> <h3 className="input-label">{t("vector-workspace.identifier")}</h3> <p className="text-white/60 text-xs font-medium py-1"> </p> <p className="text-white/60 text-sm">{workspace?.slug}</p> </div> ); }
javascript
MIT
e287fab56089cf8fcea9ba579a3ecdeca0daa313
2026-01-04T14:57:11.963777Z
false