Skip to content

Commit

Permalink
Feat/0.2.2.5 (#324)
Browse files Browse the repository at this point in the history
1. 技能提示文案
2. 新的rt模型支持
  • Loading branch information
yaojin3616 authored Feb 4, 2024
2 parents 1907d65 + d7dd130 commit 3cdd480
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/backend/bisheng/api/v1/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def read_flows(*,
payload = json.loads(Authorize.get_jwt_subject())
try:
sql = select(Flow.id, Flow.user_id, Flow.name, Flow.status, Flow.create_time,
Flow.update_time, Flow.description)
Flow.update_time, Flow.description, Flow.guide_word)
count_sql = select(func.count(Flow.id))
if 'admin' != payload.get('role'):
with session_getter() as session:
Expand Down
2 changes: 2 additions & 0 deletions src/backend/bisheng/database/models/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FlowBase(SQLModelSerializable):
onupdate=text('CURRENT_TIMESTAMP')))
create_time: Optional[datetime] = Field(default=(datetime.now()).strftime('%Y-%m-%d %H:%M:%S'),
index=True)
guide_word: Optional[str] = Field(index=False)

@validator('data')
def validate_json(v):
Expand Down Expand Up @@ -72,3 +73,4 @@ class FlowUpdate(SQLModelSerializable):
description: Optional[str] = None
data: Optional[Dict] = None
status: Optional[int] = None
guide_word: Optional[str] = None
2 changes: 2 additions & 0 deletions src/backend/bisheng/database/models/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class TemplateSkillBase(SQLModelSerializable):
nullable=False,
server_default=text('CURRENT_TIMESTAMP'),
onupdate=text('CURRENT_TIMESTAMP')))
guide_word: Optional[str] = Field(index=False)


class Template(TemplateSkillBase, table=True):
Expand All @@ -40,3 +41,4 @@ class TemplateUpdate(SQLModelSerializable):
description: Optional[str] = None
data: Optional[Dict] = None
order_num: Optional[int] = None
guide_word: Optional[str] = None
1 change: 1 addition & 0 deletions src/frontend/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ server {
root /data/webroot/bisheng;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
add_header X-Frame-Options SAMEORIGIN;
}

location /api {
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/contexts/locationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export function LocationProvider({ children }: { children: ReactNode }) {
isDev: res.env === 'dev',
libAccepts: res.uns_support,
officeUrl: res.office_url,
dialogTips: res.dialog_tips
dialogTips: res.dialog_tips,
dialogQuickSearch: res.dialog_quick_search
})
})
}, [])
Expand Down
20 changes: 16 additions & 4 deletions src/frontend/src/pages/ChatAppPage/components/ChatMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Bot, Copy, File, User } from "lucide-react";
import { Bot, Copy, File, PenLine, RefreshCw, Search, User } from "lucide-react";
import { useContext, useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import ReactMarkdown from "react-markdown";
Expand All @@ -13,6 +13,7 @@ import { downloadFile } from "../../../util/utils";
import { checkSassUrl } from "./FileView";
import Thumbs from "./Thumbs";
import { Button } from "../../../components/ui/button";
import { locationContext } from "../../../contexts/locationContext";

// 颜色列表
const colorList = [
Expand Down Expand Up @@ -45,13 +46,19 @@ const enum SourceType {
interface IProps {
chat: ChatMessageType,
userName: string,
disabledReSend: boolean
showSearch: boolean
onSource: () => void
onDislike?: (chatId) => void
onReSend: (msg) => void
onEdit: (msg) => void
onSearch: (msg) => void
}

export const ChatMessage = ({ chat, userName, onSource, onDislike }: IProps) => {
export const ChatMessage = ({ chat, userName, disabledReSend, showSearch, onSource, onDislike, onEdit, onReSend, onSearch }: IProps) => {
// const { user } = useContext(userContext);
// console.log('chat :>> ', chat);
const { appConfig } = useContext(locationContext)

const textRef = useRef(null)
const { t } = useTranslation()
Expand Down Expand Up @@ -184,7 +191,7 @@ export const ChatMessage = ({ chat, userName, onSource, onDislike }: IProps) =>
}
</div>;
case SourceType.HAS_QA:
return <p className="flex items-center text-gray-400 pb-2">{extra.qa}</p>;
return <a className={`flex items-center text-gray-400 pb-2 ${extra.url && 'hover:underline'}`} target="_blank" href={extra.url}>{extra.qa}</a>;
default:
return null;
}
Expand Down Expand Up @@ -218,9 +225,14 @@ export const ChatMessage = ({ chat, userName, onSource, onDislike }: IProps) =>
if (chat.isSend) return <div className="chat chat-end">
<div className="chat-image avatar"><div className="w-[40px] h-[40px] rounded-full bg-[rgba(53,126,249,.6)] flex items-center justify-center"><User color="#fff" size={28} /></div></div>
<div className="chat-header text-gray-400 text-sm">{userName}</div>
<div className="chat-bubble chat-bubble-info bg-[rgba(53,126,249,.15)] dark:text-gray-100 whitespace-pre-line text-sm min-h-8">
<div className="chat-bubble chat-bubble-info bg-[rgba(53,126,249,.15)] dark:text-gray-100 whitespace-pre-line text-sm min-h-8 pb-8 relative min-w-[110px]">
{chat.category === 'loading' && <span className="loading loading-spinner loading-xs mr-4 align-middle"></span>}
{chat.message[chat.chatKey]}
<div className='flex gap-2 absolute w-full left-0 bottom-[8px] justify-end pr-5'>
<PenLine size={18} className="cursor-pointer hover:text-blue-600 text-blue-400" onClick={() => !disabledReSend && onEdit(chat.message[chat.chatKey])}></PenLine>
{!disabledReSend && <RefreshCw size={18} className="cursor-pointer hover:text-blue-600 text-blue-400" onClick={() => onReSend(chat.message[chat.chatKey])}></RefreshCw>}
{showSearch && <Search size={18} className="cursor-pointer hover:text-blue-600 text-blue-400" onClick={() => onSearch(chat.message[chat.chatKey])}></Search>}
</div>
</div>
</div>
{/* 文件 */ }
Expand Down
8 changes: 8 additions & 0 deletions src/frontend/src/pages/ChatAppPage/components/ChatPanne.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,16 @@ export default forwardRef(function ChatPanne({ chatId, flow, queryString, versio
key={c.id || i}
userName={sendUserName}
chat={c}
disabledReSend={inputDisabled}
showSearch={!!appConfig.dialogQuickSearch}
onSource={() => setSouce(c)}
onDislike={(chatId) => { thumbRef.current?.openModal(chatId) }}
onReSend={(msg) => {
inputRef.current.value = msg
handleSend()
}}
onEdit={(msg) => { inputRef.current.value = msg }}
onSearch={(msg) => window.open(appConfig.dialogQuickSearch + encodeURIComponent(msg))}
></ChatMessage>)
}
</div>
Expand Down
60 changes: 31 additions & 29 deletions src/frontend/src/pages/ChatAppPage/components/ChatReportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,37 +57,39 @@ export default function ChatReportForm({ flow, onStart }) {
}

return <div className="absolute right-20 bottom-32 w-[90%] max-w-[680px] flex flex-col gap-6 rounded-xl p-4 md:p-6 border bg-gray-50">
{items.map((item, i) => <div key={item.id} className="w-full text-sm">
{item.name}
<span className="text-status-red">{item.required ? " *" : ""}</span>
<div className="mt-2">
{item.type === VariableType.Text ? <InputComponent
password={false}
value={item.value}
onChange={(val) => handleChange(i, val)}
/> :
item.type === VariableType.Select ?
<Dropdown
options={item.options.map(e => e.value)}
onSelect={(val) => handleChange(i, val)}
value={item.value}
></Dropdown> :
item.type === VariableType.File ?
<InputFileComponent
isSSO
disabled={false}
placeholder={t('report.fileRequired')}
value={''}
onChange={(e) => fileKindexVpath.current[i] = e}
fileTypes={["pdf"]}
suffixes={flow.data.nodes.find(el => el.id === item.nodeId)
?.data.node.template.file_path.suffixes || ['xxx']}
onFileChange={(val: string) => handleChange(i, val)}
></InputFileComponent> : <></>
}
<div className="max-h-[600px] overflow-y-auto">
{items.map((item, i) => <div key={item.id} className="w-full text-sm">
{item.name}
<span className="text-status-red">{item.required ? " *" : ""}</span>
<div className="mt-2">
{item.type === VariableType.Text ? <InputComponent
password={false}
value={item.value}
onChange={(val) => handleChange(i, val)}
/> :
item.type === VariableType.Select ?
<Dropdown
options={item.options.map(e => e.value)}
onSelect={(val) => handleChange(i, val)}
value={item.value}
></Dropdown> :
item.type === VariableType.File ?
<InputFileComponent
isSSO
disabled={false}
placeholder={t('report.fileRequired')}
value={''}
onChange={(e) => fileKindexVpath.current[i] = e}
fileTypes={["pdf"]}
suffixes={flow.data.nodes.find(el => el.id === item.nodeId)
?.data.node.template.file_path.suffixes || ['xxx']}
onFileChange={(val: string) => handleChange(i, val)}
></InputFileComponent> : <></>
}
</div>
</div>
)}
</div>
)}
<Button size="sm" onClick={handleStart}>{t('report.start')}</Button>
</div>
};
1 change: 1 addition & 0 deletions src/frontend/src/types/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export type AppConfig = {
uns_support: string[];
office_url: string;
dialog_tips: string;
dialog_quick_search: string;
};

0 comments on commit 3cdd480

Please sign in to comment.