mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -85,6 +85,7 @@ def get_chat_with_records(session: SessionDep, chart_id: int, current_user: Curr
|
||||
else:
|
||||
chat_info.datasource_exists = True
|
||||
chat_info.datasource_name = ds.name
|
||||
chat_info.ds_type = ds.type
|
||||
|
||||
record_list = session.query(ChatRecord).options(
|
||||
load_only(ChatRecord.id, ChatRecord.chat_id, ChatRecord.create_time, ChatRecord.finish_time,
|
||||
|
||||
@@ -89,6 +89,7 @@ class ChatInfo(BaseModel):
|
||||
chat_type: str = "chat"
|
||||
datasource: Optional[int] = None
|
||||
engine_type: str = ''
|
||||
ds_type: str = ''
|
||||
datasource_name: str = ''
|
||||
datasource_exists: bool = True
|
||||
records: List[ChatRecord | dict] = []
|
||||
|
||||
@@ -292,10 +292,9 @@ def preview(session: SessionDep, current_user: CurrentUser, id: int, data: Table
|
||||
{where}
|
||||
LIMIT 100"""
|
||||
elif ds.type == "sqlServer":
|
||||
sql = f"""SELECT [{"], [".join(fields)}] FROM [{conf.dbSchema}].[{data.table.table_name}]
|
||||
sql = f"""SELECT TOP 100 [{"], [".join(fields)}] FROM [{conf.dbSchema}].[{data.table.table_name}]
|
||||
{where}
|
||||
ORDER BY [{fields[0]}]
|
||||
OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY"""
|
||||
"""
|
||||
elif ds.type == "pg" or ds.type == "excel":
|
||||
sql = f"""SELECT "{'", "'.join(fields)}" FROM "{conf.dbSchema}"."{data.table.table_name}"
|
||||
{where}
|
||||
@@ -408,4 +407,4 @@ def filter_list(list_a, list_b):
|
||||
|
||||
|
||||
def is_normal_user(current_user: CurrentUser):
|
||||
return current_user.id != 1 and (current_user.weight is not None and current_user.weight != 1)
|
||||
return current_user.id != 1
|
||||
|
||||
@@ -134,6 +134,7 @@ export class Chat {
|
||||
chat_type?: string
|
||||
datasource?: number
|
||||
engine_type?: string
|
||||
ds_type?: string
|
||||
|
||||
constructor()
|
||||
constructor(
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
--ed-color-primary-dark-2: #189e7a !important;
|
||||
--ed-color-primary-1a: #1cba901a;
|
||||
--ed-color-primary-light-5: #3ec4a1 !important;
|
||||
--ed-border-color: #d9dcdf !important;
|
||||
}
|
||||
|
||||
a {
|
||||
|
||||
@@ -214,7 +214,11 @@ function onChatRenamed(chat: Chat) {
|
||||
/>
|
||||
</el-header>
|
||||
<el-main class="chat-list">
|
||||
<div v-if="!computedChatList.length" class="empty-search">
|
||||
{{ !!search ? $t('datasource.relevant_content_found') : $t('dashboard.no_chat') }}
|
||||
</div>
|
||||
<ChatList
|
||||
v-else
|
||||
v-model:loading="_loading"
|
||||
:current-chat-id="_currentChatId"
|
||||
:chat-list="computedChatList"
|
||||
@@ -294,6 +298,16 @@ function onChatRenamed(chat: Chat) {
|
||||
|
||||
.chat-list {
|
||||
padding: 0 0 20px 0;
|
||||
|
||||
.empty-search {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
margin-top: 80px;
|
||||
color: #646a73;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { ChatMessage } from '@/api/chat.ts'
|
||||
import DisplayChartBlock from '@/views/chat/component/DisplayChartBlock.vue'
|
||||
import ChartPopover from '@/views/chat/chat-block/ChartPopover.vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { concat } from 'lodash-es'
|
||||
import type { ChartTypes } from '@/views/chat/component/BaseChart.ts'
|
||||
@@ -157,11 +158,11 @@ const chartTypeList = computed(() => {
|
||||
})
|
||||
|
||||
function changeTable() {
|
||||
chartType.value = 'table'
|
||||
onTypeChange()
|
||||
onTypeChange('table')
|
||||
}
|
||||
|
||||
function onTypeChange() {
|
||||
function onTypeChange(val: any) {
|
||||
chartType.value = val
|
||||
chartRef.value?.onTypeChange()
|
||||
}
|
||||
|
||||
@@ -207,21 +208,13 @@ function addToDashboard() {
|
||||
<div class="buttons-bar">
|
||||
<div class="chart-select-container">
|
||||
<el-tooltip effect="dark" :content="t('chat.type')" placement="top">
|
||||
<el-select
|
||||
<ChartPopover
|
||||
:chartTypeList="chartTypeList"
|
||||
:chartType="chartType"
|
||||
:title="t('chat.type')"
|
||||
@typeChange="onTypeChange"
|
||||
v-if="chartTypeList.length > 0"
|
||||
v-model="chartType"
|
||||
class="chart-select"
|
||||
:class="{ 'chart-active': currentChartType !== 'table' }"
|
||||
@change="onTypeChange"
|
||||
>
|
||||
<el-option v-for="type in chartTypeList" :key="type.value" :value="type.value">
|
||||
<el-icon size="16">
|
||||
<component :is="type.icon" />
|
||||
</el-icon>
|
||||
{{ type.name }}
|
||||
|
||||
</el-option>
|
||||
</el-select>
|
||||
></ChartPopover>
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip effect="dark" :content="t('chat.chart_type.table')" placement="top">
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
<script lang="ts" setup>
|
||||
import icon_done_outlined from '@/assets/svg/icon_done_outlined.svg'
|
||||
import { computed } from 'vue'
|
||||
import icon_expand_down_filled from '@/assets/svg/icon_down_outlined.svg'
|
||||
const props = defineProps({
|
||||
chartTypeList: {
|
||||
type: Array<any>,
|
||||
default: () => [],
|
||||
},
|
||||
chartType: {
|
||||
type: String,
|
||||
default: 'table',
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
const currentIcon = computed(() => {
|
||||
return props.chartTypeList.find((ele) => ele.value === props.chartType || ele.value === 'table')
|
||||
.icon
|
||||
})
|
||||
const emits = defineEmits(['typeChange'])
|
||||
const handleDefaultChatChange = (val: any) => {
|
||||
emits('typeChange', val.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-popover trigger="click" popper-class="chat-type_select" placement="bottom">
|
||||
<template #reference>
|
||||
<div class="chat-select_type" :class="chartType && chartType !== 'table' && 'active'">
|
||||
<component :is="currentIcon" />
|
||||
<el-icon style="transform: scale(0.75)" class="expand" size="16">
|
||||
<icon_expand_down_filled></icon_expand_down_filled>
|
||||
</el-icon>
|
||||
</div>
|
||||
</template>
|
||||
<div class="popover">
|
||||
<div class="popover-content">
|
||||
<div v-if="!!title" class="title">{{ title }}</div>
|
||||
<div
|
||||
v-for="ele in chartTypeList"
|
||||
:key="ele.name"
|
||||
class="popover-item"
|
||||
:class="chartType === ele.value && 'isActive'"
|
||||
@click="handleDefaultChatChange(ele)"
|
||||
>
|
||||
<el-icon size="16">
|
||||
<component :is="ele.icon" />
|
||||
</el-icon>
|
||||
<div class="model-name">{{ ele.name }}</div>
|
||||
<el-icon size="16" class="done">
|
||||
<icon_done_outlined></icon_done_outlined>
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-popover>
|
||||
</template>
|
||||
|
||||
<style lang="less">
|
||||
.chat-type_select.chat-type_select {
|
||||
padding: 4px 0;
|
||||
width: 120px !important;
|
||||
min-width: 120px !important;
|
||||
box-shadow: 0px 4px 8px 0px #1f23291a;
|
||||
border: 1px solid #dee0e3;
|
||||
|
||||
.popover {
|
||||
.popover-content {
|
||||
padding: 0 4px;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
|
||||
.title {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
margin-bottom: 2px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-left: 8px;
|
||||
color: #8f959e;
|
||||
}
|
||||
}
|
||||
.popover-item {
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-left: 12px;
|
||||
padding-right: 8px;
|
||||
margin-bottom: 2px;
|
||||
position: relative;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
&:hover {
|
||||
background: #1f23291a;
|
||||
}
|
||||
|
||||
.model-name {
|
||||
margin-left: 8px;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
max-width: 220px;
|
||||
}
|
||||
|
||||
.done {
|
||||
margin-left: auto;
|
||||
display: none;
|
||||
}
|
||||
|
||||
&.isActive {
|
||||
color: var(--ed-color-primary);
|
||||
|
||||
.done {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.chat-select_type {
|
||||
width: 40px;
|
||||
height: 24px;
|
||||
border-radius: 4px;
|
||||
padding-left: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
|
||||
.expand {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #1f23291a;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: rgba(28, 186, 144, 0.1);
|
||||
color: rgba(28, 186, 144, 1);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -259,29 +259,35 @@
|
||||
v-if="computedMessages.length > 0 || (isAssistant && currentChatId)"
|
||||
class="chat-footer"
|
||||
>
|
||||
<div class="input-container" @click="clickInput">
|
||||
<div class="input-wrapper" @click="clickInput">
|
||||
<div class="datasource">
|
||||
<template v-if="currentChat.datasource && currentChat.datasource_name">
|
||||
{{ t('qa.selected_datasource') }}:
|
||||
{{ t('qa.selected_datasource') }}:
|
||||
<img
|
||||
style="margin-left: 4px; margin-right: 4px"
|
||||
:src="currentChatEngineType"
|
||||
width="16px"
|
||||
height="16px"
|
||||
alt=""
|
||||
/>
|
||||
<span class="name">
|
||||
{{ currentChat.datasource_name }}
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
<div class="input-wrapper">
|
||||
<el-input
|
||||
ref="inputRef"
|
||||
v-model="inputMessage"
|
||||
:disabled="isTyping"
|
||||
class="input-area"
|
||||
type="textarea"
|
||||
:rows="1"
|
||||
:autosize="{ minRows: 1, maxRows: 8 }"
|
||||
:placeholder="t('qa.question_placeholder')"
|
||||
@keydown.enter.exact.prevent="sendMessage"
|
||||
@keydown.ctrl.enter.exact.prevent="handleCtrlEnter"
|
||||
/>
|
||||
</div>
|
||||
<el-input
|
||||
ref="inputRef"
|
||||
v-model="inputMessage"
|
||||
:disabled="isTyping"
|
||||
class="input-area"
|
||||
type="textarea"
|
||||
:rows="1"
|
||||
:autosize="{ minRows: 1, maxRows: 8.583 }"
|
||||
:placeholder="t('qa.question_placeholder')"
|
||||
@keydown.enter.exact.prevent="sendMessage"
|
||||
@keydown.ctrl.enter.exact.prevent="handleCtrlEnter"
|
||||
/>
|
||||
|
||||
<el-button
|
||||
circle
|
||||
type="primary"
|
||||
@@ -315,6 +321,7 @@ import RecommendQuestion from './RecommendQuestion.vue'
|
||||
import ChatListContainer from './ChatListContainer.vue'
|
||||
import ChatCreator from '@/views/chat/ChatCreator.vue'
|
||||
import ChatToolBar from './ChatToolBar.vue'
|
||||
import { dsTypeWithImg } from '@/views/ds/js/ds-type'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { find } from 'lodash-es'
|
||||
import icon_new_chat_outlined from '@/assets/svg/icon_new_chat_outlined.svg'
|
||||
@@ -432,6 +439,13 @@ function onClickHistory(chat: Chat) {
|
||||
console.debug('click history', chat)
|
||||
}
|
||||
|
||||
const currentChatEngineType = computed(() => {
|
||||
return (
|
||||
dsTypeWithImg.find((ele) => currentChat.value.ds_type === ele.type || ele.type === 'excel') ||
|
||||
{}
|
||||
).img
|
||||
})
|
||||
|
||||
function toAssistantHistory(chat: Chat) {
|
||||
currentChat.value = new ChatInfo(chat)
|
||||
if (chat !== undefined && chat.id !== undefined && !loading.value) {
|
||||
@@ -852,21 +866,46 @@ onMounted(() => {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.input-container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
.input-wrapper {
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
border-radius: 16px;
|
||||
border: 1px solid rgba(217, 220, 223, 1);
|
||||
background: rgba(248, 249, 250, 1);
|
||||
padding: 12px;
|
||||
gap: 8px;
|
||||
|
||||
position: relative;
|
||||
|
||||
.datasource {
|
||||
width: calc(100% - 2px);
|
||||
position: absolute;
|
||||
margin-left: 1px;
|
||||
margin-top: 1px;
|
||||
left: 0;
|
||||
top: 0;
|
||||
padding-top: 12px;
|
||||
padding-left: 12px;
|
||||
z-index: 10;
|
||||
background: #f8f9fa;
|
||||
line-height: 22px;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
border-top-right-radius: 16px;
|
||||
border-top-left-radius: 16px;
|
||||
color: rgba(100, 106, 115, 1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.name {
|
||||
color: rgba(31, 35, 41, 1);
|
||||
}
|
||||
}
|
||||
|
||||
.input-area {
|
||||
border-color: #d9dcdf;
|
||||
|
||||
:deep(.ed-textarea__inner) {
|
||||
padding: 42px 12px 52px 12px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 16px;
|
||||
line-height: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.input-icon {
|
||||
min-width: unset;
|
||||
position: absolute;
|
||||
@@ -880,39 +919,6 @@ onMounted(() => {
|
||||
border-color: unset;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: rgba(28, 186, 144, 1);
|
||||
}
|
||||
}
|
||||
|
||||
.datasource {
|
||||
width: 100%;
|
||||
|
||||
line-height: 22px;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
color: rgba(100, 106, 115, 1);
|
||||
|
||||
.name {
|
||||
color: rgba(31, 35, 41, 1);
|
||||
}
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
|
||||
.input-area {
|
||||
height: 100%;
|
||||
|
||||
:deep(.ed-textarea__inner) {
|
||||
height: 100% !important;
|
||||
background: transparent;
|
||||
box-shadow: unset;
|
||||
padding: unset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ const open = async (user: any) => {
|
||||
checkAll.value = false
|
||||
isIndeterminate.value = false
|
||||
const systemWorkspaceList = await workspaceUserList({}, 1, 1000)
|
||||
workspace.value = systemWorkspaceList.items.filter((ele: any) => ele.weight !== 1) as any
|
||||
workspace.value = systemWorkspaceList.items as any
|
||||
if (user?.length) {
|
||||
checkedWorkspace.value = workspace.value.filter((ele) => user.includes(ele.id))
|
||||
handleCheckedWorkspaceChange(checkedWorkspace.value)
|
||||
|
||||
@@ -219,6 +219,7 @@ const handleInitDsIdChange = (val: any) => {
|
||||
activeTable.value = null
|
||||
fieldListOptions.value = []
|
||||
columnForm.permissions = []
|
||||
authTreeRef.value.init({})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -758,6 +758,10 @@ onMounted(() => {
|
||||
width: 100%;
|
||||
max-height: calc(100vh - 150px);
|
||||
overflow-y: auto;
|
||||
|
||||
:deep(.ed-popper.is-dark) {
|
||||
max-width: 400px;
|
||||
}
|
||||
:deep(.ed-table) {
|
||||
--el-table-header-bg-color: #f5f7fa;
|
||||
--el-table-border-color: #ebeef5;
|
||||
|
||||
Reference in New Issue
Block a user