Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
yoziru committed Mar 27, 2024
1 parent bc0ce76 commit 6ba3d07
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 38 deletions.
28 changes: 0 additions & 28 deletions src/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,6 @@ const formatMessages = (messages: Message[]): Message[] => {
});
};

// export async function POST(req: NextRequest) {
// const { messages, chatOptions } = await req.json();
// if (!chatOptions.selectedModel || chatOptions.selectedModel === "") {
// throw new Error("Selected model is required");
// }

// const baseUrl = process.env.VLLM_URL + "/v1";
// const model = new ChatOpenAI({
// openAIApiKey: "foo",
// configuration: {
// baseURL: baseUrl,
// },
// modelName: chatOptions.selectedModel,
// temperature: chatOptions.temperature,
// });

// const parser = new BytesOutputParser();
// const formattedMessages = formatMessages(
// addSystemMessage(messages, chatOptions.systemPrompt)
// );
// try {
// const stream = await model.pipe(parser).stream(formattedMessages);
// return new StreamingTextResponse(stream);
// } catch (e: any) {
// return NextResponse.json({ error: e.message }, { status: e.status ?? 500 });
// }
// }

export async function POST(req: NextRequest) {
try {
const { messages, chatOptions } = await req.json();
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings-clear-chats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function ClearChatsButton() {

return (
<Dialog>
<DialogTrigger className="w-full">
<DialogTrigger className="w-full" disabled={disabled}>
<Button
className="justify-start gap-2 w-full hover:bg-destructive/30 hover:text-red-500"
size="sm"
Expand Down
27 changes: 19 additions & 8 deletions src/components/system-prompt-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import TextareaAutosize from "react-textarea-autosize";
import { SystemPromptProps } from "./system-prompt";
import { DialogClose } from "@radix-ui/react-dialog";
const formSchema = z.object({
name: z.string().min(1, {
message: "Please set a system prompt",
}),
name: z.string(),
});

export default function SystemPromptForm({
Expand All @@ -36,7 +34,7 @@ export default function SystemPromptForm({
function onSubmit(data: z.infer<typeof formSchema>) {
// set system prompt to local storage
setChatOptions({ ...chatOptions, systemPrompt: data.name });
toast.success("System prompt saved");
toast.success("System prompt updated.");
}

const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
Expand All @@ -52,6 +50,11 @@ export default function SystemPromptForm({
}
};

const clearSystemPrompt = () => {
setName("");
form.setValue("name", "");
};

return (
<Form {...form}>
<form
Expand All @@ -67,7 +70,7 @@ export default function SystemPromptForm({
<div>
<TextareaAutosize
{...field}
className="w-full p-2 border rounded-xs"
className="w-full p-2 border-2 border-sky-500 rounded-sm h-full my-4"
autoComplete="off"
rows={3}
value={name}
Expand All @@ -81,9 +84,17 @@ export default function SystemPromptForm({
</FormItem>
)}
/>
<DialogClose className="space-y-2 w-full">
<Button type="submit" className="w-full">
Save system prompt
<DialogClose className="w-full flex gap-4">
<Button
onClick={clearSystemPrompt}
variant="ghost"
className="w-full"
size="sm"
>
Clear
</Button>
<Button type="submit" variant="default" className="w-full" size="sm">
Save
</Button>
</DialogClose>
</form>
Expand Down
1 change: 0 additions & 1 deletion src/components/system-prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default function SystemPrompt({
</Button>
</DialogTrigger>
<DialogContent className="space-y-2">
<DialogTitle>Save system prompt</DialogTitle>
<SystemPromptForm
chatOptions={chatOptions}
setChatOptions={setChatOptions}
Expand Down

0 comments on commit 6ba3d07

Please sign in to comment.