✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
feat: remove ai
AykutSarac258c5079eec8
diff --git a/src/components/PromptInput/index.tsx b/src/components/PromptInput/index.tsxdeleted file mode 100644index ecb9de8e..00000000--- a/src/components/PromptInput/index.tsx+++ /dev/null@@ -1,182 +0,0 @@-import React from "react";-import {- ActionIcon,- TextInput,- Text,- Loader,- Tooltip,- HoverCard,- Flex,- Badge,-} from "@mantine/core";-import { getHotkeyHandler } from "@mantine/hooks";-import styled from "styled-components";-import { FunctionsHttpError } from "@supabase/supabase-js";-import toast from "react-hot-toast";-import { GoDependabot } from "react-icons/go";-import { VscClose, VscQuestion } from "react-icons/vsc";-import useJsonQuery from "src/hooks/useJsonQuery";-import { supabase } from "src/lib/api/supabase";-import useConfig from "src/store/useConfig";-import useUser from "src/store/useUser";--const StyledPromptInput = styled(TextInput)`- .mantine-TextInput-wrapper {- margin-bottom: 0;- }- .mantine-TextInput-input {- font-weight: 500;- background: ${({ theme }) => theme.PROMPT_BG};- color: ${({ theme }) => theme.PROMPT_TEXT_COLOR};- border: none;- border-bottom: 1px solid- ${({ theme, error }) => (error ? theme.DANGER : theme.PROMPT_BORDER_COLOR)};-- :focus-within {- border-color: #15593a;- }- }-- .mantine-TextInput-error {- padding: 4px;- border-bottom: 1px solid ${({ theme }) => theme.DANGER};- background: #280000;- }-- svg {- color: ${({ theme }) => theme.PROMPT_TEXT_COLOR};- }-- ::placeholder {- color: ${({ theme }) => theme.PROMPT_PLACEHOLDER_COLOR} !important;- }-`;--export const PromptInput = () => {- const { updateJson, getJsonType } = useJsonQuery();- const premium = useUser(state => state.premium);- const [completing, setCompleting] = React.useState(false);- const [prompt, setPrompt] = React.useState("");- const promptVisible = useConfig(state => state.aiEnabled);- const [promptError, setPromptError] = React.useState<string | null>(null);-- const onSubmit = async () => {- try {- setPromptError(null);- setCompleting(true);- const jsonModel = await getJsonType();-- const { data, error } = await supabase.functions.invoke("jq", {- body: { query: prompt, jsonModel },- });-- if (error instanceof FunctionsHttpError) {- const errorMessage = await error.context.json();- throw Error(errorMessage.error);- }-- // extract jq command- const jqOutput = data.command;- const regex = /'([^']*)'/;- const match = jqOutput.match(regex);-- if (match && match[1]) {- const extractedString = match[1];- await updateJson(extractedString);- toast.success(`${data.credits} credits left for today.`);- } else {- throw Error("An error occured while parsing result.");- }- } catch (error: any) {- console.error(error);- if (error instanceof Error) setPromptError(error.message);- } finally {- setCompleting(false);- }- };-- if (!promptVisible) return null;-- return (- <Tooltip- disabled={premium}- w={400}- multiline- position="right"- label={- <Text fz="xs">- <Badge size="xs" radius={2}>- Alpha- </Badge>{" "}- JSON Crack AI is currently only available to premium users to test out. You may close this- from the settings.- </Text>- }- fz="xs"- withinPortal- withArrow- >- <div>- <StyledPromptInput- placeholder="Ask JSON Crack AI to transform the data"- value={prompt}- onChange={e => setPrompt(e.currentTarget.value)}- maxLength={200}- disabled={!premium || completing}- onKeyDown={getHotkeyHandler([["Enter", onSubmit]])}- onSubmit={onSubmit}- error={- promptError && (- <Flex align="center" justify="space-between">- {promptError}- <ActionIcon- size="xs"- variant="transparent"- title="Close Error"- onClick={() => setPromptError(null)}- >- <VscClose color="red" />- </ActionIcon>- </Flex>- )- }- rightSection={- <>- <HoverCard withArrow withinPortal>- <HoverCard.Target>- <ActionIcon variant="transparent">- <VscQuestion />- </ActionIcon>- </HoverCard.Target>- <HoverCard.Dropdown maw={300} fz="xs">- This feature is in the{" "}- <Badge size="xs" radius={2} variant="light">- alpha- </Badge>{" "}- phase, and its results may not always be accurate. Be cautious, as invalid actions- still consume a credit. We only process the schema of your data and DO NOT process- values.- <br />- <br />- You receive <b>10 credits</b> daily, and you have the option to deactivate this- feature in the settings located at the upper right corner of the editor.- <br />- <br />- Examples:- <li>- <code>Retrieve members whose names begin with "M"</code>- </li>- <li>- <code>Retrieve members with age older than 30</code>- </li>- </HoverCard.Dropdown>- </HoverCard>- </>- }- leftSection={completing ? <Loader size="xs" /> : <GoDependabot strokeWidth={1} />}- radius={0}- />- </div>- </Tooltip>- );-};diff --git a/src/containers/Editor/JsonEditor.tsx b/src/containers/Editor/JsonEditor.tsxindex 68c9e20d..63ea2575 100644--- a/src/containers/Editor/JsonEditor.tsx+++ b/src/containers/Editor/JsonEditor.tsx@@ -1,7 +1,6 @@import React from "react";import styled from "styled-components";import { MonacoEditor } from "src/components/MonacoEditor";-import { PromptInput } from "src/components/PromptInput";const StyledEditorWrapper = styled.div`display: flex;@@ -13,7 +12,6 @@ const StyledEditorWrapper = styled.div`export const JsonEditor: React.FC = () => {return (<StyledEditorWrapper>- <PromptInput /><MonacoEditor /></StyledEditorWrapper>);diff --git a/src/containers/Modals/SchemaModal/index.tsx b/src/containers/Modals/SchemaModal/index.tsxindex fb9eed08..07fbf0f1 100644--- a/src/containers/Modals/SchemaModal/index.tsx+++ b/src/containers/Modals/SchemaModal/index.tsx@@ -2,15 +2,11 @@ import React from "react";import { Stack, Modal, Button, ModalProps, Text, Anchor, Group, Divider } from "@mantine/core";import Editor from "@monaco-editor/react";import { toast } from "react-hot-toast";-import { VscLinkExternal, VscLock } from "react-icons/vsc";+import { VscLinkExternal } from "react-icons/vsc";import useConfig from "src/store/useConfig";import useFile from "src/store/useFile";-import useModal from "src/store/useModal";-import useUser from "src/store/useUser";export const SchemaModal: React.FC<ModalProps> = ({ opened, onClose }) => {- const isPremium = useUser(state => state.premium);- const showPremiumModal = useModal(state => state.setVisible("premium"));const setJsonSchema = useFile(state => state.setJsonSchema);const [schema, setSchema] = React.useState(JSON.stringify(@@ -34,8 +30,6 @@ export const SchemaModal: React.FC<ModalProps> = ({ opened, onClose }) => {const darkmodeEnabled = useConfig(state => (state.darkmodeEnabled ? "vs-dark" : "light"));const onApply = () => {- if (!isPremium) return showPremiumModal(true);-try {const parsedSchema = JSON.parse(schema);@@ -80,7 +74,7 @@ export const SchemaModal: React.FC<ModalProps> = ({ opened, onClose }) => {<Button variant="outline" onClick={onClear} disabled={!schema}>Clear</Button>- <Button onClick={onApply} disabled={!schema} rightSection={!isPremium && <VscLock />}>+ <Button onClick={onApply} disabled={!schema}>Apply</Button></Group>diff --git a/src/containers/Toolbar/OptionsMenu.tsx b/src/containers/Toolbar/OptionsMenu.tsxindex 0a828e96..4383349a 100644--- a/src/containers/Toolbar/OptionsMenu.tsx+++ b/src/containers/Toolbar/OptionsMenu.tsx@@ -1,5 +1,5 @@import React from "react";-import { Menu, Text, Flex, Badge } from "@mantine/core";+import { Menu, Text, Flex } from "@mantine/core";import { BsCheck2 } from "react-icons/bs";import { MdSettings } from "react-icons/md";import useConfig from "src/store/useConfig";@@ -12,7 +12,6 @@ export const OptionsMenu = () => {const toggleRulers = useConfig(state => state.toggleRulers);const toggleCollapseButton = useConfig(state => state.toggleCollapseButton);const toggleImagePreview = useConfig(state => state.toggleImagePreview);- const toggleAI = useConfig(state => state.toggleAI);const gesturesEnabled = useConfig(state => state.gesturesEnabled);const childrenCountVisible = useConfig(state => state.childrenCountVisible);@@ -20,7 +19,6 @@ export const OptionsMenu = () => {const rulersEnabled = useConfig(state => state.rulersEnabled);const collapseButtonVisible = useConfig(state => state.collapseButtonVisible);const imagePreviewEnabled = useConfig(state => state.imagePreviewEnabled);- const aiEnabled = useConfig(state => state.aiEnabled);return (<Menu shadow="md" trigger="click" closeOnItemClick={false} withArrow>@@ -68,17 +66,6 @@ export const OptionsMenu = () => {><Text size="xs">Dark Mode</Text></Menu.Item>- <Menu.Item- leftSection={<BsCheck2 opacity={aiEnabled ? 100 : 0} />}- onClick={() => toggleAI(!aiEnabled)}- >- <Flex align="center" gap={2}>- <Text size="xs">JSON Crack AI</Text>- <Badge ml={2} size="xs" variant="light" radius={2}>- Alpha- </Badge>- </Flex>- </Menu.Item></Menu.Dropdown></Menu>);diff --git a/src/store/useConfig.ts b/src/store/useConfig.tsindex d4fa3ef5..898bd66f 100644--- a/src/store/useConfig.ts+++ b/src/store/useConfig.ts@@ -12,7 +12,6 @@ const initialStates = {gesturesEnabled: false,rulersEnabled: true,viewMode: ViewMode.Graph,- aiEnabled: true,};export interface ConfigActions {@@ -24,14 +23,12 @@ export interface ConfigActions {toggleGestures: (value: boolean) => void;toggleRulers: (value: boolean) => void;setViewMode: (value: ViewMode) => void;- toggleAI: (value: boolean) => void;}const useConfig = create(persist<typeof initialStates & ConfigActions>(set => ({...initialStates,- toggleAI: aiEnabled => set({ aiEnabled }),toggleRulers: rulersEnabled => set({ rulersEnabled }),toggleGestures: gesturesEnabled => set({ gesturesEnabled }),toggleLiveTransform: liveTransformEnabled => set({ liveTransformEnabled }),