Skip to content

Commit

Permalink
Merge pull request #606 from chat2db/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
shanhexi authored Oct 19, 2023
2 parents 06d7096 + 51e6156 commit b1356f3
Show file tree
Hide file tree
Showing 23 changed files with 203 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
yarn install
yarn run build:web:prod --app_version=${{ steps.chat2db_version.outputs.substring }}
cp -r dist ../chat2db-server/chat2db-server-start/src/main/resources/static/front
cp -r dist/index.html ../chat2db-server/chat2db-server-start/src/main/resources/thymeleaf
cp -r dist/index.html ../chat2db-server/chat2db-server-start/src/main/resources/thymeleaf/
# 编译服务端java版本
- name: Build Java
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
yarn install
yarn run build:web:prod --app_version=99.0.${{ github.run_id }} --app_port=10822
cp -r dist ../chat2db-server/chat2db-server-start/src/main/resources/static/front
cp -r dist/index.html ../chat2db-server/chat2db-server-start/src/main/resources/thymeleaf
cp -r dist/index.html ../chat2db-server/chat2db-server-start/src/main/resources/thymeleaf/
# 编译服务端java版本
- name: Build Java
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package-lock.json
### Mac
.DS_Store
/chat2db-server/ali-dbhub-server-start/src/main/resources/static/front/*
/chat2db-server/ali-dbhub-server-start/src/main/resources/thymeleaf

### docker 数据不用上传
/docker/redis/data/*
Expand Down
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# 3.0.1
`2023-10-19`

**Changelog**
- ⚡️【Optimize】Search result scroll bar
- ⚡️【Fixed】Oracle update result data bug

**更新日志**
- ⚡️【优化】查询结果滚动条
- 🐞【修复】Oracle更新结果数据错误

# 3.0.0
`2023-10-17`

## Changelog
**Changelog**
- 🔥【New Features】Support for team collaboration mode
- 🔥【New Features】Support for visual table structure creation, editing, and deletion
- 🔥【New Features】Support for editing, adding, and deleting query data results
Expand All @@ -18,7 +29,8 @@
- ⚡️【Optimize】`Cmd/Ctrl + R` Run SQL, `Cmd/Ctrl + Shift + R` Refresh Page
- 🐞【Fixed】Table operation columns are overridden by table comments
- 🐞【Fixed】The last Tab in the query result cannot be closed
## 更新日志

**更新日志**
- 🔥【新功能】支持团队协作模式
- 🔥【新功能】支持可视化表结构新增、编辑、删除
- 🔥【新功能】支持查询数据结果编辑、新增、删除
Expand Down
43 changes: 19 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ An intelligent and versatile general-purpose SQL client and reporting tool for d

Languages: English | [中文](README_CN.md)

Official website:[Chat2DB](https://sqlgpt.cn/en)

<div style="display: flex; align-items: center;">
If you find Chat2DB helpful, please help<a style="display: flex; align-items: center;margin:0px 6px" target="_blank" href='https://github.com/chat2db/Chat2db'><img src="https://img.shields.io/github/stars/chat2db/Chat2DB.svg?style=flat-square&label=Stars&logo=github" alt="github star"/></a>Click ⭐ Star and Fork in the top right corner, and your support is the biggest motivation for Chat2DB to get bette
</div>

</div>

## DEMO
Expand All @@ -49,7 +55,7 @@ https://github.com/chat2db/Chat2DB/assets/22975773/79e9dded-375b-44cf-9979-bb757
[Downloading installation package from GitHub](https://github.com/chat2db/Chat2DB/releases)


[Downloading installation package from official website](https://sqlgpt.cn/docs/guides/download)
[Downloading installation package from official website](https://sqlgpt.cn)



Expand All @@ -61,7 +67,7 @@ Chat2DB supports connecting to the following databases:
- H2
- Oracle
- SQLServer
- SQLLite
- SQLite
- MariaDB
- ClickHouseare
- DM
Expand Down Expand Up @@ -94,25 +100,7 @@ Redis and MongoDB are partially supported , Hbase、Elasticsearch、openGauss、

## 🔥 AI Configuration

### CONFIGURE OPENAI

Option 1 (recommended): To use the ChatSql function of OPENAI, two conditions must be met:

- You need an OPENAI_API_KEY.
- The client's network can connect to the OPENAI website, and for users in China, a VPN is required. Note: If the local VPN is not fully effective, the network connectivity can be ensured by setting the network proxy HOST and PORT in the client.

<img width="1717" alt="3" src="https://github.com/chat2db/Chat2DB/assets/22975773/95c8a766-cc6b-4767-90e6-a8b616a89bc7">


Option 2 (recommended): We provide a unified proxy service.

- No OPENAI_API_KEY is required.
- No proxy or VPN is required, as long as the network is connected.

To facilitate users' quick use of AI capabilities, you can scan the QR code below to follow our WeChat public account and apply for our custom API_KEY.

<img width="1726" alt="4" src="https://github.com/chat2db/Chat2DB/assets/22975773/9236ff01-e49f-4e45-96b0-201e85fcd756">

### Use Chat2DB AI to get started

### CONFIGURE CUSTOM AI

Expand Down Expand Up @@ -147,7 +135,7 @@ Note: If local debugging is required
- git clone to local
```bash
$ git clone [email protected]:alibaba/Chat2DB.git
$ git clone [email protected]:chat2db/Chat2DB.git
```

- Front-End debug
Expand All @@ -169,10 +157,17 @@ $ cd chat2db-server/chat2db-server-start/target/
$ java -jar -Dloader.path=./lib -Dchatgpt.apiKey=xxxxx chat2db-server-start.jar #java 17 or later must be installed, To launch the chat application, you need to enter the ChatGPT key for the chatgpt.apiKey. Without entering it, you won't be able to use the AIGC function.
```

- If you need to deploy independently

```bash
$ npm run build:web:prod / cp -r dist ../chat2db-server/chat2db-server-start/src/main/resources/static/front / cp -r dist/index.html ../chat2db-server/chat2db-server-start/src/main/resources/thymeleaf
# Repackage the back-end services
```

## 📑 Documentation

- <a href="https://chat2db.opensource.alibaba.com">Official website document</a>
- <a href="https://github.com/alibaba/ali-dbhub/issues">Issue </a>
- <a href="https://doc.sqlgpt.cn/">Official website document</a>
- <a href="https://github.com/chat2db/Chat2DB/issues">Issue </a>

## Stargazers

Expand Down
52 changes: 23 additions & 29 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
<div align="center">

Languages: 中文 [English](README.md)

如果觉得 Chat2DB 对您有帮助的话,请帮忙<a target="_blank" href='https://github.com/chat2db/Chat2db'><img src="https://img.shields.io/github/stars/chat2db/Chat2DB.svg?style=flat-square&label=Stars&logo=github" alt="github star"/></a>
的右上角点个⭐ Star 和 Fork,您的支持是 Chat2DB 变得更好最大的动力

官网:[Chat2DB](https://sqlgpt.cn/zh)

<div style="display: flex; align-items: center;">
如果觉得 Chat2DB 对您有帮助的话,请帮忙<a style="display: flex; align-items: center;margin:0px 6px" target="_blank" href='https://github.com/chat2db/Chat2db'><img src="https://img.shields.io/github/stars/chat2db/Chat2DB.svg?style=flat-square&label=Stars&logo=github" alt="github star"/></a>
的右上角点个⭐ Star 和 Fork,您的支持是 Chat2DB 变得更好最大的动力
</div>
</div>


Expand Down Expand Up @@ -50,9 +54,7 @@ https://github.com/chat2db/Chat2DB/assets/22975773/b58db908-5768-4a71-aa30-135d2

[GitHub下载安装包](https://github.com/chat2db/Chat2DB/releases)


[官网下载安装包](https://sqlgpt.cn/docs/guides/download)
[官网下载安装包](https://sqlgpt.cn)

## 🚀 支持的数据库

Expand All @@ -62,7 +64,7 @@ Chat2DB 支持的数据库连接有:
- H2
- Oracle
- SQLServer
- SQLLite
- SQLite
- MariaDB
- ClickHouseare
- DM
Expand All @@ -72,7 +74,7 @@ Chat2DB 支持的数据库连接有:
- Hive
- KingBase

Redis and MongoDB are partially supported , Hbase、Elasticsearch、openGauss、TiDB、InfluxDB will support in the future.
Redis和MongoDB得到部分支持,Hbase、Elasticsearch、openGauss、TiDB、InfluxDB将在未来得到支持。


## 🌰 使用 Demo
Expand All @@ -85,31 +87,17 @@ Redis and MongoDB are partially supported , Hbase、Elasticsearch、openGauss、

<a><img src="https://alidocs.oss-cn-zhangjiakou.aliyuncs.com/res/KM7qezzyAVX2Opj8/img/d5634953-9fe5-4a03-8024-3aa4774b2955.png?x-oss-process=image/resize,w_1280,m_lfit,limit_1"/></a>

### SQL 控制台 及 AI 智能助手

#### 使用前需要配置 OpenAI 的 Api Key 及本地代理配置

<a><img src="https://alidocs.oss-cn-zhangjiakou.aliyuncs.com/res/KM7qezzyAVX2Opj8/img/f1a111bd-38cf-42d2-bfd3-f1d7f57aec3c.png?x-oss-process=image/resize,w_1280,m_lfit,limit_1"/></a>
<a><img src="https://alidocs.oss-cn-zhangjiakou.aliyuncs.com/res/KM7qezzyAVX2Opj8/img/16e3c632-f896-45c3-a7a2-91c338e82f73.png?x-oss-process=image/resize,w_1280,m_lfit,limit_1"/></a>

## 🔥 AI 配置
### SQL 控制台

### 使用 ChatGPT
<a><img width="1720" alt="2" src="https://github.com/chat2db/Chat2DB/assets/22975773/5d0332ca-8a65-4ed9-95fb-b12fae9209f3"></a>

方式一(推荐):使用 OPENAI 的 ChatSql 功能需要满足两个条件
### AI 智能助手

- 1、需要有一个 openAI 的 key:OPENAI_API_KEY
- 2、客户端网络可以连接到 OPENAI 官网,国内需要科学上网。注意:如果本地 VPN 未能全局生效,可以通过在客户端中设置网络代理 HOST 和 PORT 来保证网络连通性
- <a><img src="https://alidocs.oss-cn-zhangjiakou.aliyuncs.com/res/KM7qezzyAVX2Opj8/img/0218daf0-7d93-43c5-a5f7-decd104c0847.png?x-oss-process=image/resize,w_1280,m_lfit,limit_1"/></a>
![image](https://github.com/chat2db/Chat2DB/assets/22975773/2dfc4aaa-c5a3-42c3-bc61-28ebc237a27b)

方式二(推荐):使用我们提供了一个统一的代理服务。
## 🔥 AI

- 1、不需要 openAI 的 key
- 2、不需要代理,不需要 VPN 只要可以联网即可使用。

为了方便大家更快速的使用 AI 的能力,可以关注微信公众号,回复"AI" 获得我们的自定义 API_KEY,申请完成之后参考下图进行配置即可进行使用

<a><img src="https://alidocs.oss-cn-zhangjiakou.aliyuncs.com/res/KM7qezzyAVX2Opj8/img/5ee43d26-05bb-4b12-b705-2b263f167975.png?x-oss-process=image/resize,w_1280,m_lfit,limit_1"/></a>
### 使用Chat2DB AI 上手即用

### 使用自定义大模型
- [参考这里部署本地ChatGLM-6B模型](https://github.com/chat2db/chat2db-chatglm-6b-deploy/blob/main/README_CN.md)
Expand Down Expand Up @@ -163,9 +151,15 @@ $ cd chat2db-server/chat2db-server-start/target/
$ java -jar -Dloader.path=./lib -Dchatgpt.apiKey=xxxxx chat2db-server-start.jar # 需要安装java 17以上版本,启动应用 chatgpt.apiKey 需要输入ChatGPT的key,如果不输入无法使用AIGC功能
```

- 如果你需要独立部署
```bash
$ npm run build:web:prod / cp -r dist ../chat2db-server/chat2db-server-start/src/main/resources/static/front / cp -r dist/index.html ../chat2db-server/chat2db-server-start/src/main/resources/thymeleaf
# 再打包后端服务
```

## 📑 文档

- <a href="https://chat2db.opensource.alibaba.com">官方文档</a>
- <a href="https://doc.sqlgpt.cn/zh/">官方文档</a>
- <a href="https://github.com/chat2db/Chat2DB/issues">Issue</a>

## 常见问题
Expand Down
1 change: 0 additions & 1 deletion chat2db-client/src/components/Console/ChatInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import i18n from '@/i18n/';
import Iconfont from '@/components/Iconfont';
import { WarningOutlined } from '@ant-design/icons';
import { AiSqlSourceType, IRemainingUse } from '@/typings/ai';
import { WECHAT_MP_URL } from '@/constants/social';

export const enum SyncModelType {
AUTO = 0,
Expand Down
33 changes: 29 additions & 4 deletions chat2db-client/src/components/Console/MonacoEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React, { ForwardedRef, forwardRef, useEffect, useImperativeHandle, useRef
import cs from 'classnames';
import { useTheme } from '@/hooks';
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
import { editorDefaultOptions, EditorThemeType, ThemeType } from '@/constants';
import { DatabaseTypeCode, editorDefaultOptions, EditorThemeType, ThemeType } from '@/constants';
import { IQuickInputService } from 'monaco-editor/esm/vs/platform/quickinput/common/quickInput';

import styles from './index.less';

export type IEditorIns = monaco.editor.IStandaloneCodeEditor;
Expand All @@ -14,14 +16,20 @@ export type IAppendValue = {
range?: IRangeType;
};

const databaseTypeList = Object.keys(DatabaseTypeCode).map((d) => ({
type: d,
id: d,
label: d,
}));

interface IProps {
id: string;
isActive?: boolean;
language?: string;
className?: string;
options?: IEditorOptions;
needDestroy?: boolean;
addAction?: Array<{ id: string; label: string; action: (selectedText: string) => void }>;
addAction?: Array<{ id: string; label: string; action: (selectedText: string, ext?: string) => void }>;
defaultValue?: string;
appendValue?: IAppendValue;
// onChange?: (v: string, e?: IEditorContentChangeEvent) => void;
Expand Down Expand Up @@ -51,6 +59,7 @@ function MonacoEditor(props: IProps, ref: ForwardedRef<IExportRefFunction>) {
appendValue,
} = props;
const editorRef = useRef<IEditorIns>();
const quickInputCommand = useRef<any>();
const [appTheme] = useTheme();

// init
Expand All @@ -65,6 +74,13 @@ function MonacoEditor(props: IProps, ref: ForwardedRef<IExportRefFunction>) {
editorRef.current = editorIns;
didMount && didMount(editorIns);

// Add a new command, for getting an accessor.
quickInputCommand.current = editorIns.addCommand(0, (accessor, func) => {
// a hacker way to get the input service
const quickInputService = accessor.get(IQuickInputService);
func(quickInputService);
});

const { colorPrimary } = window._AppThemePack;
const colors = {
'editor.lineHighlightBackground': colorPrimary + '14', // 当前行背景色
Expand Down Expand Up @@ -239,9 +255,18 @@ function MonacoEditor(props: IProps, ref: ForwardedRef<IExportRefFunction>) {
contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5,
// 点击该菜单键后运行
run: () => {
run: (ed: IEditorIns) => {
const selectedText = editor.getModel()?.getValueInRange(editor.getSelection()!) || '';
runFn(selectedText);
if (_id === 'changeSQL') {
ed.trigger('', quickInputCommand.current, (quickInput) => {
quickInput.pick(databaseTypeList).then((selected) => {
console.log(selected);
runFn(selectedText, selected?.label);
});
});
} else {
runFn(selectedText);
}
},
});
});
Expand Down
Loading

0 comments on commit b1356f3

Please sign in to comment.