Spaces:
Building
Building
Update flare-ui/src/app/dialogs/version-edit-dialog/version-edit-dialog.component.ts
Browse files
flare-ui/src/app/dialogs/version-edit-dialog/version-edit-dialog.component.ts
CHANGED
@@ -420,7 +420,6 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
420 |
|
421 |
async saveVersion() {
|
422 |
if (this.versionForm.invalid || !this.selectedVersion) {
|
423 |
-
// Hangi alanların invalid olduğunu göster
|
424 |
const invalidFields: string[] = [];
|
425 |
Object.keys(this.versionForm.controls).forEach(key => {
|
426 |
const control = this.versionForm.get(key);
|
@@ -429,7 +428,6 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
429 |
}
|
430 |
});
|
431 |
|
432 |
-
// Intents içindeki hataları kontrol et
|
433 |
this.intents.controls.forEach((intent, index) => {
|
434 |
if (intent.invalid) {
|
435 |
invalidFields.push(`Intent ${index + 1}`);
|
@@ -446,7 +444,8 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
446 |
|
447 |
try {
|
448 |
const formValue = this.versionForm.getRawValue();
|
449 |
-
|
|
|
450 |
const llmConfig = {
|
451 |
repo_id: formValue.llm.repo_id,
|
452 |
generation_config: formValue.llm.generation_config,
|
@@ -454,6 +453,7 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
454 |
fine_tune_zip: formValue.llm.fine_tune_zip
|
455 |
};
|
456 |
|
|
|
457 |
const intents = formValue.intents.map((intent: any) => ({
|
458 |
name: intent.name,
|
459 |
caption: intent.caption,
|
@@ -476,19 +476,20 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
476 |
fallback_error_prompt: intent.fallback_error_prompt
|
477 |
}));
|
478 |
|
|
|
479 |
const updateData = {
|
480 |
caption: formValue.caption,
|
481 |
-
description: formValue.caption,
|
482 |
default_api: this.selectedVersion.default_api || '',
|
483 |
published: this.selectedVersion.published,
|
484 |
llm: llmConfig,
|
485 |
intents: intents,
|
486 |
-
parameters: [],
|
487 |
last_update_date: this.selectedVersion.last_update_date
|
488 |
};
|
489 |
|
490 |
console.log('Saving version data:', JSON.stringify(updateData, null, 2));
|
491 |
-
|
492 |
const result = await this.apiService.updateVersion(
|
493 |
this.project.id,
|
494 |
this.selectedVersion.id,
|
@@ -511,45 +512,86 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
511 |
} catch (error: any) {
|
512 |
console.error('Save error:', error);
|
513 |
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
548 |
}
|
549 |
-
} finally {
|
550 |
-
this.saving = false;
|
551 |
}
|
552 |
-
}
|
553 |
|
554 |
async publishVersion() {
|
555 |
if (!this.selectedVersion) return;
|
|
|
420 |
|
421 |
async saveVersion() {
|
422 |
if (this.versionForm.invalid || !this.selectedVersion) {
|
|
|
423 |
const invalidFields: string[] = [];
|
424 |
Object.keys(this.versionForm.controls).forEach(key => {
|
425 |
const control = this.versionForm.get(key);
|
|
|
428 |
}
|
429 |
});
|
430 |
|
|
|
431 |
this.intents.controls.forEach((intent, index) => {
|
432 |
if (intent.invalid) {
|
433 |
invalidFields.push(`Intent ${index + 1}`);
|
|
|
444 |
|
445 |
try {
|
446 |
const formValue = this.versionForm.getRawValue();
|
447 |
+
|
448 |
+
// LLM config'i düzgün formatta hazırla
|
449 |
const llmConfig = {
|
450 |
repo_id: formValue.llm.repo_id,
|
451 |
generation_config: formValue.llm.generation_config,
|
|
|
453 |
fine_tune_zip: formValue.llm.fine_tune_zip
|
454 |
};
|
455 |
|
456 |
+
// Intent verilerini düzgün formatta hazırla
|
457 |
const intents = formValue.intents.map((intent: any) => ({
|
458 |
name: intent.name,
|
459 |
caption: intent.caption,
|
|
|
476 |
fallback_error_prompt: intent.fallback_error_prompt
|
477 |
}));
|
478 |
|
479 |
+
// updateData'yı burada tanımla
|
480 |
const updateData = {
|
481 |
caption: formValue.caption,
|
482 |
+
description: formValue.caption,
|
483 |
default_api: this.selectedVersion.default_api || '',
|
484 |
published: this.selectedVersion.published,
|
485 |
llm: llmConfig,
|
486 |
intents: intents,
|
487 |
+
parameters: [],
|
488 |
last_update_date: this.selectedVersion.last_update_date
|
489 |
};
|
490 |
|
491 |
console.log('Saving version data:', JSON.stringify(updateData, null, 2));
|
492 |
+
|
493 |
const result = await this.apiService.updateVersion(
|
494 |
this.project.id,
|
495 |
this.selectedVersion.id,
|
|
|
512 |
} catch (error: any) {
|
513 |
console.error('Save error:', error);
|
514 |
|
515 |
+
if (error.status === 409) {
|
516 |
+
// updateData'ya burada da ihtiyacımız var, yukarıdan taşıyalım
|
517 |
+
const formValue = this.versionForm.getRawValue();
|
518 |
+
const llmConfig = {
|
519 |
+
repo_id: formValue.llm.repo_id,
|
520 |
+
generation_config: formValue.llm.generation_config,
|
521 |
+
use_fine_tune: formValue.llm.use_fine_tune,
|
522 |
+
fine_tune_zip: formValue.llm.fine_tune_zip
|
523 |
+
};
|
524 |
+
|
525 |
+
const intents = formValue.intents.map((intent: any) => ({
|
526 |
+
name: intent.name,
|
527 |
+
caption: intent.caption,
|
528 |
+
locale: intent.locale,
|
529 |
+
detection_prompt: intent.detection_prompt,
|
530 |
+
examples: Array.isArray(intent.examples) ? intent.examples.filter((ex: any) => ex) : [],
|
531 |
+
parameters: Array.isArray(intent.parameters) ? intent.parameters : [],
|
532 |
+
action: intent.action,
|
533 |
+
fallback_timeout_prompt: intent.fallback_timeout_prompt,
|
534 |
+
fallback_error_prompt: intent.fallback_error_prompt
|
535 |
+
}));
|
536 |
+
|
537 |
+
const retryUpdateData = {
|
538 |
+
caption: formValue.caption,
|
539 |
+
description: formValue.caption,
|
540 |
+
default_api: this.selectedVersion.default_api || '',
|
541 |
+
published: this.selectedVersion.published,
|
542 |
+
llm: llmConfig,
|
543 |
+
intents: intents,
|
544 |
+
parameters: [],
|
545 |
+
last_update_date: this.selectedVersion.last_update_date
|
546 |
+
};
|
547 |
+
|
548 |
+
const { default: ConfirmDialogComponent } = await import('../confirm-dialog/confirm-dialog.component');
|
549 |
+
|
550 |
+
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
551 |
+
width: '500px',
|
552 |
+
data: {
|
553 |
+
title: 'Version Modified',
|
554 |
+
message: 'This version was modified by another user. Do you want to reload and lose your changes, or force save?',
|
555 |
+
confirmText: 'Force Save',
|
556 |
+
cancelText: 'Reload',
|
557 |
+
confirmColor: 'warn'
|
558 |
+
}
|
559 |
+
});
|
560 |
+
|
561 |
+
dialogRef.afterClosed().subscribe(async (forceSave) => {
|
562 |
+
if (forceSave) {
|
563 |
+
// Force save
|
564 |
+
try {
|
565 |
+
await this.apiService.updateVersion(
|
566 |
+
this.project.id,
|
567 |
+
this.selectedVersion!.id,
|
568 |
+
retryUpdateData,
|
569 |
+
true // force flag
|
570 |
+
).toPromise();
|
571 |
+
this.snackBar.open('Version force saved', 'Close', { duration: 3000 });
|
572 |
+
await this.loadVersions();
|
573 |
+
} catch (err: any) {
|
574 |
+
this.snackBar.open(err.error?.detail || 'Force save failed', 'Close', {
|
575 |
+
duration: 5000,
|
576 |
+
panelClass: 'error-snackbar'
|
577 |
+
});
|
578 |
+
}
|
579 |
+
} else {
|
580 |
+
// Reload
|
581 |
+
await this.loadVersions();
|
582 |
+
}
|
583 |
+
});
|
584 |
+
} else {
|
585 |
+
const errorMessage = error.error?.detail || error.message || 'Failed to save version';
|
586 |
+
this.snackBar.open(errorMessage, 'Close', {
|
587 |
+
duration: 5000,
|
588 |
+
panelClass: 'error-snackbar'
|
589 |
+
});
|
590 |
+
}
|
591 |
+
} finally {
|
592 |
+
this.saving = false;
|
593 |
}
|
|
|
|
|
594 |
}
|
|
|
595 |
|
596 |
async publishVersion() {
|
597 |
if (!this.selectedVersion) return;
|