Skip to content

Commit 6f22ef9

Browse files
committed
Merge branch 'main' of https://github.com/dataease/SQLBot
2 parents 4bb7f41 + 692abd9 commit 6f22ef9

File tree

6 files changed

+106
-21
lines changed

6 files changed

+106
-21
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,33 @@ SQLBot 是一款基于大模型和 RAG 的智能问数系统。SQLBot 的优势
1515

1616
## 快速开始
1717

18-
准备一台 Linux 机器,执行一键安装脚本:
18+
### 安装部署
1919

20-
```
21-
docker run -d --name=sqlbot --restart=always -p 8080:8080 -v ~/.sqlbot:/var/lib/postgresql/data -v ~/.python-packages:/opt/sqlbot/app/sandbox/python-packages registry.fit2cloud.com/sqlbot/sqlbot
20+
准备一台 Linux 服务器,执行以下一键安装脚本。
21+
在运行 SQLBot 前,请确保已安装好 [Docker](https://docs.docker.com/get-docker/)[Docker Compose](https://docs.docker.com/compose/install/)
22+
23+
```bash
24+
# 创建目录
25+
mkdir -p /opt/sqlbot
26+
cd /opt/sqlbot
27+
28+
# 下载 docker-compose.yaml
29+
curl -o docker-compose.yaml https://raw.githubusercontent.com/dataease/SQLBot/main/docker-compose.yaml
2230

23-
# 用户名: admin
24-
# 密码: SQLBot@123..
31+
# 启动服务
32+
docker compose up -d
2533
```
2634

2735
你也可以通过 [1Panel 应用商店](https://apps.fit2cloud.com/1panel) 快速部署 SQLBot;
2836

37+
### 访问方式
38+
39+
- 在浏览器中打开: http://<你的服务器IP>:8000/
40+
- 用户名: admin
41+
- 密码: SQLBot@123456
42+
43+
### 联系我们
44+
2945
如你有更多问题,可以加入我们的技术交流群与我们交流。
3046

3147
TBD: 交流群二维码

backend/apps/ai_model/model_factory.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from functools import lru_cache
12
import json
23
from abc import ABC, abstractmethod
34
from typing import Optional, Dict, Any, Type
@@ -21,6 +22,18 @@ class LLMConfig(BaseModel):
2122
api_key: Optional[str] = None
2223
api_base_url: Optional[str] = None
2324
additional_params: Dict[str, Any] = {}
25+
class Config:
26+
frozen = True
27+
28+
def __hash__(self):
29+
return hash((
30+
self.model_id,
31+
self.model_type,
32+
self.model_name,
33+
self.api_key,
34+
self.api_base_url,
35+
frozenset(self.additional_params.items())
36+
))
2437

2538

2639
class BaseLLM(ABC):
@@ -66,6 +79,7 @@ class LLMFactory:
6679
}
6780

6881
@classmethod
82+
@lru_cache(maxsize=32)
6983
def create_llm(cls, config: LLMConfig) -> BaseLLM:
7084
llm_class = cls._llm_types.get(config.model_type)
7185
if not llm_class:

backend/apps/system/api/aimodel.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ async def generate():
2727
additional_params=additional_params,
2828
)
2929
llm_instance = LLMFactory.create_llm(config)
30-
31-
res = llm_instance.llm.stream("who are you?")
32-
33-
for chunk in res:
30+
async for chunk in llm_instance.llm.astream("1+1=?"):
3431
if chunk and chunk.content:
35-
SQLBotLogUtil.info(chunk)
3632
yield json.dumps({"content": chunk.content}) + "\n"
3733

3834
except Exception as e:

docker-compose.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
services:
2+
sqlbot:
3+
image: dataease/sqlbot:v0.9.3
4+
container_name: sqlbot
5+
restart: always
6+
networks:
7+
- sqlbot-network
8+
ports:
9+
- 8000:8000
10+
- 8001:8001
11+
environment:
12+
# Database configuration
13+
POSTGRES_SERVER: sqlbot-db
14+
POSTGRES_PORT: 5432
15+
POSTGRES_DB: sqlbot
16+
POSTGRES_USER: sqlbot
17+
POSTGRES_PASSWORD: sqlbot
18+
# Project basic settings
19+
PROJECT_NAME: "SQLBot"
20+
DEFAULT_PWD: "SQLBot@123456"
21+
# MCP settings
22+
MCP_IMAGE_PATH: /opt/sqlbot/images
23+
MCP_IMAGE_HOST: http://localhost:3000
24+
SERVER_IMAGE_HOST: https://sqlbot.fit2cloud.cn/images/
25+
# Auth & Security
26+
TOKEN_KEY: "X-SQLBOT-TOKEN"
27+
ASSISTANT_TOKEN_KEY: "X-SQLBOT-ASSISTANT-TOKEN"
28+
SECRET_KEY: y5txe1mRmS_JpOrUzFzHEu-kIQn3lf7ll0AOv9DQh0s
29+
# CORS settings
30+
BACKEND_CORS_ORIGINS: "http://localhost,http://localhost:5173,https://localhost,https://localhost:5173"
31+
# Logging
32+
LOG_LEVEL: "INFO"
33+
LOG_DIR: "/opt/sqlbot/logs"
34+
LOG_FORMAT: "%(asctime)s - %(name)s - %(levelname)s:%(lineno)d - %(message)s"
35+
SQL_DEBUG: False
36+
volumes:
37+
- ./data/sqlbot/excel:/opt/sqlbot/data/excel
38+
- ./data/sqlbot/images:/opt/sqlbot/images
39+
- ./data/sqlbot/logs:/opt/sqlbot/logs
40+
depends_on:
41+
sqlbot-db:
42+
condition: service_healthy
43+
44+
sqlbot-db:
45+
image: postgres:17.5
46+
container_name: sqlbot-db
47+
restart: always
48+
networks:
49+
- sqlbot-network
50+
volumes:
51+
- ./data/postgresql:/var/lib/postgresql/data
52+
environment:
53+
POSTGRES_DB: sqlbot
54+
POSTGRES_USER: sqlbot
55+
POSTGRES_PASSWORD: sqlbot
56+
healthcheck:
57+
test: ["CMD-SHELL", "pg_isready"]
58+
interval: 3s
59+
timeout: 5s
60+
retries: 5
61+
networks:
62+
sqlbot-network:

frontend/src/i18n/en.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"menu": {
33
"Data Q&A": "Data Q&A",
4-
"Data Connections": "Data Connections",
4+
"Data Connections": "Data Sources",
55
"Dashboard": "Dashboard",
66
"AI Model Configuration": "AI Model Configuration"
77
},
@@ -98,8 +98,8 @@
9898
},
9999
"qa": {
100100
"new_chat": "New Chat",
101-
"start_sqlbot": "Start SQLBot",
102-
"title": "Smart Data Query",
101+
"start_sqlbot": "New Chat",
102+
"title": "Data Q&A",
103103
"placeholder": "Please enter your question",
104104
"ask": "Ask",
105105
"loading": "Loading...",
@@ -111,7 +111,7 @@
111111
"select_datasource": "Select Data Source",
112112
"view_more": "View More",
113113
"selected_datasource": "Selected Data Source",
114-
"empty_datasource": "No data sources available. Please create one before starting Smart Data Query!",
114+
"empty_datasource": "No data sources available. Please create one before starting Data Q&A!",
115115
"datasource_not_exist": "Data source does not exist",
116116
"guess_u_ask": "You might want to ask:",
117117
"continue_to_ask": "Continue asking:",
@@ -130,7 +130,7 @@
130130
"copied": "Copied"
131131
},
132132
"ds": {
133-
"title": "Data Source",
133+
"title": "Data Sources",
134134
"add": "Add Data Source",
135135
"delete": "Delete Data Source",
136136
"name": "Data Source Name",
@@ -225,7 +225,7 @@
225225
"search": "Search",
226226
"all_types": "All types",
227227
"new_data_source": "New data source",
228-
"open_query": "Open query",
228+
"open_query": "New Chat",
229229
"edit": "Edit",
230230
"source_connection_failed": "Data source connection failed",
231231
"confirm": "Confirm",
@@ -365,7 +365,7 @@
365365
"add_successfully": "Add successfully",
366366
"member_management": "Member management",
367367
"permission_configuration": "Permission configuration",
368-
"set": "Set",
368+
"set": "Settings",
369369
"operate_with_caution": "After deletion, the users under the workspace will be removed and all resources will be deleted. Please operate with caution."
370370
},
371371
"permission": {

frontend/src/views/system/model/Model.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const activeName = ref('')
3535
const activeType = ref('')
3636
const modelFormRef = ref()
3737
const cardRefs = ref<any[]>([])
38-
// const showCardError = ref(true) // if you don`t want card mask error, just change this to false
38+
const showCardError = ref(false) // if you don`t want card mask error, just change this to false
3939
reactive({
4040
form: {
4141
id: '',
@@ -71,8 +71,6 @@ const defaultModelListWithSearch = computed(() => {
7171
})
7272
7373
const modelCheckHandler = async (item: any) => {
74-
console.log(item)
75-
/**
7674
const response = await modelApi.check(item)
7775
const reader = response.body.getReader()
7876
const decoder = new TextDecoder()
@@ -112,7 +110,6 @@ const modelCheckHandler = async (item: any) => {
112110
currentRef?.showErrorMask(checkMsg)
113111
}
114112
})
115-
*/
116113
}
117114
const duplicateName = async (item: any) => {
118115
const res = await modelApi.queryAll()

0 commit comments

Comments
 (0)