24 | {message.role === "user" && (
25 |
26 |
39 |
40 | )}
41 | {message.role === "assistant" && (
42 |
43 | {/* M */}
44 |
67 |
68 | )}
69 |
70 |
71 | {message.role === "user" ? "You" : "AI"}{" "}
72 |
73 | {!loading && (
74 | ")
77 | ? message.content
78 | .replaceAll(
79 | `<|loading_tools|>`,
80 | renderToString(
81 |
82 |
83 |
84 | Loading tools...
85 |
86 |
87 | )
88 | )
89 | .replaceAll(
90 | `<|tool_error|>`,
91 | renderToString()
92 | )
93 | : message.content
94 | .replaceAll(`<|tool_error|>`, "")
95 | .replaceAll(
96 | /\<\|tool_called[\s\S]*\$\$/g,
97 | renderToString(
98 | <>
99 |
100 | {message.content.split("$$")[2] === "false" ? (
101 |
102 | ) : (
103 |
107 | )}
108 |
109 | {message.content.split("$$")[1]}
110 |
111 |
112 | >
113 | )
114 | )
115 | .replaceAll(`<|loading_tools|>`, ""),
116 | }}
117 | />
118 | )}
119 | {loading && (
120 |
128 | )}
129 |
130 |
131 | );
132 | }
133 |
--------------------------------------------------------------------------------
/src/components/chat/send-form.tsx:
--------------------------------------------------------------------------------
1 | import { useEnsureRegeneratorRuntime } from "@/app/hooks/useEnsureRegeneratorRuntime";
2 | import { Textarea } from "@/components/ui/textarea";
3 | import { useEffect, useRef, useState } from "react";
4 | import { Grid } from "react-loader-spinner";
5 | import SpeechRecognition, {
6 | useSpeechRecognition,
7 | } from "react-speech-recognition";
8 | import { MicIcon } from "../icons/mic-icon";
9 | import { Button } from "../ui/button";
10 | import { toast } from "../ui/use-toast";
11 |
12 | interface SendForm {
13 | input: string;
14 | handleSubmit: (event: React.FormEvent