Spaces:
Paused
Paused
Update flare-ui/src/app/components/environment/environment.component.ts
Browse files
flare-ui/src/app/components/environment/environment.component.ts
CHANGED
|
@@ -52,22 +52,24 @@ import { ApiService, Environment } from '../../services/api.service';
|
|
| 52 |
<mat-option value="hfcloud">HF Cloud</mat-option>
|
| 53 |
<mat-option value="cloud">Cloud</mat-option>
|
| 54 |
<mat-option value="on-premise">On-Premise</mat-option>
|
|
|
|
|
|
|
| 55 |
</mat-select>
|
| 56 |
<mat-icon matPrefix>cloud</mat-icon>
|
| 57 |
</mat-form-field>
|
| 58 |
|
| 59 |
<mat-form-field appearance="outline" class="full-width">
|
| 60 |
-
<mat-label>
|
| 61 |
<input
|
| 62 |
matInput
|
| 63 |
type="password"
|
| 64 |
name="cloudToken"
|
| 65 |
[(ngModel)]="environment.cloud_token"
|
| 66 |
[disabled]="loading || environment.work_mode === 'on-premise'"
|
| 67 |
-
placeholder="
|
| 68 |
>
|
| 69 |
<mat-icon matPrefix>vpn_key</mat-icon>
|
| 70 |
-
<mat-hint>Required for HF Cloud and Cloud modes</mat-hint>
|
| 71 |
</mat-form-field>
|
| 72 |
|
| 73 |
<mat-form-field appearance="outline" class="full-width">
|
|
@@ -77,8 +79,8 @@ import { ApiService, Environment } from '../../services/api.service';
|
|
| 77 |
type="url"
|
| 78 |
name="sparkEndpoint"
|
| 79 |
[(ngModel)]="environment.spark_endpoint"
|
| 80 |
-
required
|
| 81 |
-
[disabled]="loading"
|
| 82 |
placeholder="https://spark-service.example.com"
|
| 83 |
>
|
| 84 |
<mat-icon matPrefix>link</mat-icon>
|
|
@@ -87,12 +89,27 @@ import { ApiService, Environment } from '../../services/api.service';
|
|
| 87 |
matSuffix
|
| 88 |
type="button"
|
| 89 |
(click)="testConnection()"
|
| 90 |
-
[disabled]="loading || !environment.spark_endpoint"
|
| 91 |
matTooltip="Test Connection"
|
| 92 |
>
|
| 93 |
<mat-icon>wifi_tethering</mat-icon>
|
| 94 |
</button>
|
|
|
|
| 95 |
</mat-form-field>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
<mat-expansion-panel class="prompt-panel">
|
| 98 |
<mat-expansion-panel-header>
|
|
@@ -212,6 +229,27 @@ import { ApiService, Environment } from '../../services/api.service';
|
|
| 212 |
}
|
| 213 |
}
|
| 214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
::ng-deep {
|
| 216 |
.mat-mdc-form-field-icon-prefix {
|
| 217 |
padding-right: 12px;
|
|
@@ -268,6 +306,36 @@ export class EnvironmentComponent implements OnInit {
|
|
| 268 |
}
|
| 269 |
}
|
| 270 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
save() {
|
| 272 |
this.saving = true;
|
| 273 |
|
|
|
|
| 52 |
<mat-option value="hfcloud">HF Cloud</mat-option>
|
| 53 |
<mat-option value="cloud">Cloud</mat-option>
|
| 54 |
<mat-option value="on-premise">On-Premise</mat-option>
|
| 55 |
+
<mat-option value="gpt4o">GPT-4o</mat-option>
|
| 56 |
+
<mat-option value="gpt4o-mini">GPT-4o Mini</mat-option>
|
| 57 |
</mat-select>
|
| 58 |
<mat-icon matPrefix>cloud</mat-icon>
|
| 59 |
</mat-form-field>
|
| 60 |
|
| 61 |
<mat-form-field appearance="outline" class="full-width">
|
| 62 |
+
<mat-label>{{ getTokenLabel() }}</mat-label>
|
| 63 |
<input
|
| 64 |
matInput
|
| 65 |
type="password"
|
| 66 |
name="cloudToken"
|
| 67 |
[(ngModel)]="environment.cloud_token"
|
| 68 |
[disabled]="loading || environment.work_mode === 'on-premise'"
|
| 69 |
+
[placeholder]="getTokenPlaceholder()"
|
| 70 |
>
|
| 71 |
<mat-icon matPrefix>vpn_key</mat-icon>
|
| 72 |
+
<mat-hint>{{ isGPTMode() ? 'Required for OpenAI API access' : 'Required for HF Cloud and Cloud modes' }}</mat-hint>
|
| 73 |
</mat-form-field>
|
| 74 |
|
| 75 |
<mat-form-field appearance="outline" class="full-width">
|
|
|
|
| 79 |
type="url"
|
| 80 |
name="sparkEndpoint"
|
| 81 |
[(ngModel)]="environment.spark_endpoint"
|
| 82 |
+
[required]="!isGPTMode()"
|
| 83 |
+
[disabled]="loading || isGPTMode()"
|
| 84 |
placeholder="https://spark-service.example.com"
|
| 85 |
>
|
| 86 |
<mat-icon matPrefix>link</mat-icon>
|
|
|
|
| 89 |
matSuffix
|
| 90 |
type="button"
|
| 91 |
(click)="testConnection()"
|
| 92 |
+
[disabled]="loading || !environment.spark_endpoint || isGPTMode()"
|
| 93 |
matTooltip="Test Connection"
|
| 94 |
>
|
| 95 |
<mat-icon>wifi_tethering</mat-icon>
|
| 96 |
</button>
|
| 97 |
+
<mat-hint *ngIf="isGPTMode()">Not required for GPT mode</mat-hint>
|
| 98 |
</mat-form-field>
|
| 99 |
+
|
| 100 |
+
// GPT mode için bilgi alert'i ekle (mat-card-content içine, form'dan önce)
|
| 101 |
+
@if (isGPTMode()) {
|
| 102 |
+
<mat-card class="info-card">
|
| 103 |
+
<mat-card-content>
|
| 104 |
+
<mat-icon>info</mat-icon>
|
| 105 |
+
<div>
|
| 106 |
+
<strong>{{ environment.work_mode === 'gpt4o' ? 'GPT-4o' : 'GPT-4o Mini' }} Mode</strong>
|
| 107 |
+
<p>This mode uses OpenAI's API which has usage-based pricing.</p>
|
| 108 |
+
<p>Approximate cost: {{ environment.work_mode === 'gpt4o' ? '$0.01-0.03' : '$0.001-0.003' }} per conversation turn.</p>
|
| 109 |
+
</div>
|
| 110 |
+
</mat-card-content>
|
| 111 |
+
</mat-card>
|
| 112 |
+
}
|
| 113 |
|
| 114 |
<mat-expansion-panel class="prompt-panel">
|
| 115 |
<mat-expansion-panel-header>
|
|
|
|
| 229 |
}
|
| 230 |
}
|
| 231 |
|
| 232 |
+
.info-card {
|
| 233 |
+
margin-bottom: 20px;
|
| 234 |
+
background-color: #e3f2fd;
|
| 235 |
+
|
| 236 |
+
mat-card-content {
|
| 237 |
+
display: flex;
|
| 238 |
+
gap: 16px;
|
| 239 |
+
align-items: flex-start;
|
| 240 |
+
|
| 241 |
+
mat-icon {
|
| 242 |
+
color: #1976d2;
|
| 243 |
+
margin-top: 4px;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
p {
|
| 247 |
+
margin: 4px 0;
|
| 248 |
+
font-size: 14px;
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
::ng-deep {
|
| 254 |
.mat-mdc-form-field-icon-prefix {
|
| 255 |
padding-right: 12px;
|
|
|
|
| 306 |
}
|
| 307 |
}
|
| 308 |
|
| 309 |
+
getTokenLabel(): string {
|
| 310 |
+
switch(this.environment.work_mode) {
|
| 311 |
+
case 'gpt4o':
|
| 312 |
+
case 'gpt4o-mini':
|
| 313 |
+
return 'OpenAI API Key';
|
| 314 |
+
case 'hfcloud':
|
| 315 |
+
case 'cloud':
|
| 316 |
+
return 'Cloud Token';
|
| 317 |
+
default:
|
| 318 |
+
return 'Cloud Token';
|
| 319 |
+
}
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
getTokenPlaceholder(): string {
|
| 323 |
+
switch(this.environment.work_mode) {
|
| 324 |
+
case 'gpt4o':
|
| 325 |
+
case 'gpt4o-mini':
|
| 326 |
+
return 'Enter OpenAI API key (sk-...)';
|
| 327 |
+
case 'hfcloud':
|
| 328 |
+
case 'cloud':
|
| 329 |
+
return 'Enter cloud token';
|
| 330 |
+
default:
|
| 331 |
+
return 'Enter cloud token';
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
isGPTMode(): boolean {
|
| 336 |
+
return this.environment.work_mode === 'gpt4o' || this.environment.work_mode === 'gpt4o-mini';
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
save() {
|
| 340 |
this.saving = true;
|
| 341 |
|