UNPKG

lexical-ai-plugin

Version:

This plugin is built to be used with Cloudflare Workers. In order to use this plugin, deploy this [Code](https://github.com/akadotsh/lexical-ai-worker) to Cloudflare.

46 lines (40 loc) 726 B
import axios from "axios"; export const options = [ { name: "shorten", value: ["shorten"], }, { name: "summarize", value: ["summarize"], }, { name: "simplify", value: ["simplify"], }, { name: "Splelling & Grammar", value: ["spelling", "grammar"], }, ]; export const handleAIRequest = async ( workerUrl: string, text: string, options: Array<string> ) => { if (!workerUrl || !text) return; const response = await axios(workerUrl, { method: "POST", headers: { "Content-Type": "application/json", }, data: JSON.stringify({ text, options, }), }); if (response.status === 200) { return response.data; } return text; };