import React, { useContext, useEffect, useState } from "react"; import { GUIClientContext } from "../App"; import { useSelector } from "react-redux"; import { RootStore } from "../redux/store"; import { useNavigate } from "react-router-dom"; import { ContinueConfig } from "../../../schema/ContinueConfig"; import { Button, TextArea, lightGray, secondaryDark } from "../components"; import styled from "styled-components"; import { ArrowLeftIcon } from "@heroicons/react/24/outline"; import Loader from "../components/Loader"; import InfoHover from "../components/InfoHover"; import { FormProvider, useForm } from "react-hook-form"; const Hr = styled.hr` border: 0.5px solid ${lightGray}; `; const CancelButton = styled(Button)` background-color: transparent; color: ${lightGray}; border: 1px solid ${lightGray}; &:hover { background-color: ${lightGray}; color: black; } `; const SaveButton = styled(Button)` &:hover { opacity: 0.8; } `; const Slider = styled.input.attrs({ type: "range" })` --webkit-appearance: none; width: 100%; background-color: ${secondaryDark}; outline: none; border: none; opacity: 0.7; -webkit-transition: 0.2s; transition: opacity 0.2s; &:hover { opacity: 1; } &::-webkit-slider-runnable-track { width: 100%; height: 8px; cursor: pointer; background: ${lightGray}; border-radius: 4px; } &::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 8px; height: 8px; cursor: pointer; margin-top: -3px; } &::-moz-range-thumb { width: 8px; height: 8px; cursor: pointer; margin-top: -3px; } &:focus { outline: none; border: none; } `; const ALL_MODEL_ROLES = ["default", "small", "medium", "large", "edit", "chat"]; function Settings() { const formMethods = useForm(); const onSubmit = (data: ContinueConfig) => console.log(data); const navigate = useNavigate(); const client = useContext(GUIClientContext); const config = useSelector((state: RootStore) => state.serverState.config); const submitChanges = () => { if (!client) return; const systemMessage = formMethods.watch("system_message"); const temperature = formMethods.watch("temperature"); // const models = formMethods.watch("models"); client.setSystemMessage(systemMessage || ""); if (temperature) client.setTemperature(temperature); // if (models) { // for (const role of ALL_MODEL_ROLES) { // if (models[role]) { // client.setModelForRole(role, models[role] as string, models[role]); // } // } // } }; const submitAndLeave = () => { submitChanges(); navigate("/"); }; return (

Settings

{config ? (

System Message