Skip to content

Commit

Permalink
Feat/0.3.3 (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
zgqgit committed Jul 12, 2024
2 parents 948fc5d + c461eee commit 2292f44
Show file tree
Hide file tree
Showing 34 changed files with 509 additions and 130 deletions.
4 changes: 2 additions & 2 deletions src/backend/bisheng/api/v1/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ def get_chatlist_list(*,
create_time=message.create_time,
update_time=message.update_time))
else:
# 通过接口创建的会话记录,不关联技能或者助手
logger.debug(f'unknown message.flow_id={message.flow_id}')
# 通过接口创建的会话记录,不关联技能或者助手, 或者技能和助手已被删除
pass
res = chat_list[(page - 1) * limit:page * limit]
chat_ids = [one.chat_id for one in res]
latest_messages = ChatMessageDao.get_latest_message_by_chat_ids(chat_ids, 'answer')
Expand Down
4 changes: 2 additions & 2 deletions src/backend/bisheng/chat/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from bisheng.api.services.audit_log import AuditLogService
from bisheng.api.services.user_service import UserPayload
from bisheng.api.utils import build_flow_no_yield
from bisheng.api.utils import build_flow_no_yield, get_request_ip
from bisheng.api.v1.schemas import ChatMessage, ChatResponse, FileResponse
from bisheng.cache import cache_manager
from bisheng.cache.flow import InMemoryCache
Expand Down Expand Up @@ -410,7 +410,7 @@ async def _process_when_payload(self, flow_id: str, chat_id: str,
"user_id": user_id,
"user_name": UserDao.get_user(user_id).user_name,
})
AuditLogService.create_chat_flow(login_user, websocket.client.host, flow_id)
AuditLogService.create_chat_flow(login_user, get_request_ip(websocket), flow_id)
start_resp.type = 'start'

# should input data
Expand Down
16 changes: 16 additions & 0 deletions src/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
<link rel="icon" href="/favicon.ico" />
<%- aceScriptSrc %>
<title>BISHENG</title>
<!-- style -->
<script>
fetch('/api/v1/web/config').then(function (res) {
return res.json()
}).then(function (res) {
console.log('res :>> ', res.data);
var styleStr = res.data ? res.data.value : ''
var style = styleStr ? JSON.parse(styleStr) : {comp: {}}
window.ThemeStyle = style
Object.keys(style.comp).forEach(key => {
var hsl = style.comp[key]
var hslStr = `${hsl.h} ${hsl.s * 100}% ${hsl.l * 100}%`
document.documentElement.style.setProperty(key, hslStr);
});
})
</script>
</head>

<body id='body' style="width: 100%; height:100%">
Expand Down
48 changes: 46 additions & 2 deletions src/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"react": "^18.2.0",
"react-ace": "^10.1.0",
"react-beautiful-dnd": "^13.1.1",
"react-color": "^2.19.3",
"react-cookie": "^4.1.1",
"react-day-picker": "^8.10.1",
"react-dom": "^18.2.0",
Expand Down
24 changes: 7 additions & 17 deletions src/frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -189,33 +189,23 @@
.build-tab {}

.build-tab a.active {
color: #024FE5;
background: #fff;
box-shadow: 1px 1px 2px 0 #e9e9e9
/* background: #F4F5F8;
padding: 10px 40px; */
}

.build-tab a.active>svg {
color: #024FE5 !important;
color: hsl(var(--primary)) !important;
}

.build-tab a {
color: #666;
/* background: #F4F5F8;
padding: 10px 40px; */
}

.build-tab a>svg {
color: #666;
.build-tab a.active>span {
color: hsl(var(--primary)) !important;
}

.build-tab a:hover {
color: #024FE5;
:is(.dark .build-tab a.active>svg){
color: #fff !important;
}

.build-tab a:hover>svg {
color: #024FE5;
:is(.dark .build-tab a.active>span){
color: #fff !important;
}

.bs-chat-bg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default function CardComponent<T>({


// 技能组件
return <Card className="group w-[320px] cursor-pointer bg-background-Assistant hover:bg-background-hoverAssistant" onClick={() => edit && onClick()}>
return <Card className="group w-[320px] hover:bg-card/80 cursor-pointer" onClick={() => edit && onClick()}>
<CardHeader>
<div className="flex justify-between pb-2">
<TitleIconBg id={id} >
Expand Down
38 changes: 15 additions & 23 deletions src/frontend/src/components/bs-comp/chatComponent/ChatInput.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { ClearIcon } from "@/components/bs-icons/clear";
import { FormIcon } from "@/components/bs-icons/form";
import { SendIcon } from "@/components/bs-icons/send";
import { Button } from "@/components/bs-ui/button";
import { Textarea } from "@/components/bs-ui/input";
import { useToast } from "@/components/bs-ui/toast/use-toast";
import { locationContext } from "@/contexts/locationContext";
import { PauseIcon } from "@radix-ui/react-icons";
import { useContext, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { useMessageStore } from "./messageStore";
import GuideQuestions from "./GuideQuestions";
import { ClearIcon } from "@/components/bs-icons/clear";
import { Button } from "@/components/bs-ui/button";
import { PauseIcon, StopIcon } from "@radix-ui/react-icons";
import { useMessageStore } from "./messageStore";
import { formatDate } from "@/util/utils";
import { StopIcon } from "@radix-ui/react-icons";

export default function ChatInput({ clear, form, stop, questions, inputForm, wsUrl, onBeforSend }) {
const { toast } = useToast()
Expand Down Expand Up @@ -198,6 +200,7 @@ export default function ChatInput({ clear, form, stop, questions, inputForm, wsU
const handleWsMessage = (data) => {
if (Array.isArray(data) && data.length) return
if (data.type === 'start') {
setStoped(false)
createWsMsg(data)
} else if (data.type === 'stream') {
//@ts-ignore
Expand All @@ -213,13 +216,12 @@ export default function ChatInput({ clear, form, stop, questions, inputForm, wsU
thought: data.intermediate_steps || '',
messageId: data.message_id,
noAccess: false,
liked: 0
liked: 0,
update_time: formatDate(new Date(), 'yyyy-MM-ddTHH:mm:ss')
}, data.type === 'end_cover')
} else if (data.type === "close") {
setStoped(true)
setInputLock({ locked: false, reason: '' })
} else if (data.type === 'begin') {
setStoped(false)
}
}

Expand Down Expand Up @@ -289,11 +291,14 @@ export default function ChatInput({ clear, form, stop, questions, inputForm, wsU
</div>
{/* send */}
<div className="flex gap-2 absolute right-3 top-4 z-10">
<div
{stoped && <div
id="bs-send-btn"
className="w-6 h-6 rounded-sm hover:bg-gray-200 cursor-pointer flex justify-center items-center"
onClick={() => { !inputLock.locked && handleSendClick() }}
><SendIcon className={`${inputLock.locked ? 'text-gray-400' : 'text-gray-950'} dark:text-slate-50 dark:hover:bg-gray-500`}></SendIcon></div>
onClick={() => { !inputLock.locked && handleSendClick() }}>
<SendIcon className={`${inputLock.locked ? 'text-gray-400' : 'text-gray-950'} dark:text-slate-50 dark:hover:bg-gray-500`}/>
</div>}
{!stoped && <StopIcon className="mt-1 rounded-sm bg-gray-950 text-gray-950 dark:bg-slate-50 dark:text-gray-50 cursor-pointer"
onClick={() => { setStoped(true); sendWsMsg({ "action": "stop" }); }}/>}
</div>
{/* question */}
<Textarea
Expand All @@ -312,19 +317,6 @@ export default function ChatInput({ clear, form, stop, questions, inputForm, wsU
}
}}
></Textarea>
{/* stop */}
{
stop && <div className=" absolute w-full flex justify-center bottom-32">
<Button
className="rounded-full"
variant="outline"
disabled={stoped}
onClick={() => { setStoped(true); sendWsMsg({ "action": "stop" }); }}
>
<PauseIcon className="mr-2" />Stop
</Button>
</div>
}
</div>
<p className="text-center text-sm pt-2 pb-4 text-gray-400">{appConfig.dialogTips}</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export default function MessageBs({ data, onUnlike = () => { }, onSource }: { da
const chatId = useMessageStore(state => state.chatId)

return <div className="flex w-full">
<div className="w-fit max-w-[90%]">
<div className={`text-right hover:opacity-100 opacity-0`}>
<div className="w-fit group max-w-[90%]">
<div className={`text-right group-hover:opacity-100 opacity-0`}>
<span className="text-slate-400 text-sm">{formatStrTime(data.update_time, 'MM 月 dd 日 HH:mm')}</span>
</div>
{data.sender && <p className="text-gray-600 text-xs mb-2">{data.sender}</p>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function MessagePanne({ useName, guideWord, loadMore }) {
} else if (msg.files?.length) {
type = 'file'
} else if (['tool', 'flow', 'knowledge'].includes(msg.category)
|| (msg.category === 'processing' && msg.thought.indexOf(`status_code`) === -1)
// || (msg.category === 'processing' && msg.thought.indexOf(`status_code`) === -1)
) { // 项目演示?
type = 'runLog'
} else if (msg.thought) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { locationContext } from "@/contexts/locationContext";
import { ChatMessageType } from "@/types/chat";
import { formatStrTime } from "@/util/utils";
import { MagnifyingGlassIcon, Pencil2Icon, ReloadIcon } from "@radix-ui/react-icons";
import { useContext, useState } from "react";
import { useContext } from "react";
import { useMessageStore } from "./messageStore";
import { formatStrTime } from "@/util/utils";

export default function MessageUser({ useName = 'xxx', data }: { data: ChatMessageType }) {
const msg = data.message[data.chatKey]
Expand All @@ -26,8 +26,8 @@ export default function MessageUser({ useName = 'xxx', data }: { data: ChatMessa
}

return <div className="flex justify-end w-full">
<div className="w-fit min-h-8 max-w-[90%]">
<div className={`text-right hover:opacity-100 opacity-0`}>
<div className="w-fit group min-h-8 max-w-[90%]">
<div className={`text-right group-hover:opacity-100 opacity-0`}>
<span className="text-slate-400 text-sm">{formatStrTime(data.update_time, 'MM 月 dd 日 HH:mm')}</span>
</div>
{useName && <p className="text-gray-600 text-xs mb-2 text-right">{useName}</p>}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { message } from '@/components/bs-ui/toast/use-toast';
import { generateUUID } from '@/components/bs-ui/utils'
import { MessageDB, getChatHistory } from '@/controllers/API'
import { ChatMessageType } from '@/types/chat'
import { cloneDeep } from 'lodash'
import { create } from 'zustand'
import { getChatHistory } from '@/controllers/API';
import { ChatMessageType } from '@/types/chat';
import { cloneDeep } from 'lodash';
import { create } from 'zustand';
import { formatDate } from '@/util/utils';

/**
* 会话消息管理
Expand Down Expand Up @@ -138,7 +137,8 @@ export const useMessageStore = create<State & Actions>((set, get) => ({
category: '',
files: [],
end: false,
user_name: ""
user_name: "",
update_time: formatDate(new Date(), 'yyyy-MM-ddTHH:mm:ss')
}]
}))
},
Expand Down
21 changes: 12 additions & 9 deletions src/frontend/src/components/bs-icons/plusBox/PlusBox.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function ConfirmWrapper() {
<div><TipIcon /></div>
{showClose && <Cross2Icon onClick={close} className="absolute right-0 top-[-0.5rem] cursor-pointer text-gray-400 hover:text-gray-600"></Cross2Icon>}
<AlertDialogTitle>{title}</AlertDialogTitle>
<AlertDialogDescription>
<AlertDialogDescription className="text-popover-foreground">
{desc}
</AlertDialogDescription>
</AlertDialogHeader>
Expand Down
Loading

0 comments on commit 2292f44

Please sign in to comment.