pixelass commited on
Commit
34bac1b
•
1 Parent(s): 9d1931d

feat: temperature

Browse files

allow adjusting temperature

src/lib/theme.ts CHANGED
@@ -12,11 +12,12 @@ export const roboto = Roboto({
12
  // Create a theme instance.
13
  const theme = createTheme({
14
  palette: {
 
15
  primary: {
16
- main: "#556cd6",
17
  },
18
  secondary: {
19
- main: "#19857b",
20
  },
21
  error: {
22
  main: red.A400,
 
12
  // Create a theme instance.
13
  const theme = createTheme({
14
  palette: {
15
+ mode: "dark",
16
  primary: {
17
+ main: "#00d720",
18
  },
19
  secondary: {
20
+ main: "#cc06ed",
21
  },
22
  error: {
23
  main: red.A400,
src/pages/index.tsx CHANGED
@@ -1,6 +1,8 @@
1
  import { useEffect, useRef, useState } from "react";
2
 
3
  import axios from "axios";
 
 
4
  import CheckIcon from "@mui/icons-material/Check";
5
  import ClearIcon from "@mui/icons-material/Clear";
6
  import ContentCopyIcon from "@mui/icons-material/ContentCopy";
@@ -31,19 +33,20 @@ import ListItemButton from "@mui/material/ListItemButton";
31
  import ListItemText from "@mui/material/ListItemText";
32
  import { useHost } from "esdeka/react";
33
  import CircularProgress from "@mui/material/CircularProgress";
34
- import { miniPrompt } from "@/services/api";
35
  import CssBaseline from "@mui/material/CssBaseline";
 
36
 
37
  const base = {
38
- default: miniPrompt`const canvas = document.querySelector('canvas');
39
- const ctx = canvas.getContext('2d');
40
- /*60FPS draw cycle*/
41
- function draw(){
42
- const FPS = 60;
43
- setTimeout(requestAnimationFrame(draw),1000/FPS)
44
- }
45
- draw();
46
- `,
 
47
  };
48
 
49
  const fontMono = Fira_Code({
@@ -190,6 +193,7 @@ export default function Home() {
190
  edge="start"
191
  color="inherit"
192
  aria-label={loading ? "Loading" : "Run"}
 
193
  disabled={loading}
194
  >
195
  {loading ? <HourglassTopIcon /> : <PlayArrowIcon />}
@@ -223,7 +227,8 @@ export default function Home() {
223
  id="prompt"
224
  name="prompt"
225
  label="Prompt"
226
- placeholder="add a red box"
 
227
  maxRows={6}
228
  InputProps={{
229
  style: fontMono.style,
@@ -252,6 +257,26 @@ export default function Home() {
252
  <Typography>Options</Typography>
253
  </AccordionSummary>
254
  <AccordionDetails>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  <TextField
256
  multiline
257
  fullWidth
@@ -297,6 +322,8 @@ export default function Home() {
297
  <IconButton
298
  edge="end"
299
  aria-label="Show"
 
 
300
  onClick={() => {
301
  setRunningId(answer.id);
302
  reload();
 
1
  import { useEffect, useRef, useState } from "react";
2
 
3
  import axios from "axios";
4
+ import AcUnitIcon from "@mui/icons-material/AcUnit";
5
+ import LocalFireDepartmentIcon from "@mui/icons-material/LocalFireDepartment";
6
  import CheckIcon from "@mui/icons-material/Check";
7
  import ClearIcon from "@mui/icons-material/Clear";
8
  import ContentCopyIcon from "@mui/icons-material/ContentCopy";
 
33
  import ListItemText from "@mui/material/ListItemText";
34
  import { useHost } from "esdeka/react";
35
  import CircularProgress from "@mui/material/CircularProgress";
 
36
  import CssBaseline from "@mui/material/CssBaseline";
37
+ import Slider from "@mui/material/Slider";
38
 
39
  const base = {
40
+ default: `
41
+ const canvas = document.querySelector('canvas');
42
+ const ctx = canvas.getContext('2d');
43
+ const FPS = 60;
44
+ /*60FPS draw cycle*/
45
+ function draw(){
46
+ setTimeout(requestAnimationFrame(draw),1000/FPS)
47
+ }
48
+ draw();
49
+ `.trim(),
50
  };
51
 
52
  const fontMono = Fira_Code({
 
193
  edge="start"
194
  color="inherit"
195
  aria-label={loading ? "Loading" : "Run"}
196
+ aria-disabled={loading}
197
  disabled={loading}
198
  >
199
  {loading ? <HourglassTopIcon /> : <PlayArrowIcon />}
 
227
  id="prompt"
228
  name="prompt"
229
  label="Prompt"
230
+ placeholder="add a red heart"
231
+ defaultValue="add a red heart"
232
  maxRows={6}
233
  InputProps={{
234
  style: fontMono.style,
 
257
  <Typography>Options</Typography>
258
  </AccordionSummary>
259
  <AccordionDetails>
260
+ <Stack
261
+ spacing={2}
262
+ direction="row"
263
+ sx={{ mb: 2 }}
264
+ alignItems="center"
265
+ >
266
+ <AcUnitIcon />
267
+ <Slider
268
+ marks
269
+ id="temperature"
270
+ name="temperature"
271
+ min={0}
272
+ max={0.8}
273
+ defaultValue={0.2}
274
+ step={0.1}
275
+ valueLabelDisplay="auto"
276
+ aria-label="Temperature"
277
+ />
278
+ <LocalFireDepartmentIcon />
279
+ </Stack>
280
  <TextField
281
  multiline
282
  fullWidth
 
322
  <IconButton
323
  edge="end"
324
  aria-label="Show"
325
+ aria-disabled={runningId === answer.id}
326
+ disabled={runningId === answer.id}
327
  onClick={() => {
328
  setRunningId(answer.id);
329
  reload();
src/pages/live.tsx CHANGED
@@ -11,6 +11,7 @@ const styles = (
11
  height: 100%;
12
  width: 100%;
13
  overflow: hidden;
 
14
  }
15
  #__next {
16
  display: contents;
 
11
  height: 100%;
12
  width: 100%;
13
  overflow: hidden;
14
+ background: white;
15
  }
16
  #__next {
17
  display: contents;
src/services/api/index.ts CHANGED
@@ -26,10 +26,11 @@ function extractCode(string: string) {
26
  }
27
 
28
  export async function toOpenAI({
29
- prompt = "",
30
  negativePrompt = "",
31
  template = "",
32
- }: Record<string, string>) {
 
33
  const negativePrompt_ = negativePrompt.trim();
34
  const prompt_ = prompt.trim();
35
 
@@ -47,7 +48,7 @@ export async function toOpenAI({
47
  try {
48
  const response = await openai.createChatCompletion({
49
  model: "gpt-3.5-turbo",
50
- temperature: 0.2,
51
  messages: [
52
  {
53
  role: "system",
 
26
  }
27
 
28
  export async function toOpenAI({
29
+ prompt = "be creative",
30
  negativePrompt = "",
31
  template = "",
32
+ temperature = "0.2",
33
+ }) {
34
  const negativePrompt_ = negativePrompt.trim();
35
  const prompt_ = prompt.trim();
36
 
 
48
  try {
49
  const response = await openai.createChatCompletion({
50
  model: "gpt-3.5-turbo",
51
+ temperature: Number.parseFloat(temperature),
52
  messages: [
53
  {
54
  role: "system",