Skip to content

Commit

Permalink
Removes unused imports that were previnting GH from building releases
Browse files Browse the repository at this point in the history
  • Loading branch information
dezoito committed May 10, 2024
1 parent 3f962cb commit afe66cb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
39 changes: 25 additions & 14 deletions src/components/filters/SystemPromptSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PromptDialog } from "@/components/prompt-dialog";
import {
FormControl,
FormDescription,
Expand All @@ -6,14 +7,10 @@ import {
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { useCallback, useEffect, useState } from "react";
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { TrashIcon } from "@radix-ui/react-icons";
import { PromptDialog } from "@/components/prompt-dialog";
import { useEffect, useState } from "react";
// import { Form } from "react-hook-form"
import * as React from "react";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";

interface IProps {
form: any;
Expand All @@ -22,16 +19,21 @@ interface IProps {
function SystemPromptSelector(props: IProps) {
const { form } = props;
const idx = 0;
const [systemPrompt, setSystemPrompt] = useState<string>(form.getValues().system_prompt)
const [systemPrompt, setSystemPrompt] = useState<string>(
form.getValues().system_prompt,
);

useEffect(() => {
// sync form state
form.setValue("system_prompt", systemPrompt)
}, [systemPrompt])
form.setValue("system_prompt", systemPrompt);
}, [systemPrompt]);

const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>, _: number) => {
setSystemPrompt(e.target.value)
}
const handleChange = (
e: React.ChangeEvent<HTMLTextAreaElement>,
_: number,
) => {
setSystemPrompt(e.target.value);
};

return (
<FormField
Expand All @@ -48,7 +50,13 @@ function SystemPromptSelector(props: IProps) {
<FormLabel className="flex flex-row items-center justify-between font-bold">
System Prompt
<div>
<PromptDialog content={systemPrompt} handleChange={handleChange} idx={idx} fieldName="system_prompt" fieldLabel="system prompt" />
<PromptDialog
content={systemPrompt}
handleChange={handleChange}
idx={idx}
fieldName="system_prompt"
fieldLabel="system prompt"
/>
</div>
</FormLabel>
<FormControl>
Expand All @@ -57,11 +65,14 @@ function SystemPromptSelector(props: IProps) {
className="flex-1"
value={systemPrompt}
rows={4}
onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => handleChange(e, idx)}
onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) =>
handleChange(e, idx)
}
/>
</FormControl>
<FormDescription>
Optional. The system message used to specify custom behavior.
Optional. The system message used to specify custom
behavior.
</FormDescription>
</FormItem>
);
Expand Down
16 changes: 7 additions & 9 deletions src/components/ui/form-grid-params.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { configAtom, gridParamsAtom } from "@/Atoms";
import PromptSelector from "@/components/filters/PromptSelector";
import { useConfirm } from "@/components/ui/alert-dialog-provider";
import { Input } from "@/components/ui/input";
import {
Expand All @@ -15,6 +16,7 @@ import { useForm } from "react-hook-form";
import { v4 as uuidv4 } from "uuid";
import z from "zod";
import ModelSelector from "../filters/ModelSelector";
import SystemPromptSelector from "../filters/SystemPromptSelector";
import { Button } from "./button";
import {
Form,
Expand All @@ -27,10 +29,6 @@ import {
} from "./form";
import Spinner from "./spinner";
import { useToast } from "./use-toast";
import PromptSelector from "@/components/filters/PromptSelector";
import { useState } from "react";
import { Textarea } from "@/components/ui/textarea";
import SystemPromptSelector from "../filters/SystemPromptSelector";

const validateNumberOrArray =
(inputType: "float" | "int") => (value: string | number) => {
Expand Down Expand Up @@ -152,7 +150,7 @@ export default function FormGridParams() {
const [__, setGridParams] = useAtom(gridParamsAtom);
const confirm = useConfirm();

const defaultPrompt = "Write a short sentence!"
const defaultPrompt = "Write a short sentence!";

// Initiates for fields with value set in Settings > default options
const form = useForm<z.infer<typeof ParamsFormSchema>>({
Expand Down Expand Up @@ -215,7 +213,7 @@ export default function FormGridParams() {

{/* system prompt */}
<SystemPromptSelector form={form} />

{/* generations */}
<div className="flex flex-col gap-2">
<FormField
Expand Down Expand Up @@ -584,8 +582,8 @@ export default function FormGridParams() {
</Button>
</div>
</div>
</form >
</Form >
</div >
</form>
</Form>
</div>
);
}

0 comments on commit afe66cb

Please sign in to comment.