Skip to content

Commit d2a4821

Browse files
committed
2 parents 41f0757 + 099bae8 commit d2a4821

File tree

17 files changed

+195
-40
lines changed

17 files changed

+195
-40
lines changed

backend/apps/chat/api/chat.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from fastapi.responses import StreamingResponse
99

1010
from apps.chat.curd.chat import list_chats, get_chat_with_records, create_chat, rename_chat, \
11-
delete_chat, get_chat_chart_data, get_chat_predict_data
11+
delete_chat, get_chat_chart_data, get_chat_predict_data, get_chat_with_records_with_data
1212
from apps.chat.models.chat_model import CreateChat, ChatRecord, RenameChat, ChatQuestion, ExcelData
1313
from apps.chat.task.llm import LLMService
1414
from common.core.deps import CurrentAssistant, SessionDep, CurrentUser
@@ -33,6 +33,18 @@ async def get_chat(session: SessionDep, current_user: CurrentUser, chart_id: int
3333
)
3434

3535

36+
@router.get("/get/with_data/{chart_id}")
37+
async def get_chat_with_data(session: SessionDep, current_user: CurrentUser, chart_id: int, current_assistant: CurrentAssistant):
38+
try:
39+
return get_chat_with_records_with_data(chart_id=chart_id, session=session, current_user=current_user,
40+
current_assistant=current_assistant)
41+
except Exception as e:
42+
raise HTTPException(
43+
status_code=500,
44+
detail=str(e)
45+
)
46+
47+
3648
@router.get("/record/get/{chart_record_id}/data")
3749
async def chat_record_data(session: SessionDep, chart_record_id: int):
3850
try:
@@ -205,7 +217,8 @@ def inner():
205217

206218
buffer = io.BytesIO()
207219

208-
with pd.ExcelWriter(buffer, engine='xlsxwriter', engine_kwargs={'options': {'strings_to_numbers': True}}) as writer:
220+
with pd.ExcelWriter(buffer, engine='xlsxwriter',
221+
engine_kwargs={'options': {'strings_to_numbers': True}}) as writer:
209222
df.to_excel(writer, sheet_name='Sheet1', index=False)
210223

211224
buffer.seek(0)

backend/apps/chat/curd/chat.py

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ def get_chat_predict_data(session: SessionDep, chart_record_id: int):
6767
return {}
6868

6969

70+
def get_chat_with_records_with_data(session: SessionDep, chart_id: int, current_user: CurrentUser,
71+
current_assistant: CurrentAssistant) -> ChatInfo:
72+
return get_chat_with_records(session, chart_id, current_user, current_assistant, True)
73+
74+
7075
def get_chat_with_records(session: SessionDep, chart_id: int, current_user: CurrentUser,
71-
current_assistant: CurrentAssistant) -> ChatInfo:
76+
current_assistant: CurrentAssistant, with_data: bool = False) -> ChatInfo:
7277
chat = session.get(Chat, chart_id)
7378
if not chat:
7479
raise Exception(f"Chat with id {chart_id} not found")
@@ -96,18 +101,39 @@ def get_chat_with_records(session: SessionDep, chart_id: int, current_user: Curr
96101
ChatRecord.recommended_question, ChatRecord.first_chat,
97102
ChatRecord.finish, ChatRecord.error).where(
98103
and_(ChatRecord.create_by == current_user.id, ChatRecord.chat_id == chart_id)).order_by(ChatRecord.create_time)
104+
if with_data:
105+
stmt = select(ChatRecord.id, ChatRecord.chat_id, ChatRecord.create_time, ChatRecord.finish_time,
106+
ChatRecord.question, ChatRecord.sql_answer, ChatRecord.sql,
107+
ChatRecord.chart_answer, ChatRecord.chart, ChatRecord.analysis, ChatRecord.predict,
108+
ChatRecord.datasource_select_answer, ChatRecord.analysis_record_id, ChatRecord.predict_record_id,
109+
ChatRecord.recommended_question, ChatRecord.first_chat,
110+
ChatRecord.finish, ChatRecord.error, ChatRecord.data, ChatRecord.predict_data).where(
111+
and_(ChatRecord.create_by == current_user.id, ChatRecord.chat_id == chart_id)).order_by(
112+
ChatRecord.create_time)
113+
99114
result = session.execute(stmt).all()
100115
record_list: list[ChatRecord] = []
101116
for row in result:
102-
record_list.append(
103-
ChatRecord(id=row.id, chat_id=row.chat_id, create_time=row.create_time, finish_time=row.finish_time,
104-
question=row.question, sql_answer=row.sql_answer, sql=row.sql,
105-
chart_answer=row.chart_answer, chart=row.chart,
106-
analysis=row.analysis, predict=row.predict,
107-
datasource_select_answer=row.datasource_select_answer,
108-
analysis_record_id=row.analysis_record_id, predict_record_id=row.predict_record_id,
109-
recommended_question=row.recommended_question, first_chat=row.first_chat,
110-
finish=row.finish, error=row.error))
117+
if not with_data:
118+
record_list.append(
119+
ChatRecord(id=row.id, chat_id=row.chat_id, create_time=row.create_time, finish_time=row.finish_time,
120+
question=row.question, sql_answer=row.sql_answer, sql=row.sql,
121+
chart_answer=row.chart_answer, chart=row.chart,
122+
analysis=row.analysis, predict=row.predict,
123+
datasource_select_answer=row.datasource_select_answer,
124+
analysis_record_id=row.analysis_record_id, predict_record_id=row.predict_record_id,
125+
recommended_question=row.recommended_question, first_chat=row.first_chat,
126+
finish=row.finish, error=row.error))
127+
else:
128+
record_list.append(
129+
ChatRecord(id=row.id, chat_id=row.chat_id, create_time=row.create_time, finish_time=row.finish_time,
130+
question=row.question, sql_answer=row.sql_answer, sql=row.sql,
131+
chart_answer=row.chart_answer, chart=row.chart,
132+
analysis=row.analysis, predict=row.predict,
133+
datasource_select_answer=row.datasource_select_answer,
134+
analysis_record_id=row.analysis_record_id, predict_record_id=row.predict_record_id,
135+
recommended_question=row.recommended_question, first_chat=row.first_chat,
136+
finish=row.finish, error=row.error, data=row.data, predict_data=row.predict_data))
111137

112138
result = list(map(format_record, record_list))
113139

backend/apps/system/api/aimodel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def query(
7878
AiModelDetail.default_model)
7979
if keyword is not None:
8080
statement = statement.where(AiModelDetail.name.like(f"%{keyword}%"))
81-
statement = statement.order_by(AiModelDetail.create_time.asc())
81+
statement = statement.order_by(AiModelDetail.default_model.desc(), AiModelDetail.name, AiModelDetail.create_time)
8282
items = session.exec(statement).all()
8383
return items
8484

backend/apps/system/api/assistant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def validator(session: SessionDep, id: int, virtual: Optional[int] = Query
5050

5151
@router.get("", response_model=list[AssistantModel])
5252
async def query(session: SessionDep):
53-
list_result = session.exec(select(AssistantModel).order_by(AssistantModel.create_time.asc())).all()
53+
list_result = session.exec(select(AssistantModel).order_by(AssistantModel.name, AssistantModel.create_time)).all()
5454
return list_result
5555

5656
@router.post("")

backend/apps/system/api/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async def pager(
5959
select(UserModel, UserWsModel.oid.label('ws_oid'))
6060
.join(UserWsModel, UserModel.id == UserWsModel.uid, isouter=True)
6161
.where(UserModel.id.in_(uid_list))
62-
.order_by(UserModel.create_time)
62+
.order_by(UserModel.account, UserModel.create_time)
6363
)
6464
user_workspaces = session.exec(stmt).all()
6565
merged = defaultdict(list)

backend/apps/system/api/workspace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async def option_pager(
3232
stmt = select(UserModel.id, UserModel.account, UserModel.name).where(
3333
~exists().where(UserWsModel.uid == UserModel.id, UserWsModel.oid == oid),
3434
UserModel.id != 1
35-
).order_by(UserModel.create_time.asc())
35+
).order_by(UserModel.account, UserModel.create_time)
3636

3737
if keyword:
3838
keyword_pattern = f"%{keyword}%"
@@ -97,7 +97,7 @@ async def pager(
9797
).where(
9898
UserWsModel.oid == workspace_id,
9999
UserModel.id != 1
100-
).order_by(UserModel.create_time.asc())
100+
).order_by(UserModel.account, UserModel.create_time)
101101

102102
if keyword:
103103
keyword_pattern = f"%{keyword}%"

backend/apps/system/crud/user.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def authenticate(*, session: Session, account: str, password: str) -> BaseUserDT
4646

4747
async def user_ws_options(session: Session, uid: int, trans: Optional[I18n] = None) -> list[UserWs]:
4848
if uid == 1:
49-
stmt = select(WorkspaceModel.id, WorkspaceModel.name).order_by(WorkspaceModel.create_time)
49+
stmt = select(WorkspaceModel.id, WorkspaceModel.name).order_by(WorkspaceModel.name, WorkspaceModel.create_time)
5050
else:
5151
stmt = select(WorkspaceModel.id, WorkspaceModel.name).join(
5252
UserWsModel, UserWsModel.oid == WorkspaceModel.id
5353
).where(
5454
UserWsModel.uid == uid,
55-
).order_by(WorkspaceModel.create_time)
55+
).order_by(WorkspaceModel.name, WorkspaceModel.create_time)
5656
result = session.exec(stmt)
5757
if not trans:
5858
return result.all()

frontend/auto-imports.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// biome-ignore lint: disable
77
export {}
88
declare global {
9+
const ElButton: typeof import('element-plus-secondary/es')['ElButton']
910
const ElMessage: typeof import('element-plus-secondary/es')['ElMessage']
1011
const ElMessageBox: typeof import('element-plus-secondary/es')['ElMessageBox']
1112
const LicenseGenerator: any

frontend/src/api/chat.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ export const chatApi = {
301301
get: (id: number): Promise<ChatInfo> => {
302302
return request.get(`/chat/get/${id}`)
303303
},
304+
get_with_Data: (id: number): Promise<ChatInfo> => {
305+
return request.get(`/chat/get/with_data/${id}`)
306+
},
304307
get_chart_data: (record_id?: number): Promise<any> => {
305308
return request.get(`/chat/record/get/${record_id}/data`)
306309
},

frontend/src/entity/supplier.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const supplierList: Array<{
3535
],
3636
model_options: [
3737
{ name: 'qwen-plus' },
38-
{ name: 'qwen-plus-latest' },
38+
/* { name: 'qwen-plus-latest' }, */
3939
{ name: 'qwen-max' },
4040
{ name: 'qwen-max-latest' },
4141
{ name: 'qwen-turbo' },
@@ -47,10 +47,10 @@ export const supplierList: Array<{
4747
{ name: 'qwen-omni-turbo' },
4848
/* { name: 'qwen-omni-turbo-realtime' },
4949
{ name: 'qwen-omni-turbo-realtime-latest' }, */
50-
{ name: 'qvq-max' },
50+
/* { name: 'qvq-max' },
5151
{ name: 'qvq-max-latest' },
5252
{ name: 'qvq-plus' },
53-
{ name: 'qvq-plus-latest' },
53+
{ name: 'qvq-plus-latest' }, */
5454
],
5555
},
5656
},
@@ -73,7 +73,10 @@ export const supplierList: Array<{
7373
model_config: {
7474
0: {
7575
api_domain: 'https://api.deepseek.com',
76-
model_options: [{ name: 'deepseek-chat' }, { name: 'deepseek-reasoner' }],
76+
model_options: [
77+
{ name: 'deepseek-chat' },
78+
/* { name: 'deepseek-reasoner' } */
79+
],
7780
},
7881
},
7982
},
@@ -87,11 +90,11 @@ export const supplierList: Array<{
8790
common_args: [{ key: 'temperature', val: 1.0, type: 'number', range: '[0, 2]' }],
8891
model_options: [
8992
{ name: 'hunyuan-turbos-latest' },
90-
{ name: 'hunyuan-turbos-longtext-128k-20250325' },
91-
{ name: 'hunyuan-large' },
93+
/* { name: 'hunyuan-turbos-longtext-128k-20250325' },
94+
{ name: 'hunyuan-large' }, */
9295
{ name: 'hunyuan-standard-256K' },
9396
{ name: 'hunyuan-standard' },
94-
{ name: 'hunyuan-lite' },
97+
/* { name: 'hunyuan-lite' }, */
9598
],
9699
},
97100
},
@@ -103,13 +106,16 @@ export const supplierList: Array<{
103106
model_config: {
104107
0: {
105108
api_domain: 'https://spark-api-open.xf-yun.com/v1/',
106-
common_args: [{ key: 'temperature', val: 1.0, type: 'number', range: '[0, 2]' }],
109+
common_args: [
110+
{ key: 'temperature', val: 1.0, type: 'number', range: '[0, 2]' },
111+
{ key: 'max_tokens', val: 4096, type: 'number', range: '[1, 32768]' },
112+
],
107113
model_options: [
108114
{
109115
name: '4.0Ultra',
110116
args: [{ key: 'max_tokens', val: 32768, type: 'number', range: '[1, 32768]' }],
111117
},
112-
{
118+
/* {
113119
name: 'generalv3.5',
114120
args: [{ key: 'max_tokens', val: 4096, type: 'number', range: '[1, 8192]' }],
115121
},
@@ -128,7 +134,7 @@ export const supplierList: Array<{
128134
{
129135
name: 'lite',
130136
args: [{ key: 'max_tokens', val: 4096, type: 'number', range: '[1, 4096]' }],
131-
},
137+
}, */
132138
{
133139
name: 'x1',
134140
args: [

0 commit comments

Comments
 (0)