Merge remote-tracking branch 'origin/main'

This commit is contained in:
wangjiahao
2025-05-28 16:56:36 +08:00
6 changed files with 58 additions and 19 deletions
@@ -0,0 +1,35 @@
"""008_modify_field_type
Revision ID: 35d925df4568
Revises: ff653d5df198
Create Date: 2025-05-28 12:15:28.296915
"""
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '35d925df4568'
down_revision = 'ff653d5df198'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('core_datasource', 'create_time',
existing_type=postgresql.TIMESTAMP(timezone=True),
type_=sa.DateTime(),
existing_nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('core_datasource', 'create_time',
existing_type=sa.DateTime(),
type_=postgresql.TIMESTAMP(timezone=True),
existing_nullable=True)
# ### end Alembic commands ###
@@ -3,7 +3,7 @@ from typing import Optional, Dict, Any, Type
from abc import ABC, abstractmethod
from langchain_core.language_models import BaseLLM as LangchainBaseLLM
from langchain_openai import ChatOpenAI
from langchain_community.llms import Tongyi, VLLM
# from langchain_community.llms import Tongyi, VLLM
class LLMConfig(BaseModel):
"""Base configuration class for large language models"""
@@ -43,7 +43,7 @@ class OpenAILLM(BaseLLM):
def generate(self, prompt: str) -> str:
return self.llm.invoke(prompt)
class TongyiLLM(BaseLLM):
""" class TongyiLLM(BaseLLM):
def _init_llm(self) -> LangchainBaseLLM:
return Tongyi(
model_name=self.config.model_name,
@@ -62,7 +62,7 @@ class VLLMLLM(BaseLLM):
)
def generate(self, prompt: str) -> str:
return self.llm.invoke(prompt)
return self.llm.invoke(prompt) """
class LLMFactory:
@@ -70,8 +70,8 @@ class LLMFactory:
_llm_types: Dict[str, Type[BaseLLM]] = {
"openai": OpenAILLM,
"tongyi": TongyiLLM,
"vllm": VLLMLLM
"tongyi": OpenAILLM,
"vllm": OpenAILLM
}
@classmethod
+1 -1
View File
@@ -14,7 +14,7 @@ class CoreDatasource(SQLModel, table=True):
type: str = Field(max_length=64)
type_name: str = Field(max_length=64, nullable=True)
configuration: str = Field(sa_column=Column(Text))
create_time: datetime = Field(sa_column=Column(DateTime(timezone=True), nullable=True))
create_time: datetime = Field(sa_column=Column(DateTime(timezone=False), nullable=True))
create_by: int = Field(sa_column=Column(BigInteger()))
status: str = Field(max_length=64, nullable=True)
+5 -2
View File
@@ -1,20 +1,23 @@
# Author: Junjun
# Date: 2025/5/19
import urllib.parse
from typing import List
from sqlalchemy import create_engine, text, MetaData, Table
from sqlalchemy.orm import sessionmaker
from apps.datasource.models.datasource import DatasourceConf
from common.core.config import settings
def get_engine_config():
return DatasourceConf(username="root", password="123456", host="127.0.0.1", port=5432, database="sqlbot",
return DatasourceConf(username=settings.POSTGRES_USER, password=settings.POSTGRES_PASSWORD,
host="127.0.0.1", port=settings.POSTGRES_PORT, database=settings.POSTGRES_DB,
dbSchema="public")
def get_engine_uri(conf: DatasourceConf):
return f"postgresql+psycopg2://{conf.username}:{conf.password}@{conf.host}:{conf.port}/{conf.database}"
return f"postgresql+psycopg2://{urllib.parse.quote(conf.username)}:{urllib.parse.quote(conf.password)}@{conf.host}:{conf.port}/{urllib.parse.quote(conf.database)}"
def get_engine_conn():
-1
View File
@@ -24,7 +24,6 @@ dependencies = [
"langchain-openai>=0.3,<0.4",
"langchain-community>=0.3,<0.4",
"langgraph>=0.3,<0.4",
"vllm>=0.8.5",
"dashscope>=1.14.0,<2.0.0",
"pymysql (>=1.1.1,<2.0.0)",
"cryptography (>=44.0.3,<45.0.0)",
+12 -10
View File
@@ -1,16 +1,16 @@
<template>
<el-dialog
v-model="dialogVisible"
:title="title"
:title="dialogTitle"
width="600"
:destroy-on-close="true"
:close-on-click-modal="false"
@closed="close"
modal-class="add-datasource_dialog"
>
<template #header="{ title }">
<template #header="">
<div style="display: flex">
<div style="margin-right: 24px">{{ title }}</div>
<div style="margin-right: 24px">{{ dialogTitle }}</div>
<el-steps
v-show="isCreate"
:active="active"
@@ -58,7 +58,7 @@
:disabled="!isCreate"
accept=".xls, .xlsx, .csv"
:headers="headers"
action="http://localhost:8000/api/v1/datasource/uploadExcel"
:action="getUploadURL"
:before-upload="beforeUpload"
:on-success="onSuccess"
>
@@ -118,7 +118,7 @@
:width="560"
:height="400"
:scrollbarAlwaysOn="true"
class-name="el-select-dropdown__list"
class-name="ed-select-dropdown__list"
layout="vertical"
>
<template #default="{ index, style }">
@@ -177,10 +177,12 @@ const isEditTable = ref(false);
const checkList = ref<any>([]);
const tableList = ref<any>([]);
const excelUploadSuccess = ref(false);
const tableListLoading = ref(true);
const tableListLoading = ref(false);
const token = wsCache.get("user.token");
const headers = ref<any>({ "X-SQLBOT-TOKEN": `Bearer ${token}` });
const title = ref("");
const dialogTitle = ref("");
const getUploadURL = import.meta.env.VITE_API_BASE_URL + '/datasource/uploadExcel'
const rules = reactive<FormRules>({
name: [
@@ -223,7 +225,7 @@ const close = () => {
const open = (item: any, editTable: boolean = false) => {
isEditTable.value = false;
if (item) {
title.value = "Edit Datasource";
dialogTitle.value = "Edit Datasource";
isCreate.value = false;
form.value.id = item.id;
form.value.name = item.name;
@@ -245,7 +247,7 @@ const open = (item: any, editTable: boolean = false) => {
}
if (editTable) {
title.value = "Choose Tables";
dialogTitle.value = "Choose Tables";
active.value = 1;
isEditTable.value = true;
isCreate.value = false;
@@ -278,7 +280,7 @@ const open = (item: any, editTable: boolean = false) => {
});
}
} else {
title.value = "Add Datasource";
dialogTitle.value = "Add Datasource";
isCreate.value = true;
isEditTable.value = false;
checkList.value = [];