navyseal4000
commited on
Commit
·
a896f3f
1
Parent(s):
36b7d94
Clear speech to text, listening upon submission
Browse files- app/components/chat/BaseChat.tsx +34 -4
- app/utils/constants.ts +1 -1
app/components/chat/BaseChat.tsx
CHANGED
@@ -145,6 +145,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
145 |
const [modelList, setModelList] = useState(MODEL_LIST);
|
146 |
const [isListening, setIsListening] = useState(false);
|
147 |
const [recognition, setRecognition] = useState<SpeechRecognition | null>(null);
|
|
|
148 |
|
149 |
useEffect(() => {
|
150 |
// Load API keys from cookies on component mount
|
@@ -177,6 +178,9 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
177 |
.map(result => result.transcript)
|
178 |
.join('');
|
179 |
|
|
|
|
|
|
|
180 |
if (handleInputChange) {
|
181 |
const syntheticEvent = {
|
182 |
target: { value: transcript },
|
@@ -208,6 +212,25 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
208 |
}
|
209 |
};
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
const updateApiKey = (provider: string, key: string) => {
|
212 |
try {
|
213 |
const updatedApiKeys = { ...apiKeys, [provider]: key };
|
@@ -301,8 +324,11 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
301 |
}
|
302 |
|
303 |
event.preventDefault();
|
304 |
-
|
305 |
-
|
|
|
|
|
|
|
306 |
}
|
307 |
}}
|
308 |
value={input}
|
@@ -327,7 +353,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
327 |
return;
|
328 |
}
|
329 |
|
330 |
-
|
331 |
}}
|
332 |
/>
|
333 |
)}
|
@@ -384,7 +410,11 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
384 |
<button
|
385 |
key={index}
|
386 |
onClick={(event) => {
|
387 |
-
|
|
|
|
|
|
|
|
|
388 |
}}
|
389 |
className="group flex items-center w-full gap-2 justify-center bg-transparent text-bolt-elements-textTertiary hover:text-bolt-elements-textPrimary transition-theme"
|
390 |
>
|
|
|
145 |
const [modelList, setModelList] = useState(MODEL_LIST);
|
146 |
const [isListening, setIsListening] = useState(false);
|
147 |
const [recognition, setRecognition] = useState<SpeechRecognition | null>(null);
|
148 |
+
const [transcript, setTranscript] = useState('');
|
149 |
|
150 |
useEffect(() => {
|
151 |
// Load API keys from cookies on component mount
|
|
|
178 |
.map(result => result.transcript)
|
179 |
.join('');
|
180 |
|
181 |
+
setTranscript(transcript);
|
182 |
+
|
183 |
+
|
184 |
if (handleInputChange) {
|
185 |
const syntheticEvent = {
|
186 |
target: { value: transcript },
|
|
|
212 |
}
|
213 |
};
|
214 |
|
215 |
+
const handleSendMessage = (event: React.UIEvent, messageInput?: string) => {
|
216 |
+
if (sendMessage) {
|
217 |
+
sendMessage(event, messageInput);
|
218 |
+
if (recognition) {
|
219 |
+
recognition.abort(); // Stop current recognition
|
220 |
+
setTranscript(''); // Clear transcript
|
221 |
+
setIsListening(false);
|
222 |
+
|
223 |
+
// Clear the input by triggering handleInputChange with empty value
|
224 |
+
if (handleInputChange) {
|
225 |
+
const syntheticEvent = {
|
226 |
+
target: { value: '' },
|
227 |
+
} as React.ChangeEvent<HTMLTextAreaElement>;
|
228 |
+
handleInputChange(syntheticEvent);
|
229 |
+
}
|
230 |
+
}
|
231 |
+
}
|
232 |
+
};
|
233 |
+
|
234 |
const updateApiKey = (provider: string, key: string) => {
|
235 |
try {
|
236 |
const updatedApiKeys = { ...apiKeys, [provider]: key };
|
|
|
324 |
}
|
325 |
|
326 |
event.preventDefault();
|
327 |
+
if (isStreaming) {
|
328 |
+
handleStop?.();
|
329 |
+
return;
|
330 |
+
}
|
331 |
+
handleSendMessage?.(event);
|
332 |
}
|
333 |
}}
|
334 |
value={input}
|
|
|
353 |
return;
|
354 |
}
|
355 |
|
356 |
+
handleSendMessage?.(event);
|
357 |
}}
|
358 |
/>
|
359 |
)}
|
|
|
410 |
<button
|
411 |
key={index}
|
412 |
onClick={(event) => {
|
413 |
+
if (isStreaming) {
|
414 |
+
handleStop?.();
|
415 |
+
return;
|
416 |
+
}
|
417 |
+
handleSendMessage?.(event, examplePrompt.text);
|
418 |
}}
|
419 |
className="group flex items-center w-full gap-2 justify-center bg-transparent text-bolt-elements-textTertiary hover:text-bolt-elements-textPrimary transition-theme"
|
420 |
>
|
app/utils/constants.ts
CHANGED
@@ -6,7 +6,7 @@ export const WORK_DIR = `/home/${WORK_DIR_NAME}`;
|
|
6 |
export const MODIFICATIONS_TAG_NAME = 'bolt_file_modifications';
|
7 |
export const MODEL_REGEX = /^\[Model: (.*?)\]\n\n/;
|
8 |
export const PROVIDER_REGEX = /\[Provider: (.*?)\]\n\n/;
|
9 |
-
export const DEFAULT_MODEL = '
|
10 |
|
11 |
const PROVIDER_LIST: ProviderInfo[] = [
|
12 |
{
|
|
|
6 |
export const MODIFICATIONS_TAG_NAME = 'bolt_file_modifications';
|
7 |
export const MODEL_REGEX = /^\[Model: (.*?)\]\n\n/;
|
8 |
export const PROVIDER_REGEX = /\[Provider: (.*?)\]\n\n/;
|
9 |
+
export const DEFAULT_MODEL = 'qwen2.5-coder:32b';
|
10 |
|
11 |
const PROVIDER_LIST: ProviderInfo[] = [
|
12 |
{
|