Skip to content

Commit

Permalink
fix: prompt & bugs (#699)
Browse files Browse the repository at this point in the history
* fix: prompt & bugs

* fix: workflow
  • Loading branch information
mizy authored Dec 6, 2023
1 parent b0c3b17 commit 09ede24
Show file tree
Hide file tree
Showing 31 changed files with 96 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions app/components/Breadcrumb/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
6 changes: 3 additions & 3 deletions app/components/FileConfigSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -230,7 +230,7 @@ const FileConfigSetting = (props: IProps) => {
key: 'withHeader',
width: '30%',
render: (record) =>
record.path.indexOf('.csv') > -1 && (
record.name.indexOf('.csv') > -1 && (
<Checkbox checked={record.withHeader} onChange={(e) => updateItem(e, record)}>
{intl.get('import.hasHeader')}
</Checkbox>
Expand All @@ -253,7 +253,7 @@ const FileConfigSetting = (props: IProps) => {
key: 'delimiter',
width: '30%',
render: (record) =>
record.path.indexOf('.csv') > -1 && (
record.name.indexOf('.csv') > -1 && (
<Input value={record.delimiter} placeholder="," onChange={(e) => updateDelimiter(e, record)} />
),
},
Expand Down
23 changes: 12 additions & 11 deletions app/components/MonacoEditor/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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'),
Expand All @@ -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) => ({
Expand All @@ -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) => ({
Expand All @@ -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) => ({
Expand All @@ -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) => ({
Expand Down Expand Up @@ -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,
Expand All @@ -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}()`,
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Console/Drawer/NgqlDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Console/Drawer/SchemaDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
10 changes: 5 additions & 5 deletions app/pages/Console/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;

Expand Down Expand Up @@ -171,7 +171,7 @@ const Console = (props: IProps) => {
}),
];
return {
suggestions: suggestions,
suggestions,
dispose: () => {
const line = position.lineNumber;
const column = position.column;
Expand All @@ -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',
Expand All @@ -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();
Expand Down
20 changes: 11 additions & 9 deletions app/pages/Import/AIImport/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -91,7 +91,7 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => {
<Icon type="icon-vesoft-numeric-1-circle" />
{intl.get('llm.setup')}
</div>
<span></span>
<span />
<div>
<Icon type="icon-vesoft-numeric-2-circle" />
{intl.get('llm.confirm')}
Expand All @@ -103,7 +103,7 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => {
{Math.ceil(tokens / 10000)}w
</div>
)}
<Form form={form} layout="vertical" style={{ display: step == 0 ? 'block' : 'none' }}>
<Form form={form} layout="vertical" style={{ display: step === 0 ? 'block' : 'none' }}>
<Form.Item label={intl.get('llm.file')} required>
{llm.config.features.includes('aiImportFilePath') && (
<Form.Item noStyle name="type">
Expand All @@ -128,7 +128,7 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => {
}}
>
{fileList.map((item) => (
<Select.Option value={item.name} data={item}>
<Select.Option key={item.name} value={item.name} data={item}>
{item.name}
</Select.Option>
))}
Expand All @@ -143,7 +143,9 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => {
<Form.Item label={intl.get('llm.importGraphSpace')} name="space" required>
<Select onChange={(v) => setSpace(v)}>
{schema.spaces.map((item) => (
<Select.Option value={item}>{item}</Select.Option>
<Select.Option key={item} value={item}>
{item}
</Select.Option>
))}
</Select>
</Form.Item>
Expand All @@ -155,7 +157,7 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => {
</Form.Item>
</Form>

<Form layout="vertical" style={{ display: step == 1 ? 'block' : 'none' }}>
<Form layout="vertical" style={{ display: step === 1 ? 'block' : 'none' }}>
<Form.Item label={intl.get('llm.file')}>
<span>{valuse.file}</span>
</Form.Item>
Expand All @@ -165,13 +167,13 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => {
</Form>
<div className={styles.buttonArea}>
<Button onClick={props.onCancel}>{intl.get('common.cancel')}</Button>
{step == 1 && <Button onClick={() => setStep(0)}>{intl.get('llm.previous')}</Button>}
{step == 0 && (
{step === 1 && <Button onClick={() => setStep(0)}>{intl.get('llm.previous')}</Button>}
{step === 0 && (
<Button onClick={onNext} type="primary">
{intl.get('llm.next')}
</Button>
)}
{step == 1 && (
{step === 1 && (
<Button type="primary" onClick={onConfirm}>
{intl.get('llm.start')}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Import/DatasourceList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Import/TaskCreate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Import/TaskList/TaskItem/AIImportItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Import/TaskList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Import/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions app/pages/LLMBot/chat.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();
Expand Down Expand Up @@ -149,7 +149,7 @@ function Chat() {
return (
<div
key={index}
className={styles.chatMessage + ' ' + styles[item.role == 'user' ? 'fromUser' : 'fromBot']}
className={styles.chatMessage + ' ' + styles[item.role === 'user' ? 'fromUser' : 'fromBot']}
>
<div className={styles.chatMessageInner}>
<div className={styles.chatMessageContent}>{renderContent(item)}</div>
Expand Down
Loading

0 comments on commit 09ede24

Please sign in to comment.