1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
import React, { useContext } from "react";
import { GUIClientContext } from "../App";
import { useDispatch, useSelector } from "react-redux";
import { RootStore } from "../redux/store";
import { useNavigate } from "react-router-dom";
import { ContinueConfig } from "../../../schema/ContinueConfig";
import {
Button,
NumberInput,
TextArea,
lightGray,
secondaryDark,
vscBackground,
} 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";
import { getFontSize } from "../util";
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", "summarize", "edit", "chat"];
function Settings() {
const formMethods = useForm<ContinueConfig>();
const onSubmit = (data: ContinueConfig) => console.log(data);
const navigate = useNavigate();
const client = useContext(GUIClientContext);
const config = useSelector((state: RootStore) => state.serverState.config);
const dispatch = useDispatch();
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 (
<FormProvider {...formMethods}>
<div className="overflow-scroll">
<div
className="items-center flex sticky top-0"
style={{
borderBottom: `0.5px solid ${lightGray}`,
backgroundColor: vscBackground,
}}
>
<ArrowLeftIcon
width="1.2em"
height="1.2em"
onClick={submitAndLeave}
className="inline-block ml-4 cursor-pointer"
/>
<h3 className="text-lg font-bold m-2 inline-block">Settings</h3>
</div>
<form onSubmit={formMethods.handleSubmit(onSubmit)}>
{config ? (
<div className="p-2">
<h3 className="flex gap-1">
System Message
<InfoHover
msg={`Set a system message with information that the LLM should always
keep in mind (e.g. "Please give concise answers. Always respond in
Spanish.")`}
/>
</h3>
<TextArea
placeholder="Enter a system message (e.g. 'Always respond in German')"
{...formMethods.register("system_message")}
defaultValue={config.system_message}
/>
<Hr />
<h3 className="flex gap-1">
Temperature
<InfoHover
msg={`Set temperature to any value between 0 and 1. Higher values will
make the LLM more creative, while lower values will make it more
predictable.`}
/>
</h3>
<div className="flex justify-between mx-16 gap-1">
<p>0</p>
<Slider
type="range"
min="0"
max="1"
step="0.01"
defaultValue={config.temperature}
{...formMethods.register("temperature")}
/>
<p>1</p>
</div>
<div className="text-center" style={{ marginTop: "-25px" }}>
<p className="text-sm text-gray-500">
{formMethods.watch("temperature") ||
config.temperature ||
"-"}
</p>
</div>
<Hr />
{/**
<h3 className="flex gap-1">Models</h3>
{ALL_MODEL_ROLES.map((role) => {
return (
<>
<h4>{role}</h4>
<ModelSettings
role={role}
llm={(config.models as any)[role]}
/>
</>
);
})}
<Hr />
<h3 className="flex gap-1">
Custom Commands
<InfoHover
msg={`Custom commands let you map a prompt to a shortened slash command.
They are like slash commands, but more easily defined - write just a
prompt instead of a Step class. Their output will always be in chat
form`}
/>
</h3>
<Hr />
<h3 className="flex gap-1">
Context Providers
<InfoHover
msg={`Context Providers let you type '@' and quickly reference sources of information, like files, GitHub Issues, webpages, and more.`}
/>
</h3>
*/}
</div>
) : (
<Loader />
)}
</form>
<hr />
<div className="px-2">
<h3>Appearance</h3>
<p>Font Size</p>
<NumberInput
type="number"
min="8"
max="48"
step="1"
defaultValue={getFontSize()}
onChange={(e) => {
localStorage.setItem("fontSize", e.target.value);
}}
/>
</div>
<div className="flex gap-2 justify-end px-4">
<CancelButton
onClick={() => {
navigate("/");
}}
>
Cancel
</CancelButton>
<SaveButton onClick={submitAndLeave}>Save</SaveButton>
</div>
</div>
</FormProvider>
);
}
export default Settings;
|