feat: 使用langchain实现插件功能

This commit is contained in:
Hk-Gosuto
2023-07-22 15:38:44 +08:00
parent 9223f95726
commit 2bb421b8bf
12 changed files with 906 additions and 128 deletions

View File

@@ -34,8 +34,6 @@ import AutoIcon from "../icons/auto.svg";
import BottomIcon from "../icons/bottom.svg";
import StopIcon from "../icons/pause.svg";
import RobotIcon from "../icons/robot.svg";
import SearchCloseIcon from "../icons/search_close.svg";
import SearchOpenIcon from "../icons/search_open.svg";
import CheckmarkIcon from "../icons/checkmark.svg";
import {
@@ -404,11 +402,11 @@ export function ChatActions(props: {
const navigate = useNavigate();
const chatStore = useChatStore();
// switch web search
const webSearch = chatStore.currentSession().webSearch;
function switchWebSearch() {
// switch tools
const useTools = chatStore.currentSession().useTools;
function switchUseTools() {
chatStore.updateCurrentSession((session) => {
session.webSearch = !session.webSearch;
session.useTools = !session.useTools;
});
}
@@ -513,15 +511,15 @@ export function ChatActions(props: {
icon={<RobotIcon />}
/>
<ChatAction
onClick={switchWebSearch}
{/* <ChatAction
onClick={switchUseTools}
text={
webSearch
? Locale.Chat.InputActions.CloseWebSearch
: Locale.Chat.InputActions.OpenWebSearch
useTools
? Locale.Chat.InputActions.CloseTools
: Locale.Chat.InputActions.OpenTools
}
icon={webSearch ? <SearchOpenIcon /> : <SearchCloseIcon />}
/>
icon={useTools ? <SearchOpenIcon /> : <SearchCloseIcon />}
/> */}
{showModelSelector && (
<Selector
@@ -1149,20 +1147,27 @@ export function Chat() {
</div>
)}
</div>
<div>
<div className={styles["chat-message-tools-status"]}>
<div className={styles["chat-message-tools-name"]}>
<CheckmarkIcon
className={styles["chat-message-checkmark"]}
/>
web search:
<code className={styles["chat-message-tools-details"]}>
xxxxxxxxxxxxxxxx
</code>
{session.useTools &&
!isUser &&
message.toolMessages &&
message.toolMessages.map((tool, index) => (
<div
className={styles["chat-message-tools-status"]}
key={index}
>
<div className={styles["chat-message-tools-name"]}>
<CheckmarkIcon
className={styles["chat-message-checkmark"]}
/>
{tool.toolName}:
<code
className={styles["chat-message-tools-details"]}
>
{tool.toolInput}
</code>
</div>
</div>
</div>
</div>
))}
{showTyping && (
<div className={styles["chat-message-status"]}>