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:
@@ -24,7 +24,8 @@ class Chat(SQLModel, table=True):
|
||||
chat_type: str = Field(max_length=20, default="chat") # chat, datasource
|
||||
datasource: int = Field(sa_column=Column(BigInteger, nullable=True))
|
||||
engine_type: str = Field(max_length=64)
|
||||
origin: Optional[int] = Field(sa_column=Column(Integer, nullable=False, default=0)) # 0: default, 1: mcp, 2: assistant
|
||||
origin: Optional[int] = Field(
|
||||
sa_column=Column(Integer, nullable=False, default=0)) # 0: default, 1: mcp, 2: assistant
|
||||
|
||||
|
||||
class ChatRecord(SQLModel, table=True):
|
||||
@@ -152,11 +153,12 @@ class AiModelQuestion(BaseModel):
|
||||
|
||||
|
||||
class ChatQuestion(AiModelQuestion):
|
||||
question: str = ''
|
||||
chat_id: int = 0
|
||||
question: str
|
||||
chat_id: int
|
||||
|
||||
|
||||
class ChatMcp(ChatQuestion):
|
||||
token: str = ''
|
||||
token: str
|
||||
|
||||
|
||||
class ChatStart(BaseModel):
|
||||
|
||||
@@ -132,14 +132,24 @@ class AssistantOutDs:
|
||||
def get_db_schema(self, ds_id: int) -> str:
|
||||
ds = self.get_ds(ds_id)
|
||||
schema_str = ""
|
||||
db_name = ds.db_schema
|
||||
#db_name = ds.db_schema
|
||||
db_name = ds.db_schema if ds.db_schema is not None and ds.db_schema != "" else ds.dataBase
|
||||
schema_str += f"【DB_ID】 {db_name}\n【Schema】\n"
|
||||
for table in ds.tables:
|
||||
schema_str += f"# Table: {db_name}.{table.name}"
|
||||
schema_str += f", {table.comment}\n[\n"
|
||||
schema_str += f"# Table: {db_name}.{table.name}" if ds.type != "mysql" else f"# Table: {table.name}"
|
||||
table_comment = table.comment
|
||||
if table_comment == '':
|
||||
schema_str += '\n[\n'
|
||||
else:
|
||||
schema_str += f", {table_comment}\n[\n"
|
||||
|
||||
field_list = []
|
||||
for field in table.fields:
|
||||
field_list.append(f"({field.name}:{field.type}, {field.comment})")
|
||||
field_comment = field.comment
|
||||
if field_comment == '':
|
||||
field_list.append(f"({field.name}:{field.type})")
|
||||
else:
|
||||
field_list.append(f"({field.name}:{field.type}, {field_comment})")
|
||||
schema_str += ",\n".join(field_list)
|
||||
schema_str += '\n]\n'
|
||||
return schema_str
|
||||
|
||||
@@ -76,7 +76,9 @@ def extract_nested_json(text):
|
||||
|
||||
def string_to_numeric_hash(text: str, bits: Optional[int] = 64) -> int:
|
||||
hash_bytes = hashlib.sha256(text.encode()).digest()
|
||||
return int.from_bytes(hash_bytes[:bits//8], byteorder='big')
|
||||
hash_num = int.from_bytes(hash_bytes, byteorder='big')
|
||||
max_bigint = 2**63 - 1
|
||||
return hash_num % max_bigint
|
||||
|
||||
|
||||
def setup_logging():
|
||||
|
||||
@@ -294,7 +294,7 @@
|
||||
"filter": "Filter",
|
||||
"batch_import": "Batch import",
|
||||
"add_users": "Add users",
|
||||
"selected_2_users": "Do you want to delete the selected 2 users?",
|
||||
"selected_2_users": "Do you want to delete the selected {msg} users?",
|
||||
"filter_conditions": "Filter conditions",
|
||||
"enable": "Enable",
|
||||
"disable": "Disable",
|
||||
|
||||
@@ -328,7 +328,7 @@ const back = () => {
|
||||
: $t('datasource.new_data_source')
|
||||
}}</span>
|
||||
<div v-if="!editDatasource" class="flex-center" style="width: 100%">
|
||||
<el-steps custom style="max-width: 500px; flex: 1" :active="activeStep" align-center>
|
||||
<el-steps custom style="max-width: 800px; flex: 1" :active="activeStep" align-center>
|
||||
<el-step>
|
||||
<template #title> {{ $t('qa.select_datasource') }} </template>
|
||||
</el-step>
|
||||
|
||||
@@ -69,7 +69,7 @@ const handleEmbedded = () => {
|
||||
|
||||
<style lang="less" scoped>
|
||||
.card {
|
||||
width: 371px;
|
||||
width: 400px;
|
||||
height: 168px;
|
||||
border: 1px solid #dee0e3;
|
||||
padding: 16px;
|
||||
|
||||
@@ -737,7 +737,9 @@ const saveHandler = () => {
|
||||
<template #label>
|
||||
<div class="private-list">
|
||||
{{ t('embedded.set_data_source') }}
|
||||
<span class="open-the_query">{{ $t('embedded.open_the_query') }} </span>
|
||||
<span :title="$t('embedded.open_the_query')" class="open-the_query ellipsis"
|
||||
>{{ $t('embedded.open_the_query') }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="card-ds_content">
|
||||
@@ -971,6 +973,7 @@ const saveHandler = () => {
|
||||
.open-the_query {
|
||||
color: #ff8800;
|
||||
margin-left: 4px;
|
||||
max-width: 650px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1069,7 +1072,7 @@ const saveHandler = () => {
|
||||
position: relative;
|
||||
}
|
||||
.popover-item {
|
||||
height: 98px;
|
||||
min-height: 98px;
|
||||
display: flex;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
|
||||
Reference in New Issue
Block a user