MCPcopy Create free account
hub / github.com/DTStack/dt-react-component / handleSubmit

Function handleSubmit

src/chat/demos/basic.tsx:14–34  ·  view source on GitHub ↗
(raw = value)

Source from the content-addressed store, hash-verified

12 const [convert, setConvert] = useState(false);
13
14 const handleSubmit = (raw = value) => {
15 const val = raw?.trim();
16 if (chat.loading() || !val) return;
17 setValue('');
18 const promptId = new Date().valueOf().toString();
19 const messageId = (new Date().valueOf() + 1).toString();
20 chat.prompt.create({ id: promptId, title: val });
21 chat.message.create(promptId, { id: messageId, content: '' });
22 mockSSE({
23 message: val,
24 onopen() {
25 chat.start(promptId, messageId);
26 },
27 onmessage(str) {
28 chat.push(promptId, messageId, str);
29 },
30 onstop() {
31 chat.close(promptId, messageId);
32 },
33 });
34 };
35
36 useEffect(() => {
37 chat.conversation.create({ id: new Date().valueOf().toString() });

Callers 1

basic.tsxFile · 0.70

Calls 2

mockSSEFunction · 0.90
setValueFunction · 0.85

Tested by

no test coverage detected