import styled from "styled-components"; import { defaultBorderRadius, lightGray, secondaryDark, vscBackground, vscForeground, } from "."; import { useContext } from "react"; import { GUIClientContext } from "../App"; import { RootStore } from "../redux/store"; import { useDispatch, useSelector } from "react-redux"; import { ArrowLeftIcon, PlusIcon } from "@heroicons/react/24/outline"; import { setDialogMessage, setShowDialog } from "../redux/slices/uiStateSlice"; import { useNavigate } from "react-router-dom"; const MODEL_INFO: { title: string; class: string; args: any }[] = [ { title: "Ollama", class: "Ollama", args: { model: "codellama", }, }, { title: "llama.cpp", class: "LlamaCpp", args: {}, } ]; const GridDiv = styled.div` display: grid; grid-template-columns: 1fr auto; align-items: center; border: 0.5px solid ${lightGray}; border-radius: ${defaultBorderRadius}; overflow: hidden; `; const Select = styled.select` border: none; max-width: 50vw; //changed the width background-color: ${vscBackground}; color: ${vscForeground}; padding: 6px; max-height: 35vh; overflow: scroll; cursor: pointer; &:focus { outline: none; } &:hover { background-color: ${secondaryDark}; } `; const StyledPlusIcon = styled(PlusIcon)` cursor: pointer; margin: 0px; padding-left: 4px; padding-right: 4px; height: 100%; &:hover { background-color: ${secondaryDark}; } border-left: 0.5px solid ${lightGray}; `; const NewProviderDiv = styled.div` cursor: pointer; padding: 8px; padding-left: 16px; padding-right: 16px; border-top: 0.5px solid ${lightGray}; &:hover { background-color: ${secondaryDark}; } `; function modelSelectTitle(model: any): string { if (model?.title) return model?.title; if (model?.model !== undefined && model?.model.trim() !== "") { if (model?.class_name) { return `${model?.class_name} - ${model?.model}`; } return model?.model; } return model?.class_name; } function ModelSelect(props: {}) { const dispatch = useDispatch(); const client = useContext(GUIClientContext); const defaultModel = useSelector( (state: RootStore) => (state.serverState.config as any)?.models?.default ); const savedModels = useSelector( (state: RootStore) => (state.serverState.config as any)?.models?.saved ); const navigate = useNavigate(); return ( { navigate("/models"); }} /> ); } export default ModelSelect;