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: "OpenAI", class: "OpenAI", args: { model: "gpt-4", api_key: "", }, }, { title: "Anthropic", class: "AnthropicLLM", args: { model: "claude-2", api_key: "", }, }, { title: "Ollama", class: "Ollama", args: { model: "codellama", }, }, { title: "TogetherAI", class: "TogetherLLM", args: { model: "togethercomputer/CodeLlama-13b-Instruct", api_key: "", }, }, { title: "Replicate", class: "ReplicateLLM", args: { model: "replicate/llama-2-70b-chat:58d078176e02c219e11eb4da5a02a7830a283b14cf8f94537af893ccff5ee781", api_key: "", }, }, { title: "llama.cpp", class: "LlamaCpp", args: {}, }, { title: "HuggingFace Inference API", class: "HuggingFaceInferenceAPI", args: { endpoint_url: "", hf_token: "", }, }, { title: "Google PaLM API", class: "GooglePaLMAPI", args: { model: "chat-bison-001", api_key: "", }, }, { title: "LM Studio", class: "GGML", args: { server_url: "http://localhost:1234", }, }, { title: "Other OpenAI-compatible API", class: "GGML", args: { server_url: "", }, }, { title: "GPT-4 limited free trial", class: "OpenAIFreeTrial", args: { model: "gpt-4", }, }, ]; 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;