Spaces:
Paused
Paused
Update flare-ui/src/app/components/chat/chat.component.ts
Browse files
flare-ui/src/app/components/chat/chat.component.ts
CHANGED
|
@@ -58,6 +58,8 @@ export class ChatComponent implements OnInit, OnDestroy, AfterViewChecked {
|
|
| 58 |
selectedProject: string | null = null;
|
| 59 |
useTTS = false;
|
| 60 |
ttsAvailable = false;
|
|
|
|
|
|
|
| 61 |
|
| 62 |
sessionId: string | null = null;
|
| 63 |
messages: ChatMessage[] = [];
|
|
@@ -89,6 +91,7 @@ export class ChatComponent implements OnInit, OnDestroy, AfterViewChecked {
|
|
| 89 |
|
| 90 |
ngOnInit(): void {
|
| 91 |
this.loadProjects();
|
|
|
|
| 92 |
this.checkTTSAvailability();
|
| 93 |
this.checkSTTAvailability();
|
| 94 |
|
|
@@ -103,6 +106,25 @@ export class ChatComponent implements OnInit, OnDestroy, AfterViewChecked {
|
|
| 103 |
this.watchSTTToggle();
|
| 104 |
}
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
private watchSTTToggle(): void {
|
| 107 |
// When STT is toggled, provide feedback
|
| 108 |
// This could be implemented with form control valueChanges if needed
|
|
@@ -307,7 +329,7 @@ export class ChatComponent implements OnInit, OnDestroy, AfterViewChecked {
|
|
| 307 |
this.loading = true;
|
| 308 |
this.error = '';
|
| 309 |
|
| 310 |
-
this.api.startChat(this.selectedProject).pipe(
|
| 311 |
takeUntil(this.destroyed$)
|
| 312 |
).subscribe({
|
| 313 |
next: res => {
|
|
|
|
| 58 |
selectedProject: string | null = null;
|
| 59 |
useTTS = false;
|
| 60 |
ttsAvailable = false;
|
| 61 |
+
selectedLocale: string = 'tr';
|
| 62 |
+
availableLocales: any[] = [];
|
| 63 |
|
| 64 |
sessionId: string | null = null;
|
| 65 |
messages: ChatMessage[] = [];
|
|
|
|
| 91 |
|
| 92 |
ngOnInit(): void {
|
| 93 |
this.loadProjects();
|
| 94 |
+
this.loadAvailableLocales();
|
| 95 |
this.checkTTSAvailability();
|
| 96 |
this.checkSTTAvailability();
|
| 97 |
|
|
|
|
| 106 |
this.watchSTTToggle();
|
| 107 |
}
|
| 108 |
|
| 109 |
+
loadAvailableLocales(): void {
|
| 110 |
+
this.api.getAvailableLocales().pipe(
|
| 111 |
+
takeUntil(this.destroyed$)
|
| 112 |
+
).subscribe({
|
| 113 |
+
next: (response) => {
|
| 114 |
+
this.availableLocales = response.locales;
|
| 115 |
+
this.selectedLocale = response.default || 'tr';
|
| 116 |
+
},
|
| 117 |
+
error: (err) => {
|
| 118 |
+
console.error('Failed to load locales:', err);
|
| 119 |
+
// Fallback locales
|
| 120 |
+
this.availableLocales = [
|
| 121 |
+
{ code: 'tr', name: 'Türkçe' },
|
| 122 |
+
{ code: 'en', name: 'English' }
|
| 123 |
+
];
|
| 124 |
+
}
|
| 125 |
+
});
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
private watchSTTToggle(): void {
|
| 129 |
// When STT is toggled, provide feedback
|
| 130 |
// This could be implemented with form control valueChanges if needed
|
|
|
|
| 329 |
this.loading = true;
|
| 330 |
this.error = '';
|
| 331 |
|
| 332 |
+
this.api.startChat(this.selectedProject, this.selectedLocale).pipe(
|
| 333 |
takeUntil(this.destroyed$)
|
| 334 |
).subscribe({
|
| 335 |
next: res => {
|