Spaces:
Running
Running
Update flare-ui/src/app/components/environment/environment.component.ts
Browse files
flare-ui/src/app/components/environment/environment.component.ts
CHANGED
@@ -12,7 +12,8 @@ import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
|
12 |
import { MatExpansionModule } from '@angular/material/expansion';
|
13 |
import { MatSliderModule } from '@angular/material/slider';
|
14 |
import { MatCheckboxModule } from '@angular/material/checkbox';
|
15 |
-
import {
|
|
|
16 |
import { EnvironmentService } from '../../services/environment.service';
|
17 |
|
18 |
@Component({
|
@@ -31,7 +32,8 @@ import { EnvironmentService } from '../../services/environment.service';
|
|
31 |
MatSnackBarModule,
|
32 |
MatExpansionModule,
|
33 |
MatSliderModule,
|
34 |
-
MatCheckboxModule
|
|
|
35 |
],
|
36 |
templateUrl: './environment.component.html',
|
37 |
styleUrls: ['./environment.component.scss']
|
@@ -68,6 +70,14 @@ export class EnvironmentComponent implements OnInit {
|
|
68 |
interim_results: true
|
69 |
};
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
loading = true;
|
72 |
saving = false;
|
73 |
|
@@ -91,6 +101,11 @@ export class EnvironmentComponent implements OnInit {
|
|
91 |
this.sttSettings = { ...this.sttSettings, ...env.stt_settings };
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
|
|
94 |
this.loading = false;
|
95 |
},
|
96 |
error: (err) => {
|
@@ -103,6 +118,42 @@ export class EnvironmentComponent implements OnInit {
|
|
103 |
});
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
getTokenLabel(): string {
|
107 |
switch(this.environment.work_mode) {
|
108 |
case 'gpt4o':
|
@@ -120,12 +171,12 @@ export class EnvironmentComponent implements OnInit {
|
|
120 |
switch(this.environment.work_mode) {
|
121 |
case 'gpt4o':
|
122 |
case 'gpt4o-mini':
|
123 |
-
return '
|
124 |
case 'hfcloud':
|
125 |
case 'cloud':
|
126 |
return 'Enter cloud token';
|
127 |
default:
|
128 |
-
return 'Enter
|
129 |
}
|
130 |
}
|
131 |
|
@@ -133,30 +184,11 @@ export class EnvironmentComponent implements OnInit {
|
|
133 |
return this.environment.work_mode === 'gpt4o' || this.environment.work_mode === 'gpt4o-mini';
|
134 |
}
|
135 |
|
136 |
-
onWorkModeChange() {
|
137 |
-
if (this.environment.work_mode === 'on-premise') {
|
138 |
-
this.environment.cloud_token = '';
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
onTTSEngineChange() {
|
143 |
if (this.environment.tts_engine === 'no_tts') {
|
144 |
this.environment.tts_engine_api_key = '';
|
145 |
-
this.ttsSettings.use_ssml = false;
|
146 |
-
} else if (!this.isTTSProviderSSMLCapable()) {
|
147 |
-
// SSML desteklemiyorsa kapat
|
148 |
-
this.ttsSettings.use_ssml = false;
|
149 |
}
|
150 |
}
|
151 |
-
|
152 |
-
isTTSProviderSSMLCapable(): boolean {
|
153 |
-
// SSML destekleyen provider'lar
|
154 |
-
const ssmlProviders = ['google', 'azure', 'amazon'];
|
155 |
-
if (!this.environment.tts_engine) {
|
156 |
-
return false;
|
157 |
-
}
|
158 |
-
return ssmlProviders.includes(this.environment.tts_engine);
|
159 |
-
}
|
160 |
|
161 |
onSTTEngineChange() {
|
162 |
if (this.environment.stt_engine === 'no_stt') {
|
@@ -164,10 +196,15 @@ export class EnvironmentComponent implements OnInit {
|
|
164 |
}
|
165 |
}
|
166 |
|
|
|
|
|
|
|
|
|
|
|
167 |
getSTTKeyLabel(): string {
|
168 |
switch(this.environment.stt_engine) {
|
169 |
case 'google':
|
170 |
-
return '
|
171 |
case 'azure':
|
172 |
return 'Azure Subscription Key';
|
173 |
case 'amazon':
|
@@ -182,7 +219,7 @@ export class EnvironmentComponent implements OnInit {
|
|
182 |
getSTTKeyPlaceholder(): string {
|
183 |
switch(this.environment.stt_engine) {
|
184 |
case 'google':
|
185 |
-
return '
|
186 |
case 'azure':
|
187 |
return 'Enter Azure subscription key';
|
188 |
case 'amazon':
|
@@ -216,11 +253,12 @@ export class EnvironmentComponent implements OnInit {
|
|
216 |
save() {
|
217 |
this.saving = true;
|
218 |
|
219 |
-
// Include
|
220 |
const saveData = {
|
221 |
...this.environment,
|
222 |
stt_settings: this.sttSettings,
|
223 |
-
tts_settings: this.ttsSettings
|
|
|
224 |
};
|
225 |
|
226 |
this.apiService.updateEnvironment(saveData).subscribe({
|
@@ -273,4 +311,16 @@ export class EnvironmentComponent implements OnInit {
|
|
273 |
});
|
274 |
}, 1000);
|
275 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
}
|
|
|
12 |
import { MatExpansionModule } from '@angular/material/expansion';
|
13 |
import { MatSliderModule } from '@angular/material/slider';
|
14 |
import { MatCheckboxModule } from '@angular/material/checkbox';
|
15 |
+
import { MatListModule } from '@angular/material/list';
|
16 |
+
import { ApiService, Environment, STTSettings, TTSSettings, ParameterCollectionConfig } from '../../services/api.service';
|
17 |
import { EnvironmentService } from '../../services/environment.service';
|
18 |
|
19 |
@Component({
|
|
|
32 |
MatSnackBarModule,
|
33 |
MatExpansionModule,
|
34 |
MatSliderModule,
|
35 |
+
MatCheckboxModule,
|
36 |
+
MatListModule
|
37 |
],
|
38 |
templateUrl: './environment.component.html',
|
39 |
styleUrls: ['./environment.component.scss']
|
|
|
70 |
interim_results: true
|
71 |
};
|
72 |
|
73 |
+
// Parameter Collection Configuration
|
74 |
+
parameterCollectionConfig: ParameterCollectionConfig = {
|
75 |
+
max_params_per_question: 2,
|
76 |
+
smart_grouping: true,
|
77 |
+
retry_unanswered: true,
|
78 |
+
collection_prompt: this.getDefaultCollectionPrompt()
|
79 |
+
};
|
80 |
+
|
81 |
loading = true;
|
82 |
saving = false;
|
83 |
|
|
|
101 |
this.sttSettings = { ...this.sttSettings, ...env.stt_settings };
|
102 |
}
|
103 |
|
104 |
+
// Load Parameter Collection Configuration
|
105 |
+
if (env.parameter_collection_config) {
|
106 |
+
this.parameterCollectionConfig = { ...this.parameterCollectionConfig, ...env.parameter_collection_config };
|
107 |
+
}
|
108 |
+
|
109 |
this.loading = false;
|
110 |
},
|
111 |
error: (err) => {
|
|
|
118 |
});
|
119 |
}
|
120 |
|
121 |
+
getDefaultCollectionPrompt(): string {
|
122 |
+
return `You are a helpful assistant collecting information from the user.
|
123 |
+
|
124 |
+
Conversation context:
|
125 |
+
{{conversation_history}}
|
126 |
+
|
127 |
+
Intent: {{intent_name}} - {{intent_caption}}
|
128 |
+
|
129 |
+
Already collected:
|
130 |
+
{{collected_params}}
|
131 |
+
|
132 |
+
Still needed:
|
133 |
+
{{missing_params}}
|
134 |
+
|
135 |
+
Previously asked but not answered:
|
136 |
+
{{unanswered_params}}
|
137 |
+
|
138 |
+
Rules:
|
139 |
+
1. Ask for maximum {{max_params}} parameters in one question
|
140 |
+
2. Group parameters that naturally go together (like from/to cities, dates)
|
141 |
+
3. If some parameters were asked before but not answered, include them again
|
142 |
+
4. Be natural and conversational in {{project_language}}
|
143 |
+
5. Use context from the conversation to make the question flow naturally
|
144 |
+
|
145 |
+
Generate ONLY the question, nothing else.`;
|
146 |
+
}
|
147 |
+
|
148 |
+
resetCollectionPrompt(): void {
|
149 |
+
this.parameterCollectionConfig.collection_prompt = this.getDefaultCollectionPrompt();
|
150 |
+
this.showSnackBar('Collection prompt reset to default');
|
151 |
+
}
|
152 |
+
|
153 |
+
formatSliderLabel(value: number): string {
|
154 |
+
return `${value}`;
|
155 |
+
}
|
156 |
+
|
157 |
getTokenLabel(): string {
|
158 |
switch(this.environment.work_mode) {
|
159 |
case 'gpt4o':
|
|
|
171 |
switch(this.environment.work_mode) {
|
172 |
case 'gpt4o':
|
173 |
case 'gpt4o-mini':
|
174 |
+
return 'sk-...';
|
175 |
case 'hfcloud':
|
176 |
case 'cloud':
|
177 |
return 'Enter cloud token';
|
178 |
default:
|
179 |
+
return 'Enter token';
|
180 |
}
|
181 |
}
|
182 |
|
|
|
184 |
return this.environment.work_mode === 'gpt4o' || this.environment.work_mode === 'gpt4o-mini';
|
185 |
}
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
onTTSEngineChange() {
|
188 |
if (this.environment.tts_engine === 'no_tts') {
|
189 |
this.environment.tts_engine_api_key = '';
|
|
|
|
|
|
|
|
|
190 |
}
|
191 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
onSTTEngineChange() {
|
194 |
if (this.environment.stt_engine === 'no_stt') {
|
|
|
196 |
}
|
197 |
}
|
198 |
|
199 |
+
isTTSProviderSSMLCapable(): boolean {
|
200 |
+
return this.environment.tts_engine === 'elevenlabs';
|
201 |
+
}
|
202 |
+
|
203 |
+
// STT Key methods
|
204 |
getSTTKeyLabel(): string {
|
205 |
switch(this.environment.stt_engine) {
|
206 |
case 'google':
|
207 |
+
return 'Service Account JSON Path';
|
208 |
case 'azure':
|
209 |
return 'Azure Subscription Key';
|
210 |
case 'amazon':
|
|
|
219 |
getSTTKeyPlaceholder(): string {
|
220 |
switch(this.environment.stt_engine) {
|
221 |
case 'google':
|
222 |
+
return '/credentials/google-service-account.json';
|
223 |
case 'azure':
|
224 |
return 'Enter Azure subscription key';
|
225 |
case 'amazon':
|
|
|
253 |
save() {
|
254 |
this.saving = true;
|
255 |
|
256 |
+
// Include all settings in the save
|
257 |
const saveData = {
|
258 |
...this.environment,
|
259 |
stt_settings: this.sttSettings,
|
260 |
+
tts_settings: this.ttsSettings,
|
261 |
+
parameter_collection_config: this.parameterCollectionConfig
|
262 |
};
|
263 |
|
264 |
this.apiService.updateEnvironment(saveData).subscribe({
|
|
|
311 |
});
|
312 |
}, 1000);
|
313 |
}
|
314 |
+
|
315 |
+
showSnackBar(message: string) {
|
316 |
+
this.snackBar.open(message, 'Close', {
|
317 |
+
duration: 3000
|
318 |
+
});
|
319 |
+
}
|
320 |
+
|
321 |
+
get envForm() {
|
322 |
+
return {
|
323 |
+
valid: true // Form validation için basit bir getter
|
324 |
+
};
|
325 |
+
}
|
326 |
}
|