Skip to content

Commit 26c68fb

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 1cc4382 + a3e4f5b commit 26c68fb

File tree

14 files changed

+292
-168
lines changed

14 files changed

+292
-168
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""032_modify_assistant_ddl
2+
3+
Revision ID: 6549e47f9adc
4+
Revises: bd2ed188b5bd
5+
Create Date: 2025-07-22 12:23:16.646665
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
import sqlmodel.sql.sqltypes
11+
12+
13+
# revision identifiers, used by Alembic.
14+
revision = '6549e47f9adc'
15+
down_revision = 'bd2ed188b5bd'
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
op.add_column('sys_assistant', sa.Column('description', sa.Text(), nullable=True))
22+
23+
24+
def downgrade():
25+
op.drop_column('sys_assistant', 'description')

backend/apps/system/api/assistant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def info(session: SessionDep, id: str, virtual: Optional[int] = Query(None
4545

4646
@router.get("", response_model=list[AssistantModel])
4747
async def query(session: SessionDep):
48-
list_result = session.exec(select(AssistantModel).order_by(AssistantModel.create_time)).all()
48+
list_result = session.exec(select(AssistantModel).order_by(AssistantModel.create_time.asc())).all()
4949
return list_result
5050

5151
@router.post("")

backend/apps/system/api/workspace.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ async def option_pager(
2929
pagination = PaginationParams(page=pageNum, size=pageSize)
3030
paginator = Paginator(session)
3131
stmt = select(UserModel.id, UserModel.account, UserModel.name).where(
32-
~exists().where(UserWsModel.uid == UserModel.id, UserWsModel.oid == oid)
33-
).order_by(UserModel.create_time)
32+
~exists().where(UserWsModel.uid == UserModel.id, UserWsModel.oid == oid),
33+
UserModel.id != 1
34+
).order_by(UserModel.create_time.asc())
3435

3536
if keyword:
3637
keyword_pattern = f"%{keyword}%"
@@ -51,12 +52,15 @@ async def option_user(
5152
current_user: CurrentUser,
5253
keyword: str = Query(description="搜索关键字")
5354
):
55+
if not keyword:
56+
raise HTTPException("keyword is required")
5457
if (not current_user.isAdmin) and current_user.weight == 0:
5558
raise RuntimeError("no permission to execute this api")
5659
oid = current_user.oid
5760

5861
stmt = select(UserModel.id, UserModel.account, UserModel.name).where(
59-
~exists().where(UserWsModel.uid == UserModel.id, UserWsModel.oid == oid)
62+
~exists().where(UserWsModel.uid == UserModel.id, UserWsModel.oid == oid),
63+
UserModel.id != 1
6064
)
6165

6266
if keyword:
@@ -89,7 +93,8 @@ async def pager(
8993
UserWsModel, UserModel.id == UserWsModel.uid
9094
).where(
9195
UserWsModel.oid == workspace_id,
92-
).order_by(UserModel.create_time)
96+
UserModel.id != 1
97+
).order_by(UserModel.create_time.asc())
9398

9499
if keyword:
95100
keyword_pattern = f"%{keyword}%"
@@ -163,7 +168,7 @@ async def delete(session: SessionDep, current_user: CurrentUser, dto: UserWsBase
163168

164169
@router.get("", response_model=list[WorkspaceModel])
165170
async def query(session: SessionDep, trans: Trans):
166-
list_result = session.exec(select(WorkspaceModel).order_by(WorkspaceModel.create_time)).all()
171+
list_result = session.exec(select(WorkspaceModel).order_by(WorkspaceModel.create_time.asc())).all()
167172
for ws in list_result:
168173
if ws.name.startswith('i18n'):
169174
ws.name = trans(ws.name)
@@ -182,8 +187,7 @@ async def update(session: SessionDep, editor: WorkspaceEditor):
182187
db_model = session.get(WorkspaceModel, id)
183188
if not db_model:
184189
raise HTTPException(f"WorkspaceModel with id {id} not found")
185-
update_data = WorkspaceModel.model_validate(editor)
186-
db_model.sqlmodel_update(update_data)
190+
db_model.name = editor.name
187191
session.add(db_model)
188192
session.commit()
189193

backend/apps/system/models/system_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class AssistantBaseModel(SQLModel):
4747
name: str = Field(max_length=255, nullable=False)
4848
type: int = Field(nullable=False, default=0)
4949
domain: str = Field(max_length=255, nullable=False)
50+
description: str = Field(sa_type = Text(), nullable=True)
5051
configuration: Optional[str] = Field(sa_type = Text(), nullable=True)
5152
create_time: int = Field(default=0, sa_type=BigInteger())
5253

backend/apps/system/schemas/system_schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class AssistantBase(BaseModel):
6868
domain: str
6969
type: int = 0
7070
configuration: Optional[str] = None
71+
description: Optional[str] = None
7172
class AssistantDTO(AssistantBase, BaseCreatorDTO):
7273
pass
7374

backend/common/core/sqlbot_cache.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ async def wrapper(*args, **kwargs):
164164
)
165165

166166
async with _get_cache_lock(cache_key):
167-
await FastAPICache.clear(key=cache_key)
168-
result = await func(*args, **kwargs)
169-
logging.info(f"Clearing cache for key: {cache_key}")
170-
print(f"Clearing cache for key: {cache_key}")
171-
return result
167+
if await FastAPICache.get_backend().get(cache_key):
168+
await FastAPICache.clear(key=cache_key)
169+
result = await func(*args, **kwargs)
170+
logging.info(f"Clearing cache for key: {cache_key}")
171+
print(f"Clearing cache for key: {cache_key}")
172+
return result
173+
return await func(*args, **kwargs)
172174

173175
return wrapper
174176
return decorator

frontend/src/api/embedded.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { request } from '@/utils/request'
2+
3+
export const getList = () => request.get('/system/assistant')
4+
export const updateAssistant = (data: any) => request.put('/system/assistant', data)
5+
export const saveAssistant = (data: any) => request.post('/system/assistant', data)
6+
export const getOne = (id: any) => request.get(`/system/assistant/${id}`)
7+
export const delOne = (id: any) => request.delete(`/system/assistant/${id}`)
Lines changed: 3 additions & 0 deletions
Loading
34 KB
Loading

frontend/src/i18n/en.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@
228228
"got_it": "Got it",
229229
"field_original_notes": "Field original notes",
230230
"field_notes_1": "Field notes",
231-
"no_table":"No Table",
232-
"go_add":"Add"
231+
"no_table": "No Table",
232+
"go_add": "Add"
233233
},
234234
"model": {
235235
"default_model": "Default model",
@@ -430,7 +430,12 @@
430430
"target_credential_name": "Target credential name",
431431
"target_credential": "Target credential",
432432
"edit_advanced_applications": "Edit advanced applications",
433-
"edit_basic_applications": "Edit basic applications"
433+
"edit_basic_applications": "Edit basic applications",
434+
"delete": "delete {msg}?",
435+
"code_to_embed": "Copy the following code to embed",
436+
"floating_window_mode": "Floating window mode",
437+
"copy_successful": "Copy successful",
438+
"copy_failed": "Copy failed"
434439
},
435440
"chat": {
436441
"type": "Chart Type",
@@ -476,4 +481,4 @@
476481
"back_community": "Restore to Community Edition",
477482
"confirm_tips": "Are you sure to restore to Community Edition?"
478483
}
479-
}
484+
}

0 commit comments

Comments
 (0)