diff --git a/src/pages/addToolMsg.tsx b/src/pages/addToolMsg.tsx new file mode 100644 index 0000000..d52a185 --- /dev/null +++ b/src/pages/addToolMsg.tsx @@ -0,0 +1,95 @@ +import { useState } from "preact/hooks"; +import { Dispatch, StateUpdater } from "preact/hooks"; + +import { Tr } from "@/translate"; +import { calculate_token_length } from "@/chatgpt"; +import { ChatStore } from "@/types/chatstore"; + +const AddToolMsg = (props: { + setShowAddToolMsg: Dispatch>; + chatStore: ChatStore; + setChatStore: (cs: ChatStore) => void; + update_total_tokens: () => void; +}) => { + const { setShowAddToolMsg, chatStore, update_total_tokens, setChatStore } = + props; + + const [newToolCallID, setNewToolCallID] = useState(""); + const [newToolContent, setNewToolContent] = useState(""); + return ( +
{ + setShowAddToolMsg(false); + }} + > +
{ + event.stopPropagation(); + }} + > +

Add Tool Message

+
+ + + setNewToolCallID(event.target.value)} + /> + + + + + + + + + +
+
+ ); +}; + +export default AddToolMsg; diff --git a/src/pages/chatbox.tsx b/src/pages/chatbox.tsx index 851c98c..d268c04 100644 --- a/src/pages/chatbox.tsx +++ b/src/pages/chatbox.tsx @@ -38,6 +38,7 @@ import Templates from "@/components/Templates"; import VersionHint from "@/components/VersionHint"; import StatusBar from "@/components/StatusBar"; import WhisperButton from "@/components/WhisperButton"; +import AddToolMsg from "./addToolMsg"; export default function ChatBOX(props: { db: Promise>; @@ -56,8 +57,6 @@ export default function ChatBOX(props: { const [generatingMessage, setGeneratingMessage] = useState(""); const [showRetry, setShowRetry] = useState(false); const [showAddToolMsg, setShowAddToolMsg] = useState(false); - const [newToolCallID, setNewToolCallID] = useState(""); - const [newToolContent, setNewToolContent] = useState(""); const [showSearch, setShowSearch] = useState(false); let default_follow = localStorage.getItem("follow"); if (default_follow === null) { @@ -803,82 +802,12 @@ export default function ChatBOX(props: { )} {showAddToolMsg && ( -
{ - setShowAddToolMsg(false); - }} - > -
{ - event.stopPropagation(); - }} - > -

Add Tool Message

-
- - - - setNewToolCallID(event.target.value) - } - /> - - - - - - - - - -
-
+ )}