import React, { useState } from "react" import { useLocation, NavLink } from "react-router-dom" import { Sidebar } from "../Option/Sidebar" import { Drawer, Select, Tooltip } from "antd" import { useQuery } from "@tanstack/react-query" import { getAllModels } from "~/services/ollama" import { useMessageOption } from "~/hooks/useMessageOption" import { ChevronLeft, CogIcon, ComputerIcon, GithubIcon, PanelLeftIcon, SquarePen, ZapIcon } from "lucide-react" import { getAllPrompts } from "@/db" import { ShareBtn } from "~/components/Common/ShareBtn" import { useTranslation } from "react-i18next" import { OllamaIcon } from "../Icons/Ollama" import { SelectedKnowledge } from "../Option/Knowledge/SelectedKnwledge" export default function OptionLayout({ children }: { children: React.ReactNode }) { const [sidebarOpen, setSidebarOpen] = useState(false) const { t } = useTranslation(["option", "common"]) const { selectedModel, setSelectedModel, clearChat, selectedSystemPrompt, setSelectedQuickPrompt, setSelectedSystemPrompt, messages, streaming } = useMessageOption() const { data: models, isLoading: isModelsLoading, isFetching: isModelsFetching } = useQuery({ queryKey: ["fetchModel"], queryFn: () => getAllModels({ returnEmpty: true }), refetchInterval: 15000 }) const { data: prompts, isLoading: isPromptLoading } = useQuery({ queryKey: ["fetchAllPromptsLayout"], queryFn: getAllPrompts }) const { pathname } = useLocation() const getPromptInfoById = (id: string) => { return prompts?.find((prompt) => prompt.id === id) } const handlePromptChange = (value: string) => { const prompt = getPromptInfoById(value) if (prompt?.is_system) { setSelectedSystemPrompt(prompt.id) } else { setSelectedQuickPrompt(prompt!.content) setSelectedSystemPrompt("") } } return (
) }