import { ArrowLeftIcon } from "@heroicons/react/24/outline"; import { ContinueConfig } from "../shims/typings"; import { useEffect } from "react"; import { FormProvider, useForm } from "react-hook-form"; import { useDispatch, useSelector } from "react-redux"; import { useNavigate } from "react-router-dom"; import styled from "styled-components"; import { Button, Hr, NumberInput, TextArea, lightGray, vscBackground, vscForeground, vscInputBackground, } from "../components"; import InfoHover from "../components/InfoHover"; import Loader from "../components/loaders/Loader"; import { RootState } from "../redux/store"; import { getFontSize, getPlatform } from "../util"; import { postToIde } from "../util/ide"; 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: ${vscInputBackground}; 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 ConfigJsonButton = styled(Button)` padding: 2px 4px; margin-left: auto; margin-right: 4px; background-color: transparent; color: ${vscForeground}; border: 1px solid ${lightGray}; &:hover { background-color: ${lightGray}; } `; const ALL_MODEL_ROLES = ["default", "summarize", "edit", "chat"]; function Settings() { const formMethods = useForm(); const onSubmit = (data: ContinueConfig) => console.log(data); const navigate = useNavigate(); const config = useSelector((state: RootState) => state.state.config); const dispatch = useDispatch(); const submitChanges = () => { // TODO // if (!client) return; // const systemMessage = formMethods.watch("system_message") as // | string // | undefined; // const temperature = formMethods.watch("temperature") as number | undefined; // // 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("/"); }; useEffect(() => { if (!config) return; formMethods.setValue("systemMessage", config.systemMessage); formMethods.setValue( "completionOptions.temperature", config.completionOptions?.temperature, ); }, [config]); return (

Settings

{ postToIde("showFile", { filepath: getPlatform() == "windows" ? "~\\.continue\\config.json" : "~/.continue/config.json", }); }} > Open config.json
{config ? (

System Message