Pseudo function signatures
Show pseudo function signatures in the variant editor box as a UX hint that you're typing in javascript and have access to the scenario.
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import { Box, Button, HStack, Tooltip, useToast } from "@chakra-ui/react";
|
import { Box, Button, HStack, Tooltip, VStack, useToast } from "@chakra-ui/react";
|
||||||
import { useRef, useEffect, useState, useCallback } from "react";
|
import { useRef, useEffect, useState, useCallback } from "react";
|
||||||
import { useHandledAsyncCallback, useModifierKeyLabel } from "~/utils/hooks";
|
import { useHandledAsyncCallback, useModifierKeyLabel } from "~/utils/hooks";
|
||||||
import { type PromptVariant } from "./types";
|
import { type PromptVariant } from "./types";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
import { useAppStore } from "~/state/store";
|
import { useAppStore } from "~/state/store";
|
||||||
|
import { editorBackground } from "~/state/sharedVariantEditor.slice";
|
||||||
// import openAITypes from "~/codegen/openai.types.ts.txt";
|
// import openAITypes from "~/codegen/openai.types.ts.txt";
|
||||||
|
|
||||||
export default function VariantConfigEditor(props: { variant: PromptVariant }) {
|
export default function VariantConfigEditor(props: { variant: PromptVariant }) {
|
||||||
@@ -129,21 +130,21 @@ export default function VariantConfigEditor(props: { variant: PromptVariant }) {
|
|||||||
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
||||||
}, [monaco, editorId]);
|
}, [monaco, editorId]);
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// const savedConfigChanged = lastSavedFn !== savedConfig;
|
|
||||||
|
|
||||||
// lastSavedFn = savedConfig;
|
|
||||||
|
|
||||||
// if (savedConfigChanged && editorRef.current?.getValue() !== savedConfig) {
|
|
||||||
// editorRef.current?.setValue(savedConfig);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// checkForChanges();
|
|
||||||
// }, [savedConfig, checkForChanges]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box w="100%" pos="relative">
|
<Box w="100%" pos="relative">
|
||||||
<div id={editorId} style={{ height: "300px", width: "100%" }}></div>
|
<VStack
|
||||||
|
spacing={0}
|
||||||
|
align="stretch"
|
||||||
|
fontSize="xs"
|
||||||
|
fontWeight="bold"
|
||||||
|
color="gray.600"
|
||||||
|
py={2}
|
||||||
|
bgColor={editorBackground}
|
||||||
|
>
|
||||||
|
<code>{`function constructPrompt(scenario: Scenario): Prompt {`}</code>
|
||||||
|
<div id={editorId} style={{ height: "300px", width: "100%" }}></div>
|
||||||
|
<code>{`return prompt; }`}</code>
|
||||||
|
</VStack>
|
||||||
{isChanged && (
|
{isChanged && (
|
||||||
<HStack pos="absolute" bottom={2} right={2}>
|
<HStack pos="absolute" bottom={2} right={2}>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import parserTypescript from "prettier/plugins/typescript";
|
|||||||
import parserEstree from "prettier/plugins/estree";
|
import parserEstree from "prettier/plugins/estree";
|
||||||
import { type languages } from "monaco-editor/esm/vs/editor/editor.api";
|
import { type languages } from "monaco-editor/esm/vs/editor/editor.api";
|
||||||
|
|
||||||
|
export const editorBackground = "#fafafa";
|
||||||
|
|
||||||
export type SharedVariantEditorSlice = {
|
export type SharedVariantEditorSlice = {
|
||||||
monaco: null | ReturnType<typeof loader.__getMonacoInstance>;
|
monaco: null | ReturnType<typeof loader.__getMonacoInstance>;
|
||||||
loadMonaco: () => Promise<void>;
|
loadMonaco: () => Promise<void>;
|
||||||
@@ -50,7 +52,7 @@ export const createVariantEditorSlice: SliceCreator<SharedVariantEditorSlice> =
|
|||||||
inherit: true,
|
inherit: true,
|
||||||
rules: [],
|
rules: [],
|
||||||
colors: {
|
colors: {
|
||||||
"editor.background": "#fafafa",
|
"editor.background": editorBackground,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user