ciyidogan commited on
Commit
4048d52
·
verified ·
1 Parent(s): 1edb206

Update flare-ui/src/app/components/environment/environment.component.ts

Browse files
flare-ui/src/app/components/environment/environment.component.ts CHANGED
@@ -31,328 +31,9 @@ import { EnvironmentService } from '../../services/environment.service';
31
  MatExpansionModule,
32
  MatSliderModule
33
  ],
34
- template: `
35
- <div class="environment-container">
36
- <mat-card>
37
- <mat-card-header>
38
- <mat-card-title>
39
- <mat-icon>settings</mat-icon>
40
- Environment Configuration
41
- </mat-card-title>
42
- </mat-card-header>
43
-
44
- <mat-card-content>
45
- @if (isGPTMode()) {
46
- <mat-card class="info-card">
47
- <mat-card-content>
48
- <mat-icon>info</mat-icon>
49
- <div>
50
- <strong>{{ environment.work_mode === 'gpt4o' ? 'GPT-4o' : 'GPT-4o Mini' }} Mode</strong>
51
- <p>This mode uses OpenAI's API which has usage-based pricing.</p>
52
- <p>Approximate cost: {{ environment.work_mode === 'gpt4o' ? '$0.01-0.03' : '$0.001-0.003' }} per conversation turn.</p>
53
- </div>
54
- </mat-card-content>
55
- </mat-card>
56
- }
57
-
58
- <form (ngSubmit)="save()" #envForm="ngForm">
59
- <mat-form-field appearance="outline" class="full-width">
60
- <mat-label>Work Mode</mat-label>
61
- <mat-select
62
- name="workMode"
63
- [(ngModel)]="environment.work_mode"
64
- (selectionChange)="onWorkModeChange()"
65
- required
66
- [disabled]="loading"
67
- >
68
- <mat-option value="hfcloud">HF Cloud</mat-option>
69
- <mat-option value="cloud">Cloud</mat-option>
70
- <mat-option value="on-premise">On-Premise</mat-option>
71
- <mat-option value="gpt4o">GPT-4o</mat-option>
72
- <mat-option value="gpt4o-mini">GPT-4o Mini</mat-option>
73
- </mat-select>
74
- <mat-icon matPrefix>cloud</mat-icon>
75
- </mat-form-field>
76
-
77
- <mat-form-field appearance="outline" class="full-width">
78
- <mat-label>{{ getTokenLabel() }}</mat-label>
79
- <input
80
- matInput
81
- type="password"
82
- name="cloudToken"
83
- [(ngModel)]="environment.cloud_token"
84
- [disabled]="loading || environment.work_mode === 'on-premise'"
85
- [placeholder]="getTokenPlaceholder()"
86
- >
87
- <mat-icon matPrefix>vpn_key</mat-icon>
88
- <mat-hint>{{ isGPTMode() ? 'Required for OpenAI API access' : 'Required for HF Cloud and Cloud modes' }}</mat-hint>
89
- </mat-form-field>
90
-
91
- <mat-form-field appearance="outline" class="full-width">
92
- <mat-label>Spark Endpoint</mat-label>
93
- <input
94
- matInput
95
- type="url"
96
- name="sparkEndpoint"
97
- [(ngModel)]="environment.spark_endpoint"
98
- [required]="!isGPTMode()"
99
- [disabled]="loading || isGPTMode()"
100
- placeholder="https://spark-service.example.com"
101
- >
102
- <mat-icon matPrefix>link</mat-icon>
103
- <button
104
- mat-icon-button
105
- matSuffix
106
- type="button"
107
- (click)="testConnection()"
108
- [disabled]="loading || !environment.spark_endpoint || isGPTMode()"
109
- matTooltip="Test Connection"
110
- >
111
- <mat-icon>wifi_tethering</mat-icon>
112
- </button>
113
- @if (isGPTMode()) {
114
- <mat-hint>Not required for GPT mode</mat-hint>
115
- }
116
- </mat-form-field>
117
-
118
- <!-- TTS Configuration -->
119
- <div class="engine-row">
120
- <mat-form-field appearance="outline" class="engine-field">
121
- <mat-label>TTS Engine</mat-label>
122
- <mat-select
123
- name="ttsEngine"
124
- [(ngModel)]="environment.tts_engine"
125
- (selectionChange)="onTTSEngineChange()"
126
- [disabled]="loading"
127
- >
128
- <mat-option value="no_tts">No TTS</mat-option>
129
- <mat-option value="elevenlabs">ElevenLabs</mat-option>
130
- <mat-option value="blaze">Blaze (Coming Soon)</mat-option>
131
- </mat-select>
132
- <mat-icon matPrefix>record_voice_over</mat-icon>
133
- </mat-form-field>
134
-
135
- <mat-form-field appearance="outline" class="api-key-field">
136
- <mat-label>TTS API Key</mat-label>
137
- <input
138
- matInput
139
- type="password"
140
- name="ttsApiKey"
141
- [(ngModel)]="environment.tts_engine_api_key"
142
- [disabled]="loading || environment.tts_engine === 'no_tts'"
143
- [required]="environment.tts_engine !== 'no_tts'"
144
- placeholder="Enter TTS API key"
145
- >
146
- <mat-icon matPrefix>key</mat-icon>
147
- </mat-form-field>
148
- </div>
149
-
150
- <!-- STT Configuration -->
151
- <div class="engine-row">
152
- <mat-form-field appearance="outline" class="engine-field">
153
- <mat-label>STT Engine</mat-label>
154
- <mat-select
155
- name="sttEngine"
156
- [(ngModel)]="environment.stt_engine"
157
- (selectionChange)="onSTTEngineChange()"
158
- [disabled]="loading"
159
- >
160
- <mat-option value="no_stt">No STT</mat-option>
161
- <mat-option value="google">Google Cloud Speech</mat-option>
162
- <mat-option value="azure">Azure Speech (Coming Soon)</mat-option>
163
- <mat-option value="amazon">Amazon Transcribe (Coming Soon)</mat-option>
164
- <mat-option value="flicker">Flicker (Coming Soon)</mat-option>
165
- </mat-select>
166
- <mat-icon matPrefix>mic</mat-icon>
167
- </mat-form-field>
168
-
169
- <mat-form-field appearance="outline" class="api-key-field">
170
- <mat-label>{{ getSTTKeyLabel() }}</mat-label>
171
- <input
172
- matInput
173
- type="password"
174
- name="sttApiKey"
175
- [(ngModel)]="environment.stt_engine_api_key"
176
- [disabled]="loading || environment.stt_engine === 'no_stt'"
177
- [required]="environment.stt_engine !== 'no_stt'"
178
- [placeholder]="getSTTKeyPlaceholder()"
179
- >
180
- <mat-icon matPrefix>key</mat-icon>
181
- <mat-hint>{{ getSTTKeyHint() }}</mat-hint>
182
- </mat-form-field>
183
-
184
- <!-- STT Settings Panel -->
185
- <mat-expansion-panel class="stt-settings-panel" *ngIf="environment.stt_engine !== 'no_stt'">
186
- <mat-expansion-panel-header>
187
- <mat-panel-title>
188
- <mat-icon>settings_voice</mat-icon>
189
- STT Settings
190
- </mat-panel-title>
191
- <mat-panel-description>
192
- Advanced speech recognition settings
193
- </mat-panel-description>
194
- </mat-expansion-panel-header>
195
-
196
- <div class="stt-settings-content">
197
- <!-- Language -->
198
- <mat-form-field appearance="outline" class="full-width">
199
- <mat-label>Language</mat-label>
200
- <mat-select
201
- name="sttLanguage"
202
- [(ngModel)]="environment.stt_settings.language"
203
- [disabled]="loading"
204
- >
205
- <mat-option value="tr-TR">Turkish (tr-TR)</mat-option>
206
- <mat-option value="en-US">English US (en-US)</mat-option>
207
- <mat-option value="en-GB">English UK (en-GB)</mat-option>
208
- <mat-option value="de-DE">German (de-DE)</mat-option>
209
- <mat-option value="fr-FR">French (fr-FR)</mat-option>
210
- <mat-option value="es-ES">Spanish (es-ES)</mat-option>
211
- </mat-select>
212
- <mat-icon matPrefix>language</mat-icon>
213
- </mat-form-field>
214
-
215
- <!-- Model -->
216
- <mat-form-field appearance="outline" class="full-width" *ngIf="environment.stt_engine === 'google'">
217
- <mat-label>Recognition Model</mat-label>
218
- <mat-select
219
- name="sttModel"
220
- [(ngModel)]="environment.stt_settings.model"
221
- [disabled]="loading"
222
- >
223
- <mat-option value="latest_long">Latest Long (Best for long audio)</mat-option>
224
- <mat-option value="latest_short">Latest Short (Best for short audio)</mat-option>
225
- <mat-option value="command_and_search">Command and Search</mat-option>
226
- <mat-option value="phone_call">Phone Call</mat-option>
227
- <mat-option value="video">Video</mat-option>
228
- </mat-select>
229
- <mat-icon matPrefix>model_training</mat-icon>
230
- </mat-form-field>
231
-
232
- <!-- Speech Timeout -->
233
- <div class="slider-field">
234
- <label>Speech Timeout: {{ environment.stt_settings.speech_timeout_ms }}ms</label>
235
- <mat-slider
236
- [min]="500"
237
- [max]="5000"
238
- [step]="100"
239
- [discrete]="true"
240
- [displayWith]="formatMilliseconds"
241
- >
242
- <input matSliderThumb [(ngModel)]="environment.stt_settings.speech_timeout_ms">
243
- </mat-slider>
244
- <mat-hint>Silence duration to end speech detection</mat-hint>
245
- </div>
246
-
247
- <!-- VAD Sensitivity -->
248
- <div class="slider-field">
249
- <label>Voice Activity Detection Sensitivity: {{ environment.stt_settings.vad_sensitivity }}</label>
250
- <mat-slider
251
- [min]="0"
252
- [max]="1"
253
- [step]="0.1"
254
- [discrete]="true"
255
- >
256
- <input matSliderThumb [(ngModel)]="environment.stt_settings.vad_sensitivity">
257
- </mat-slider>
258
- <mat-hint>Higher values = more sensitive</mat-hint>
259
- </div>
260
-
261
- <!-- Noise Reduction Level -->
262
- <div class="slider-field">
263
- <label>Noise Reduction Level: {{ environment.stt_settings.noise_reduction_level }}</label>
264
- <mat-slider
265
- [min]="0"
266
- [max]="3"
267
- [step]="1"
268
- [discrete]="true"
269
- >
270
- <input matSliderThumb [(ngModel)]="environment.stt_settings.noise_reduction_level">
271
- </mat-slider>
272
- <mat-hint>0 = Off, 3 = Maximum</mat-hint>
273
- </div>
274
-
275
- <!-- Checkboxes -->
276
- <div class="checkbox-group">
277
- <mat-checkbox
278
- [(ngModel)]="environment.stt_settings.use_enhanced"
279
- [disabled]="loading"
280
- *ngIf="environment.stt_engine === 'google'">
281
- Use Enhanced Model
282
- </mat-checkbox>
283
-
284
- <mat-checkbox
285
- [(ngModel)]="environment.stt_settings.enable_punctuation"
286
- [disabled]="loading">
287
- Enable Automatic Punctuation
288
- </mat-checkbox>
289
-
290
- <mat-checkbox
291
- [(ngModel)]="environment.stt_settings.interim_results"
292
- [disabled]="loading">
293
- Show Interim Results
294
- </mat-checkbox>
295
- </div>
296
- </div>
297
- </mat-expansion-panel>
298
- </div>
299
-
300
- <mat-expansion-panel class="prompt-panel">
301
- <mat-expansion-panel-header>
302
- <mat-panel-title>
303
- <mat-icon>psychology</mat-icon>
304
- Internal System Prompt
305
- </mat-panel-title>
306
- <mat-panel-description>
307
- Advanced configuration for LLM
308
- </mat-panel-description>
309
- </mat-expansion-panel-header>
310
-
311
- <mat-form-field appearance="outline" class="full-width">
312
- <mat-label>Internal Prompt</mat-label>
313
- <textarea
314
- matInput
315
- name="internalPrompt"
316
- [(ngModel)]="environment.internal_prompt"
317
- [disabled]="loading"
318
- rows="10"
319
- placeholder="Enter internal system prompt..."
320
- ></textarea>
321
- <mat-hint>This prompt will be prepended to all project prompts</mat-hint>
322
- </mat-form-field>
323
- </mat-expansion-panel>
324
 
325
- <div class="form-actions">
326
- <button
327
- mat-raised-button
328
- color="primary"
329
- type="submit"
330
- [disabled]="loading || !envForm.valid || saving"
331
- >
332
- @if (saving) {
333
- <mat-spinner diameter="20"></mat-spinner>
334
- Saving...
335
- } @else {
336
- <mat-icon>save</mat-icon>
337
- Save
338
- }
339
- </button>
340
-
341
- <button
342
- mat-raised-button
343
- type="button"
344
- (click)="reloadFromSpark()"
345
- [disabled]="loading || isGPTMode()"
346
- >
347
- <mat-icon>refresh</mat-icon>
348
- Reload from Spark
349
- </button>
350
- </div>
351
- </form>
352
- </mat-card-content>
353
- </mat-card>
354
- </div>
355
- `,
356
  styles: [`
357
  .environment-container {
358
  max-width: 800px;
 
31
  MatExpansionModule,
32
  MatSliderModule
33
  ],
34
+ templateUrl: './environment.component.html',
35
+ styleUrls: ['./environment.component.scss']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  styles: [`
38
  .environment-container {
39
  max-width: 800px;