Spaces:
Running
Running
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
@@ -287,42 +287,71 @@ export default class VersionEditDialogComponent implements OnInit {
|
|
287 |
|
288 |
async createVersion() {
|
289 |
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
290 |
-
width: '
|
291 |
data: {
|
292 |
title: 'Create New Version',
|
293 |
-
message: '
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
confirmText: 'Create',
|
295 |
-
|
296 |
-
versions: this.versions
|
297 |
}
|
298 |
});
|
299 |
-
|
300 |
-
dialogRef.afterClosed().subscribe(async (
|
301 |
-
if (
|
302 |
-
this.
|
303 |
try {
|
304 |
-
|
305 |
-
source_version_id: sourceVersionId,
|
306 |
-
caption: 'New Version'
|
307 |
-
}).toPromise();
|
308 |
-
|
309 |
-
this.snackBar.open('Version created successfully', 'Close', { duration: 3000 });
|
310 |
-
|
311 |
-
// Reload project to get new version
|
312 |
-
await this.reloadProject();
|
313 |
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
}
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
|
|
|
|
|
|
324 |
} finally {
|
325 |
-
this.
|
326 |
}
|
327 |
}
|
328 |
});
|
|
|
287 |
|
288 |
async createVersion() {
|
289 |
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
290 |
+
width: '400px',
|
291 |
data: {
|
292 |
title: 'Create New Version',
|
293 |
+
message: 'Select source version:',
|
294 |
+
showDropdown: true,
|
295 |
+
dropdownOptions: this.versions.map(v => ({
|
296 |
+
value: v.id,
|
297 |
+
label: `Version ${v.id}${v.published ? ' (Published)' : ''}${v.description ? ' - ' + v.description : ''}`
|
298 |
+
})),
|
299 |
+
dropdownPlaceholder: 'Select source version (or leave empty for blank)',
|
300 |
confirmText: 'Create',
|
301 |
+
cancelText: 'Cancel'
|
|
|
302 |
}
|
303 |
});
|
304 |
+
|
305 |
+
dialogRef.afterClosed().subscribe(async (result) => {
|
306 |
+
if (result?.confirmed) {
|
307 |
+
this.loading = true;
|
308 |
try {
|
309 |
+
let newVersionData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
|
311 |
+
if (result.selectedValue) {
|
312 |
+
// Copy from selected version
|
313 |
+
const sourceVersion = this.versions.find(v => v.id === result.selectedValue);
|
314 |
+
if (sourceVersion) {
|
315 |
+
newVersionData = {
|
316 |
+
...sourceVersion,
|
317 |
+
id: undefined,
|
318 |
+
published: false,
|
319 |
+
last_update_date: undefined,
|
320 |
+
description: `Copy of version ${sourceVersion.id}`
|
321 |
+
};
|
322 |
+
}
|
323 |
+
} else {
|
324 |
+
// Create blank version
|
325 |
+
newVersionData = {
|
326 |
+
description: 'New version',
|
327 |
+
default_api: '',
|
328 |
+
published: false,
|
329 |
+
llm: {
|
330 |
+
repo_id: '',
|
331 |
+
generation_config: {
|
332 |
+
max_new_tokens: 512,
|
333 |
+
temperature: 0.7,
|
334 |
+
top_p: 0.95,
|
335 |
+
top_k: 50,
|
336 |
+
repetition_penalty: 1.1
|
337 |
+
},
|
338 |
+
use_fine_tune: false,
|
339 |
+
fine_tune_zip: ''
|
340 |
+
},
|
341 |
+
intents: [],
|
342 |
+
parameters: []
|
343 |
+
};
|
344 |
}
|
345 |
+
|
346 |
+
if (newVersionData) {
|
347 |
+
await this.apiService.createVersion(this.project.id, newVersionData).toPromise();
|
348 |
+
await this.loadVersions();
|
349 |
+
this.snackBar.open('Version created successfully!', 'Close', { duration: 3000 });
|
350 |
+
}
|
351 |
+
} catch (error) {
|
352 |
+
this.snackBar.open('Failed to create version', 'Close', { duration: 3000 });
|
353 |
} finally {
|
354 |
+
this.loading = false;
|
355 |
}
|
356 |
}
|
357 |
});
|