Skip to content

Commit

Permalink
Feat/0.3.2.1 (#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
zgqgit committed Jul 1, 2024
2 parents 264de56 + 064f931 commit 25cc900
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 72 deletions.
4 changes: 4 additions & 0 deletions src/backend/bisheng/api/services/role_group_service.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import json
from datetime import datetime
from typing import List, Any, Dict
from uuid import UUID

from fastapi.encoders import jsonable_encoder
from fastapi import Request, HTTPException

from bisheng.cache.redis import redis_client
from bisheng.api.services.assistant import AssistantService
from bisheng.api.services.audit_log import AuditLogService
from bisheng.api.services.user_service import UserPayload
Expand Down Expand Up @@ -125,6 +127,8 @@ def delete_group_hook(self, request: Request, login_user: UserPayload, group_inf
GroupResourceDao.delete_group_resource_by_group_id(group_info.id)
# 删除用户组下的角色列表
RoleDao.delete_role_by_group_id(group_info.id)
# 将删除事件发到redis队列中
redis_client.rpush('delete_group', json.dumps({"id": group_info.id}))

def get_group_user_list(self, group_id: int, page_size: int, page_num: int) -> List[User]:
"""获取全量的group列表"""
Expand Down
66 changes: 0 additions & 66 deletions src/backend/bisheng/api/v1/usergroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,69 +202,3 @@ async def get_group_roles(*,
"data": role_list,
"total": total
})


@router.get("/assistant", response_model=UnifiedResponseModel[List[AssistantSimpleInfo]])
async def get_group_assistant(*,
group_id: int = Query(..., description="用户组ID"),
keyword: str = Query(None, description="搜索关键字"),
page: int = 1,
limit: int = 10,
user: UserPayload = Depends(get_login_user)):
"""
获取用户组可见的助手列表
"""
# 判断是否是用户组的管理员
if not user.check_group_admin(group_id):
return UnAuthorizedError.return_resp()

# 查询用户组下的助手ID列表
resource_list = GroupResourceDao.get_group_resource(group_id, ResourceTypeEnum.ASSISTANT)
res = []
total = 0
if resource_list:
assistant_ids = [UUID(resource.third_id) for resource in resource_list] # 查询助手
data, total = AssistantDao.filter_assistant_by_id(assistant_ids, keyword, page, limit)
for one in data:
simple_one = AssistantService.return_simple_assistant_info(one)
res.append(simple_one)
return resp_200(data={
"data": res,
"total": total
})


@router.get("/knowledge", response_model=UnifiedResponseModel[GroupRead])
async def get_group_knowledge(*,
group_id: int = Query(..., description="用户组ID"),
keyword: str = Query(None, description="搜索关键字"),
page: int = 1,
limit: int = 10,
user: UserPayload = Depends(get_login_user)):
"""
获取用户组可见的知识库列表
"""

# 判断是否是用户组的管理员
if not user.check_group_admin(group_id):
return UnAuthorizedError.return_resp()

# 查询用户组下的知识库ID列表
resource_list = GroupResourceDao.get_group_resource(group_id, ResourceTypeEnum.KNOWLEDGE)
res = []
total = 0
if resource_list:
knowledge_ids = [int(resource.third_id) for resource in resource_list]
# 查询知识库
data, total = KnowledgeDao.filter_knowledge_by_ids(knowledge_ids, keyword, page, limit)
db_user_ids = {one.user_id for one in data}
user_list = UserDao.get_user_by_ids(list(db_user_ids))
user_map = {user.user_id: user.user_name for user in user_list}
for one in data:
one_dict = one.model_dump()
one_dict["user_name"] = user_map.get(one.user_id, one.user_id)
res.append(one_dict)
return resp_200(data={
"data": res,
"total": total
})
7 changes: 7 additions & 0 deletions src/backend/bisheng/cache/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ def delete(self, key):
finally:
self.close()

def rpush(self, key, value):
try:
self.cluster_nodes(key)
return self.connection.rpush(key, value)
finally:
self.close()

def exists(self, key):
try:
self.cluster_nodes(key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default function ChatInput({ clear, form, stop, questions, inputForm, wsU
handleWsMessage(data)
// 群聊@自己时,开启input
if (['end', 'end_cover'].includes(data.type) && data.receiver?.is_self) {
setInputLock({ locked: true, reason: '' })
setInputLock({ locked: false, reason: '' })
}
}
ws.onclose = (event) => {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/bs-comp/sheets/SkillSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function SkillSheet({ select, children, onSelect }) {
};

const toCreateFlow = () => {
window.open("/build/skills");
window.open(__APP_ENV__.BASE_URL + "/build/skills");
};

const { t } = useTranslation()
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/bs-comp/sheets/ToolsSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function ToolsSheet({ select, onSelect, children }) {
<SearchInput placeholder={t('build.search')} className="mt-6" onChange={(e) => setKeyword(e.target.value)} />
<Button
className="mt-4 w-full"
onClick={() => window.open("/build/tools")}
onClick={() => window.open(__APP_ENV__.BASE_URL + "/build/tools")}
>
{t('create')}{t("tools.createCustomTool")}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/pages/ModelPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function ConfigModal({ data, readonly, open, setOpen, onSave }) {
</div>
</div>
<div className="flex justify-start">
<Button variant='link' onClick={() => window.open('/model/doc')} className="link col-span-8 pl-0">{t('model.modelConfigExplanationLink')}</Button>
<Button variant='link' onClick={() => window.open(__APP_ENV__.BASE_URL + '/model/doc')} className="link col-span-8 pl-0">{t('model.modelConfigExplanationLink')}</Button>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { viteStaticCopy } from 'vite-plugin-static-copy';
import svgr from "vite-plugin-svgr";

// Use environment variable to determine the target.
const target = process.env.VITE_PROXY_TARGET || "http://192.168.106.120:3002";
const target = process.env.VITE_PROXY_TARGET || "http://127.0.0.1:7861";
const apiRoutes = ["^/api/", "/health"];

const proxyTargets = apiRoutes.reduce((proxyObj, route) => {
Expand Down Expand Up @@ -46,7 +46,7 @@ proxyTargets['/custom_base/api'] = {
* 开启后一般外层网管匹配【custom】时直接透传转到内层网关
* 内层网关访问 api或者前端静态资源需要去掉【custom】前缀
*/
// const app_env = { BASE_URL: '/custom' }
// const app_env = { BASE_URL: '/custom_base' }
const app_env = { BASE_URL: '' }

export default defineConfig(() => {
Expand Down

0 comments on commit 25cc900

Please sign in to comment.