ciyidogan commited on
Commit
a0f9d12
·
verified ·
1 Parent(s): c28ca1d

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
@@ -121,54 +121,51 @@ export default class VersionEditDialogComponent implements OnInit {
121
 
122
  loadVersion(version: Version) {
123
  this.selectedVersion = version;
124
-
125
- // Reset form to initial state
126
- this.initializeForm();
127
-
128
- // Populate basic fields
129
  this.versionForm.patchValue({
130
- id: version.id,
131
- caption: version.caption,
132
- published: version.published,
133
- general_prompt: version.general_prompt || '',
134
- llm: version.llm || {
135
- repo_id: '',
136
- generation_config: {
137
- max_new_tokens: 256,
138
- temperature: 0.2,
139
- top_p: 0.8,
140
- repetition_penalty: 1.1
141
- },
142
- use_fine_tune: false,
143
- fine_tune_zip: ''
144
  },
145
- last_update_date: version.last_update_date || ''
 
146
  });
147
-
148
- // Populate intents
149
- const intentsArray = this.versionForm.get('intents') as FormArray;
150
- if (version.intents) {
151
- version.intents.forEach(intent => {
152
- const intentFormGroup = this.createIntentFormGroup(intent);
153
-
154
- // Parameters'ı ayrı olarak ekle
155
- if (intent.parameters) {
156
- this.populateIntentParameters(intentFormGroup, intent.parameters);
157
- }
158
-
159
- intentsArray.push(intentFormGroup);
160
  });
161
- }
162
-
163
- // Enable/disable form based on published status
164
- if (version.published) {
165
- this.versionForm.disable();
166
- this.snackBar.open('This version is published and cannot be edited', 'OK', { duration: 3000 });
167
- } else {
168
- this.versionForm.enable();
169
- this.versionForm.get('id')?.disable();
170
- this.versionForm.get('published')?.disable();
171
- }
 
 
 
 
172
  }
173
 
174
  createIntentFormGroup(intent: any = {}): FormGroup {
 
121
 
122
  loadVersion(version: Version) {
123
  this.selectedVersion = version;
 
 
 
 
 
124
  this.versionForm.patchValue({
125
+ caption: version.caption || '',
126
+ description: version.caption || '', // description yerine caption kullan
127
+ default_api: version.default_api || '',
128
+ published: version.published || false,
129
+ repo_id: version.llm?.repo_id || '',
130
+ generation_config: version.llm?.generation_config || {
131
+ max_new_tokens: 512,
132
+ temperature: 0.7,
133
+ top_p: 0.95,
134
+ top_k: 50,
135
+ repetition_penalty: 1.1
 
 
 
136
  },
137
+ use_fine_tune: version.llm?.use_fine_tune || false,
138
+ fine_tune_zip: version.llm?.fine_tune_zip || ''
139
  });
140
+
141
+ // Clear and rebuild intents
142
+ this.intents.clear();
143
+ (version.intents || []).forEach(intent => {
144
+ this.addIntent();
145
+ const intentIndex = this.intents.length - 1;
146
+ const intentGroup = this.intents.at(intentIndex);
147
+
148
+ intentGroup.patchValue({
149
+ name: intent.name,
150
+ description: intent.description || '',
151
+ api_to_call: intent.api_to_call || '',
152
+ enabled: intent.enabled !== false
153
  });
154
+
155
+ // Add intent parameters
156
+ const paramsArray = this.getIntentParameters(intentIndex);
157
+ paramsArray.clear();
158
+ (intent.parameters || []).forEach(param => {
159
+ paramsArray.push(this.createParameterFormGroup(param));
160
+ });
161
+
162
+ // Add examples
163
+ const examplesArray = this.getIntentExamples(intentIndex);
164
+ examplesArray.clear();
165
+ (intent.examples || []).forEach(example => {
166
+ examplesArray.push(this.fb.control(example));
167
+ });
168
+ });
169
  }
170
 
171
  createIntentFormGroup(intent: any = {}): FormGroup {