From 09ede240960224bf7c484c31ed242d975b95f356 Mon Sep 17 00:00:00 2001 From: Miao Zhuang <1060950782@163.com> Date: Wed, 6 Dec 2023 14:52:30 +0800 Subject: [PATCH] fix: prompt & bugs (#699) * fix: prompt & bugs * fix: workflow --- .github/workflows/build.yml | 2 +- app/components/Breadcrumb/index.tsx | 1 + app/components/FileConfigSetting/index.tsx | 6 ++--- app/components/MonacoEditor/index.tsx | 23 ++++++++++--------- app/pages/Console/Drawer/NgqlDrawer.tsx | 2 +- app/pages/Console/Drawer/SchemaDrawer.tsx | 2 +- app/pages/Console/index.tsx | 10 ++++---- app/pages/Import/AIImport/Create.tsx | 20 ++++++++-------- .../PlatformConfig/S3ConfigForm.tsx | 2 +- app/pages/Import/DatasourceList/index.tsx | 2 +- app/pages/Import/TaskCreate/index.tsx | 2 +- .../Import/TaskList/TaskItem/AIImportItem.tsx | 2 +- app/pages/Import/TaskList/index.tsx | 2 +- app/pages/Import/index.tsx | 2 +- app/pages/LLMBot/chat.tsx | 4 ++-- app/pages/LLMBot/index.tsx | 12 +++++----- app/pages/MainPage/index.tsx | 2 +- .../SchemaConfig/List/CommonLayout/index.tsx | 2 +- app/pages/Schema/SpaceCreate/CreateForm.tsx | 2 +- app/pages/Setting/index.tsx | 4 ++-- .../Plugins/SketchShapes/Path.tsx | 1 + .../Plugins/SketchShapes/Shapers.tsx | 2 +- app/stores/console.ts | 2 +- app/stores/llm.ts | 18 +++++++-------- app/utils/ngql.ts | 2 +- app/utils/websocket.ts | 2 +- package-lock.json | 14 +++++------ package.json | 2 +- server/api/studio/pkg/llm/importjob.go | 9 ++++++++ server/api/studio/pkg/llm/schedule.go | 11 ++++++++- server/api/studio/pkg/pdf/reader.go | 1 + 31 files changed, 96 insertions(+), 72 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65fac136..10321618 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: path: source/nebula-graph-studio - uses: actions/setup-go@v2 with: - go-version: '^1.18.7' + go-version: '^1.21' - uses: actions/setup-node@v2 with: node-version: '16' diff --git a/app/components/Breadcrumb/index.tsx b/app/components/Breadcrumb/index.tsx index 7d8ac36f..410af212 100644 --- a/app/components/Breadcrumb/index.tsx +++ b/app/components/Breadcrumb/index.tsx @@ -1,6 +1,7 @@ import { useCallback } from 'react'; import { Link } from 'react-router-dom'; import { Breadcrumb } from 'antd'; +// eslint-disable-next-line no-duplicate-imports import type { BreadcrumbProps } from 'antd'; import { PageHeader } from '@ant-design/pro-layout'; import cls from 'classnames'; diff --git a/app/components/FileConfigSetting/index.tsx b/app/components/FileConfigSetting/index.tsx index 24b17237..96ea9548 100644 --- a/app/components/FileConfigSetting/index.tsx +++ b/app/components/FileConfigSetting/index.tsx @@ -66,7 +66,7 @@ const FileConfigSetting = (props: IProps) => { const readFile = useCallback( debounce(() => { const { activeItem, setState } = state; - if (!activeItem || !(activeItem.path.indexOf('.csv') > -1)) return; + if (!activeItem || !(activeItem.name.indexOf('.csv') > -1)) return; setState({ loading: true }); let content = []; if (activeItem.sample !== undefined) { @@ -230,7 +230,7 @@ const FileConfigSetting = (props: IProps) => { key: 'withHeader', width: '30%', render: (record) => - record.path.indexOf('.csv') > -1 && ( + record.name.indexOf('.csv') > -1 && ( updateItem(e, record)}> {intl.get('import.hasHeader')} @@ -253,7 +253,7 @@ const FileConfigSetting = (props: IProps) => { key: 'delimiter', width: '30%', render: (record) => - record.path.indexOf('.csv') > -1 && ( + record.name.indexOf('.csv') > -1 && ( updateDelimiter(e, record)} /> ), }, diff --git a/app/components/MonacoEditor/index.tsx b/app/components/MonacoEditor/index.tsx index eedb69f5..f4825d45 100644 --- a/app/components/MonacoEditor/index.tsx +++ b/app/components/MonacoEditor/index.tsx @@ -1,4 +1,5 @@ import { useCallback, useEffect, useMemo, useRef } from 'react'; +// eslint-disable-next-line import/no-extraneous-dependencies import * as monaco from 'monaco-editor'; import type { editor as TMonacoEditor } from 'monaco-editor'; import Editor, { useMonaco, loader, type Monaco } from '@monaco-editor/react'; @@ -109,7 +110,7 @@ const MonacoEditor = (props: IProps) => { edges, propertyReference, tokenizer: { - //@ts-ignore + // @ts-ignore root: [ ...createSchemaRegex(patterns, regexFormat(tags), 'tag'), ...createSchemaRegex(patterns, regexFormat(edges), 'edge'), @@ -130,7 +131,7 @@ const MonacoEditor = (props: IProps) => { }); // register a completion item provider for keywords const keywordProvider = monaco?.languages.registerCompletionItemProvider('ngql', { - //@ts-ignore + // @ts-ignore provideCompletionItems: () => { const suggestions = [ ...nebulaWordsUppercase.map((k) => ({ @@ -141,11 +142,11 @@ const MonacoEditor = (props: IProps) => { sortText: '1', // monaco completion suggestions sort by sortText, 1: keyword 2: tag 3: edge 4: field 5: function })), ]; - return { suggestions: suggestions }; + return { suggestions }; }, }); const parameterProvider = monaco?.languages.registerCompletionItemProvider('ngql', { - //@ts-ignore + // @ts-ignore provideCompletionItems: () => { const suggestions = [ ...parameterDeclaration.map((k) => ({ @@ -155,13 +156,13 @@ const MonacoEditor = (props: IProps) => { sortText: '5', })), ]; - return { suggestions: suggestions }; + return { suggestions }; }, triggerCharacters: [':'], }); const propertyReferenceProvider = monaco?.languages.registerCompletionItemProvider('ngql', { - //@ts-ignore + // @ts-ignore provideCompletionItems: () => { const suggestions = [ ...propertyReference.map((k) => ({ @@ -171,13 +172,13 @@ const MonacoEditor = (props: IProps) => { sortText: '1', // monaco completion suggestions sort by sortText, 1: keyword 2: tag 3: edge 4: field 5: function })), ]; - return { suggestions: suggestions }; + return { suggestions }; }, triggerCharacters: ['$'], }); // register a completion item provider for tags and edges, can trigger by ':' and '.' const schemaInfoProvider = monaco?.languages.registerCompletionItemProvider('ngql', { - //@ts-ignore + // @ts-ignore provideCompletionItems: () => { const suggestions = [ ...tags.map((k: string) => ({ @@ -209,7 +210,7 @@ const MonacoEditor = (props: IProps) => { const regex = /^properties\(.*\)$/g; // match properties() // register a completion item provider for fields, can trigger by '.' const schemaInfoTriggerProvider = monaco?.languages.registerCompletionItemProvider('ngql', { - //@ts-ignore + // @ts-ignore provideCompletionItems: (model, position) => { const textUntilPosition = model.getValueInRange({ startLineNumber: position.lineNumber, @@ -236,7 +237,7 @@ const MonacoEditor = (props: IProps) => { }); // register a completion item provider for functions const funcProvider = monaco?.languages.registerCompletionItemProvider('ngql', { - //@ts-ignore + // @ts-ignore provideCompletionItems: () => { const suggestions = nebulaFunction.map((f) => ({ label: `${f}()`, @@ -271,7 +272,7 @@ const MonacoEditor = (props: IProps) => { useEffect(() => { if (!monaco) return; const languages = monaco.languages.getLanguages(); - if (languages.some((i) => i.id == 'ngql')) return; + if (languages.some((i) => i.id === 'ngql')) return; monaco?.languages.register({ id: 'ngql' }); monaco?.editor.defineTheme('studio', { base: 'vs', diff --git a/app/pages/Console/Drawer/NgqlDrawer.tsx b/app/pages/Console/Drawer/NgqlDrawer.tsx index ea2f18a7..bfd03301 100644 --- a/app/pages/Console/Drawer/NgqlDrawer.tsx +++ b/app/pages/Console/Drawer/NgqlDrawer.tsx @@ -10,7 +10,7 @@ const isIncluded = (a: string, b: string) => { return a.toLowerCase().includes(b.toLowerCase()); }; -//TODO modify the content +// TODO modify the content const Doc = [ { title: diff --git a/app/pages/Console/Drawer/SchemaDrawer.tsx b/app/pages/Console/Drawer/SchemaDrawer.tsx index cbfbb735..d65566b7 100644 --- a/app/pages/Console/Drawer/SchemaDrawer.tsx +++ b/app/pages/Console/Drawer/SchemaDrawer.tsx @@ -2,10 +2,10 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { Input, Tree } from 'antd'; import { observer } from 'mobx-react-lite'; import { useStore } from '@app/stores'; -import styles from './index.module.less'; import Icon from '@app/components/Icon'; import { DownOutlined, SearchOutlined } from '@ant-design/icons'; import { useI18n } from '@vesoft-inc/i18n'; +import styles from './index.module.less'; const isIncluded = (a: string, b: string) => { return a.toLowerCase().includes(b.toLowerCase()); diff --git a/app/pages/Console/index.tsx b/app/pages/Console/index.tsx index 59d085f7..93efa400 100644 --- a/app/pages/Console/index.tsx +++ b/app/pages/Console/index.tsx @@ -9,6 +9,8 @@ import Icon from '@app/components/Icon'; import MonacoEditor from '@app/components/MonacoEditor'; import { useI18n } from '@vesoft-inc/i18n'; import { safeParse } from '@app/utils/function'; +import { SchemaItemOverview } from '@app/stores/console'; +import LLMBot from '../LLMBot'; import OutputBox from './OutputBox'; import HistoryBtn from './HistoryBtn'; import FavoriteBtn from './FavoriteBtn'; @@ -17,8 +19,6 @@ import ExportModal from './ExportModal'; import SchemaDrawer from './Drawer/SchemaDrawer'; // import NgqlDrawer from './Drawer/NgqlDrawer'; import styles from './index.module.less'; -import { SchemaItemOverview } from '@app/stores/console'; -import LLMBot from '../LLMBot'; const Option = Select.Option; @@ -171,7 +171,7 @@ const Console = (props: IProps) => { }), ]; return { - suggestions: suggestions, + suggestions, dispose: () => { const line = position.lineNumber; const column = position.column; @@ -192,7 +192,7 @@ const Console = (props: IProps) => { const onInstanceMount = (instance, monaco) => { editor.current = { editor: instance, - monaco: monaco, + monaco, }; instance.addAction({ id: 'my-unique-id', @@ -202,7 +202,7 @@ const Console = (props: IProps) => { // ], contextMenuGroupId: 'myMenu', contextMenuOrder: 1.5, - run: function () { + run() { const _editor = editor.current.editor; let value = ''; const selection = _editor.getSelection(); diff --git a/app/pages/Import/AIImport/Create.tsx b/app/pages/Import/AIImport/Create.tsx index 4a43e0dd..8d5a6337 100644 --- a/app/pages/Import/AIImport/Create.tsx +++ b/app/pages/Import/AIImport/Create.tsx @@ -2,12 +2,12 @@ import { useStore } from '@app/stores'; import { useI18n } from '@vesoft-inc/i18n'; import { Button, Form, Input, Modal, Radio, Select, message } from 'antd'; import { observer } from 'mobx-react-lite'; -import styles from './index.module.less'; import Icon from '@app/components/Icon'; import { useEffect, useMemo, useState } from 'react'; import { llmImportPrompt } from '@app/stores/llm'; import { getByteLength } from '@app/utils/function'; import { post } from '@app/utils/http'; +import styles from './index.module.less'; const Create = observer((props: { visible: boolean; onCancel: () => void }) => { const { llm, schema, files } = useStore(); @@ -91,7 +91,7 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => { {intl.get('llm.setup')} - +
{intl.get('llm.confirm')} @@ -103,7 +103,7 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => { {Math.ceil(tokens / 10000)}w
)} -
+ {llm.config.features.includes('aiImportFilePath') && ( @@ -128,7 +128,7 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => { }} > {fileList.map((item) => ( - + {item.name} ))} @@ -143,7 +143,9 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => { @@ -155,7 +157,7 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => { -
+ {valuse.file} @@ -165,13 +167,13 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => {
- {step == 1 && } - {step == 0 && ( + {step === 1 && } + {step === 0 && ( )} - {step == 1 && ( + {step === 1 && ( diff --git a/app/pages/Import/DatasourceList/DatasourceConfig/PlatformConfig/S3ConfigForm.tsx b/app/pages/Import/DatasourceList/DatasourceConfig/PlatformConfig/S3ConfigForm.tsx index f0360bd0..245fa57f 100644 --- a/app/pages/Import/DatasourceList/DatasourceConfig/PlatformConfig/S3ConfigForm.tsx +++ b/app/pages/Import/DatasourceList/DatasourceConfig/PlatformConfig/S3ConfigForm.tsx @@ -4,8 +4,8 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { observer } from 'mobx-react-lite'; import { ES3Platform } from '@app/interfaces/datasource'; import Instruction from '@app/components/Instruction'; -import styles from './index.module.less'; import { useStore } from '@app/stores'; +import styles from './index.module.less'; const FormItem = Form.Item; interface IProps { formRef: FormInstance; diff --git a/app/pages/Import/DatasourceList/index.tsx b/app/pages/Import/DatasourceList/index.tsx index c47e9909..e88052aa 100644 --- a/app/pages/Import/DatasourceList/index.tsx +++ b/app/pages/Import/DatasourceList/index.tsx @@ -2,10 +2,10 @@ import { observer } from 'mobx-react-lite'; import { Tabs, TabsProps } from 'antd'; import { useI18n } from '@vesoft-inc/i18n'; import { IDatasourceType } from '@app/interfaces/datasource'; +import { useStore } from '@app/stores'; import LocalFileList from './LocalFileList'; import RemoteList from './RemoteList'; import styles from './index.module.less'; -import { useStore } from '@app/stores'; const DatasourceList = () => { const { intl } = useI18n(); diff --git a/app/pages/Import/TaskCreate/index.tsx b/app/pages/Import/TaskCreate/index.tsx index 8863d229..1b6060b4 100644 --- a/app/pages/Import/TaskCreate/index.tsx +++ b/app/pages/Import/TaskCreate/index.tsx @@ -13,10 +13,10 @@ import Icon from '@app/components/Icon'; import Instruction from '@app/components/Instruction'; import { isEmpty } from '@app/utils/function'; import { ImportStore } from '@app/stores/import'; +import { IDatasourceType } from '@app/interfaces/datasource'; import styles from './index.module.less'; import ConfigConfirmModal from './ConfigConfirmModal'; import SchemaConfig from './SchemaConfig'; -import { IDatasourceType } from '@app/interfaces/datasource'; const Option = Select.Option; const formItemLayout = { wrapperCol: { diff --git a/app/pages/Import/TaskList/TaskItem/AIImportItem.tsx b/app/pages/Import/TaskList/TaskItem/AIImportItem.tsx index de6d2626..fd9ded8a 100644 --- a/app/pages/Import/TaskList/TaskItem/AIImportItem.tsx +++ b/app/pages/Import/TaskList/TaskItem/AIImportItem.tsx @@ -6,9 +6,9 @@ import { getFileSize } from '@app/utils/file'; import Icon from '@app/components/Icon'; import { useI18n } from '@vesoft-inc/i18n'; import { observer } from 'mobx-react-lite'; -import styles from './index.module.less'; import { _delete, post } from '@app/utils/http'; import React from 'react'; +import styles from './index.module.less'; interface IProps { data: ITaskItem; onViewLog: (data: ITaskItem) => void; diff --git a/app/pages/Import/TaskList/index.tsx b/app/pages/Import/TaskList/index.tsx index 7c795d2d..e2b449ad 100644 --- a/app/pages/Import/TaskList/index.tsx +++ b/app/pages/Import/TaskList/index.tsx @@ -8,11 +8,11 @@ import { trackPageView } from '@app/utils/stat'; import { ITaskItem, ITaskStatus } from '@app/interfaces/import'; import { useI18n } from '@vesoft-inc/i18n'; import DatasourceConfigModal from '../DatasourceList/DatasourceConfig/PlatformConfig'; +import Create from '../AIImport/Create'; import LogModal from './TaskItem/LogModal'; import TemplateModal from './TemplateModal'; import styles from './index.module.less'; import TaskItem from './TaskItem'; -import Create from '../AIImport/Create'; import AIImportItem, { ILLMStatus } from './TaskItem/AIImportItem'; const Option = Select.Option; diff --git a/app/pages/Import/index.tsx b/app/pages/Import/index.tsx index b0a1cb94..514ffaab 100644 --- a/app/pages/Import/index.tsx +++ b/app/pages/Import/index.tsx @@ -4,10 +4,10 @@ import { Route, useHistory, useLocation } from 'react-router-dom'; import { trackPageView } from '@app/utils/stat'; import cls from 'classnames'; import { useI18n } from '@vesoft-inc/i18n'; +import llm from '@app/stores/llm'; import DatasourceList from './DatasourceList'; import styles from './index.module.less'; import TaskList from './TaskList'; -import llm from '@app/stores/llm'; const Import = () => { const history = useHistory(); diff --git a/app/pages/LLMBot/chat.tsx b/app/pages/LLMBot/chat.tsx index 4e25f595..2aaf01eb 100644 --- a/app/pages/LLMBot/chat.tsx +++ b/app/pages/LLMBot/chat.tsx @@ -1,5 +1,4 @@ import { Button, Input } from 'antd'; -import styles from './chat.module.less'; import { useEffect, useRef, useState } from 'react'; import ws from '@app/utils/websocket'; import { debounce } from 'lodash'; @@ -8,6 +7,7 @@ import { observer } from 'mobx-react-lite'; import { useI18n } from '@vesoft-inc/i18n'; import { LoadingOutlined } from '@ant-design/icons'; import MonacoEditor from '@app/components/MonacoEditor'; +import styles from './chat.module.less'; function Chat() { const { intl } = useI18n(); @@ -149,7 +149,7 @@ function Chat() { return (
{renderContent(item)}
diff --git a/app/pages/LLMBot/index.tsx b/app/pages/LLMBot/index.tsx index 453fa4d6..8ff9665c 100644 --- a/app/pages/LLMBot/index.tsx +++ b/app/pages/LLMBot/index.tsx @@ -1,13 +1,13 @@ import { Popover, Switch } from 'antd'; -import styles from './index.module.less'; -import Chat from './chat'; import Icon from '@app/components/Icon'; import { observer } from 'mobx-react-lite'; import { useStore } from '@app/stores'; +import Chat from './chat'; +import styles from './index.module.less'; // float llm bot window function LLMBot() { const { global, llm } = useStore(); - if (global.appSetting?.beta?.open && global.appSetting?.beta?.functions?.text2query.open != true) { + if (!global.appSetting?.beta?.open || global.appSetting?.beta?.functions?.text2query?.open !== true) { return null; } const { open } = llm; @@ -36,7 +36,7 @@ function LLMBot() { mode: checked ? 'text2cypher' : 'text2ngql', }); }} - checked={llm.mode == 'text2cypher'} + checked={llm.mode === 'text2cypher'} />
@@ -56,8 +56,8 @@ function LLMBot() { - - + + diff --git a/app/pages/MainPage/index.tsx b/app/pages/MainPage/index.tsx index 6f1e4d76..2773059e 100644 --- a/app/pages/MainPage/index.tsx +++ b/app/pages/MainPage/index.tsx @@ -1,4 +1,4 @@ -import { Suspense, useEffect } from 'react'; +import { Suspense } from 'react'; import { Layout, Spin } from 'antd'; import { Redirect, Route, Switch } from 'react-router-dom'; import { shouldAlwaysShowWelcome } from '@app/pages/Welcome'; diff --git a/app/pages/Schema/SchemaConfig/List/CommonLayout/index.tsx b/app/pages/Schema/SchemaConfig/List/CommonLayout/index.tsx index e0004a2c..d57d2bd7 100644 --- a/app/pages/Schema/SchemaConfig/List/CommonLayout/index.tsx +++ b/app/pages/Schema/SchemaConfig/List/CommonLayout/index.tsx @@ -6,9 +6,9 @@ import { observer } from 'mobx-react-lite'; import Icon from '@app/components/Icon'; import EmptyTableTip from '@app/components/EmptyTableTip'; import { IndexType } from '@app/interfaces/schema'; +import cls from 'classnames'; import Search from '../Search'; import styles from './index.module.less'; -import cls from 'classnames'; interface IProps { onSearch: (value) => void; diff --git a/app/pages/Schema/SpaceCreate/CreateForm.tsx b/app/pages/Schema/SpaceCreate/CreateForm.tsx index ab921de4..3fe920a6 100644 --- a/app/pages/Schema/SpaceCreate/CreateForm.tsx +++ b/app/pages/Schema/SpaceCreate/CreateForm.tsx @@ -4,8 +4,8 @@ import { useStore } from '@app/stores'; import { nameRulesFn, numberRulesFn, replicaRulesFn, stringByteRulesFn } from '@app/config/rules'; import { useI18n } from '@vesoft-inc/i18n'; import { DEFAULT_PARTITION_NUM } from '@app/utils/constant'; -import styles from './index.module.less'; import { observer } from 'mobx-react-lite'; +import styles from './index.module.less'; const Option = Select.Option; const defaultFormItemLayout = { diff --git a/app/pages/Setting/index.tsx b/app/pages/Setting/index.tsx index c645aac0..d3f66170 100644 --- a/app/pages/Setting/index.tsx +++ b/app/pages/Setting/index.tsx @@ -5,10 +5,10 @@ import { useI18n } from '@vesoft-inc/i18n'; import { useStore } from '@app/stores'; // import LanguageSelect from '@app/components/LanguageSelect'; import { trackEvent } from '@app/utils/stat'; -import styles from './index.module.less'; -import LanguageSelect from '../Login/LanguageSelect'; import { useForm } from 'antd/lib/form/Form'; import { post } from '@app/utils/http'; +import LanguageSelect from '../Login/LanguageSelect'; +import styles from './index.module.less'; const Setting = observer(() => { const { intl } = useI18n(); diff --git a/app/pages/SketchModeling/Plugins/SketchShapes/Path.tsx b/app/pages/SketchModeling/Plugins/SketchShapes/Path.tsx index 261eccdd..51dd6024 100644 --- a/app/pages/SketchModeling/Plugins/SketchShapes/Path.tsx +++ b/app/pages/SketchModeling/Plugins/SketchShapes/Path.tsx @@ -198,6 +198,7 @@ const Path: LineRender = { width={width} height={20} textAnchor="middle" + // eslint-disable-next-line react/no-unknown-property transform-origin={`${x} ${y}`} style={{ transform: `rotate(${angle}deg)` }} > diff --git a/app/pages/SketchModeling/Plugins/SketchShapes/Shapers.tsx b/app/pages/SketchModeling/Plugins/SketchShapes/Shapers.tsx index 57414782..18e573e1 100644 --- a/app/pages/SketchModeling/Plugins/SketchShapes/Shapers.tsx +++ b/app/pages/SketchModeling/Plugins/SketchShapes/Shapers.tsx @@ -4,9 +4,9 @@ import { InstanceNode } from '@vesoft-inc/veditor/types/Shape/Node'; import { createRoot } from 'react-dom/client'; import { ISchemaEnum } from '@app/interfaces/schema'; import { NODE_RADIUS } from '@app/config/sketch'; +import { flushSync } from 'react-dom'; import Path from './Path'; import styles from './index.module.less'; -import { flushSync } from 'react-dom'; export default function initShapes(editor: VEditor) { const node = { ...DefaultNode.default, diff --git a/app/stores/console.ts b/app/stores/console.ts index 95c7cdd5..a15c3be4 100644 --- a/app/stores/console.ts +++ b/app/stores/console.ts @@ -6,8 +6,8 @@ import { debounce } from 'lodash'; import { getI18n } from '@vesoft-inc/i18n'; import { safeParse } from '@app/utils/function'; import { NgqlRes } from '@app/utils/websocket'; -import { getRootStore } from '.'; import { IField } from '@app/interfaces/schema'; +import { getRootStore } from '.'; const { intl } = getI18n(); diff --git a/app/stores/llm.ts b/app/stores/llm.ts index a81b0145..47ae08b1 100644 --- a/app/stores/llm.ts +++ b/app/stores/llm.ts @@ -1,10 +1,10 @@ import { makeAutoObservable } from 'mobx'; -import schema from './schema'; import { get } from '@app/utils/http'; -import rootStore from '.'; import ws from '@app/utils/websocket'; import { safeParse } from '@app/utils/function'; import * as ngqlDoc from '@app/utils/ngql'; +import schema from './schema'; +import rootStore from '.'; export const matchPrompt = `Use NebulaGraph match knowledge to help me answer question. Use only the provided relationship types and properties in the schema. @@ -27,22 +27,22 @@ diff > RETURN p.person.name; Question:{query_str} `; -export const llmImportPrompt = `As a knowledge graph expert, your task is to extract relationship data from the following text: ----- +export const llmImportPrompt = `As a knowledge graph AI importer, your task is to extract relationship data from the following text: +----text {text} ---- Please proceed according to the schema of the knowledge graph: ----- +----graph schema {spaceSchema} ---- -Return the results directly, without interpretation. The results should be in the following JSON format: +Return the results directly, without explain and comment. The results should be in the following JSON format: { "nodes":[{ "name":string,"type":string,"props":object }], "edges":[{ "src":string,"dst":string,"edgeType":string,"props":object }] } -The result is: +Result: `; export const llmImportTask = `please excute the task below,and return the result,dont' explain,just return the result directly. { @@ -101,7 +101,7 @@ class LLM { fetchConfig() { return get('/api/config/llm')().then((res) => { - if (res.code != 0 || !res.data) return; + if (res.code !== 0 || !res.data) return; const { config, ...values } = res.data.config; const configMap = config ? safeParse(config) : {}; this.setConfig({ @@ -236,7 +236,7 @@ class LLM { const firstToken = tokens.find((item) => item.replaceAll(' ', '').length > 0); const hits = ngqlDoc.ngqlDoc.filter((each) => each.title.toLowerCase().indexOf(firstToken.toLowerCase()) === 0); let doc = ''; - if (this.mode == 'text2cypher' && firstToken.toLowerCase() == 'match') { + if (this.mode === 'text2cypher' && firstToken.toLowerCase() === 'match') { doc += matchPrompt; } else { if (hits.length) { diff --git a/app/utils/ngql.ts b/app/utils/ngql.ts index bccada9c..dd7c6881 100644 --- a/app/utils/ngql.ts +++ b/app/utils/ngql.ts @@ -23,7 +23,7 @@ export const ngqlMap = ngqlDoc.reduce((acc, item) => { acc[item.title.toLowerCase()] = item; return acc; }); -//@ts-ignore +// @ts-ignore window.ngqlMap = ngqlMap; export const NGQLCategoryString = ngqlDoc .filter((item) => item.url.indexOf('ngql-guide') >= 0) diff --git a/app/utils/websocket.ts b/app/utils/websocket.ts index 04976370..51498d87 100644 --- a/app/utils/websocket.ts +++ b/app/utils/websocket.ts @@ -331,7 +331,7 @@ export class NgqlRunner { config, msgType: 'llm', }); - config['notClear'] = true; + config.notClear = true; this.socket.send(JSON.stringify(messageReceiver.messageSend)); this.messageReceiverMap.set(messageReceiver.messageSend.header.msgId, messageReceiver); diff --git a/package-lock.json b/package-lock.json index ee162565..c531c70a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,7 +72,7 @@ "eslint": "^8.41.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.4.1", + "eslint-plugin-react-refresh": "^0.4.5", "husky": "^8.0.3", "less": "^4.1.1", "postcss": "^8.4.12", @@ -3635,9 +3635,9 @@ } }, "node_modules/eslint-plugin-react-refresh": { - "version": "0.4.1", - "resolved": "https://registry.npmmirror.com/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.1.tgz", - "integrity": "sha512-QgrvtRJkmV+m4w953LS146+6RwEe5waouubFVNLBfOjXJf6MLczjymO8fOcKj9jMS8aKkTCMJqiPu2WEeFI99A==", + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.5.tgz", + "integrity": "sha512-D53FYKJa+fDmZMtriODxvhwrO+IOqrxoEo21gMA0sjHdU6dPVH4OhyFip9ypl8HOF5RV5KdTo+rBQLvnY2cO8w==", "dev": true, "peerDependencies": { "eslint": ">=7" @@ -11945,9 +11945,9 @@ "requires": {} }, "eslint-plugin-react-refresh": { - "version": "0.4.1", - "resolved": "https://registry.npmmirror.com/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.1.tgz", - "integrity": "sha512-QgrvtRJkmV+m4w953LS146+6RwEe5waouubFVNLBfOjXJf6MLczjymO8fOcKj9jMS8aKkTCMJqiPu2WEeFI99A==", + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.5.tgz", + "integrity": "sha512-D53FYKJa+fDmZMtriODxvhwrO+IOqrxoEo21gMA0sjHdU6dPVH4OhyFip9ypl8HOF5RV5KdTo+rBQLvnY2cO8w==", "dev": true, "requires": {} }, diff --git a/package.json b/package.json index fce246da..03c8c070 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "eslint": "^8.41.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.4.1", + "eslint-plugin-react-refresh": "^0.4.5", "husky": "^8.0.3", "less": "^4.1.1", "postcss": "^8.4.12", diff --git a/server/api/studio/pkg/llm/importjob.go b/server/api/studio/pkg/llm/importjob.go index 2e8e1a6c..7874d996 100644 --- a/server/api/studio/pkg/llm/importjob.go +++ b/server/api/studio/pkg/llm/importjob.go @@ -283,18 +283,27 @@ func (i *ImportJob) ParseSchema(text string) error { } i.Schema = schema i.SchemaMap = make(map[string]map[string]Field) + nodeSchemaString := "" + edgeSchemaString := "" for _, tag := range schema.NodeTypes { + nodeSchemaString += fmt.Sprintf("NodeType \"%s\" {", tag.Type) i.SchemaMap[tag.Type] = make(map[string]Field) for _, field := range tag.Props { i.SchemaMap[tag.Type][field.Name] = field + nodeSchemaString += fmt.Sprintf("\"%s\":%s ", field.Name, field.DataType) } + nodeSchemaString += "}\n" } for _, edge := range schema.EdgeTypes { + edgeSchemaString += fmt.Sprintf("EdgeType \"%s\" { ", edge.Type) i.SchemaMap[edge.Type] = make(map[string]Field) for _, field := range edge.Props { i.SchemaMap[edge.Type][field.Name] = field + edgeSchemaString += fmt.Sprintf("\"%s\":%s ", field.Name, field.DataType) } + edgeSchemaString += "}\n" } + i.LLMJob.SpaceSchemaString = nodeSchemaString + edgeSchemaString return nil } diff --git a/server/api/studio/pkg/llm/schedule.go b/server/api/studio/pkg/llm/schedule.go index bc362623..77647e18 100644 --- a/server/api/studio/pkg/llm/schedule.go +++ b/server/api/studio/pkg/llm/schedule.go @@ -1,8 +1,10 @@ package llm import ( + "os" "time" + "github.com/vesoft-inc/nebula-studio/server/api/studio/internal/config" db "github.com/vesoft-inc/nebula-studio/server/api/studio/internal/model" ) @@ -10,7 +12,14 @@ type LLMJob = db.LLMJob type LLMConfig = db.LLMConfig func InitSchedule() { - // TODO + gqlPath := config.GetConfig().LLM.GQLPath + if gqlPath != "" { + // mkdir gqlPath + err := os.MkdirAll(gqlPath, 0755) + if err != nil { + panic(err) + } + } for { jobs := GetPendingJobs() RunJobs(jobs, map[string]func(job *db.LLMJob){ diff --git a/server/api/studio/pkg/pdf/reader.go b/server/api/studio/pkg/pdf/reader.go index c00c8cb5..0ecbb530 100644 --- a/server/api/studio/pkg/pdf/reader.go +++ b/server/api/studio/pkg/pdf/reader.go @@ -61,6 +61,7 @@ func ReadPDFFile(filePath string) (string, error) { regex := regexp.MustCompile(`(\n(\n|\s){1,})|\.{6,}`) text.S = regex.ReplaceAllString(text.S, "\n") text.S = strings.ReplaceAll(text.S, "�", " ") + text.S = strings.Trim(text.S, " ") if len(text.S) == 0 || text.S == " " { continue }