Public
Back
Version 2
9/1/2024
/**
* This val creates a text editing tool using the Cerebras Llama 70B model.
* It includes a command input field and a rich text editor.
* The user's command and current text are sent to the Cerebras API,
* which returns the modified text to be displayed in the editor.
* We'll use React for the UI and the Cerebras API for text processing.
*/
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useRef, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
import ReactQuill from "https://esm.sh/react-quill";
function App() {
const [command, setCommand] = useState("");
const [editorContent, setEditorContent] = useState("");
const [isLoading, setIsLoading] = useState(false);
const [success, setSuccess] = useState(false);
const quillRef = useRef(null);
const handleSubmit = async (e) => {
e.preventDefault();
setIsLoading(true);
setSuccess(false);
try {
const response = await fetch("/process", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ command, text: editorContent }),
});
if (response.ok) {
const result = await response.json();
setEditorContent(result.modifiedText);
setSuccess(true);
sharanbabu-aitexteditor.web.val.run
Updated: September 7, 2024