fully working ai limiting
This commit is contained in:
parent
f3e9f81722
commit
93008c34d3
@ -604,6 +604,14 @@ export default function CodeEditor({
|
|||||||
const updatedFile = lines.join("\n");
|
const updatedFile = lines.join("\n");
|
||||||
editorRef?.setValue(updatedFile);
|
editorRef?.setValue(updatedFile);
|
||||||
}}
|
}}
|
||||||
|
onClose={() => {
|
||||||
|
setGenerate((prev) => {
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
show: !prev.show,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
@ -18,6 +18,7 @@ export default function GenerateInput({
|
|||||||
editor,
|
editor,
|
||||||
onExpand,
|
onExpand,
|
||||||
onAccept,
|
onAccept,
|
||||||
|
onClose,
|
||||||
}: {
|
}: {
|
||||||
user: User;
|
user: User;
|
||||||
socket: Socket;
|
socket: Socket;
|
||||||
@ -32,6 +33,7 @@ export default function GenerateInput({
|
|||||||
};
|
};
|
||||||
onExpand: () => void;
|
onExpand: () => void;
|
||||||
onAccept: (code: string) => void;
|
onAccept: (code: string) => void;
|
||||||
|
onClose: () => void;
|
||||||
}) {
|
}) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -61,6 +63,7 @@ export default function GenerateInput({
|
|||||||
toast.error(
|
toast.error(
|
||||||
"You reached the maximum # of generations. Contact @ishaandey_ on X/Twitter to reset :)"
|
"You reached the maximum # of generations. Contact @ishaandey_ on X/Twitter to reset :)"
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading({ generate: !regenerate, regenerate });
|
setLoading({ generate: !regenerate, regenerate });
|
||||||
@ -72,10 +75,11 @@ export default function GenerateInput({
|
|||||||
data.line,
|
data.line,
|
||||||
regenerate ? currentPrompt : input,
|
regenerate ? currentPrompt : input,
|
||||||
(res: { response: string; success: boolean }) => {
|
(res: { response: string; success: boolean }) => {
|
||||||
if (!res.success) {
|
console.log("Generated code", res.response, res.success);
|
||||||
toast.error("Failed to generate code.");
|
// if (!res.success) {
|
||||||
return;
|
// toast.error("Failed to generate code.");
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
setCode(res.response);
|
setCode(res.response);
|
||||||
router.refresh();
|
router.refresh();
|
||||||
@ -122,6 +126,14 @@ export default function GenerateInput({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={onClose}
|
||||||
|
variant="outline"
|
||||||
|
size="smIcon"
|
||||||
|
className="bg-transparent shrink-0 border-muted-foreground"
|
||||||
|
>
|
||||||
|
<X className="h-3 w-3" />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{expanded ? (
|
{expanded ? (
|
||||||
<>
|
<>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user