Spaces:
Building
Building
File size: 16,141 Bytes
9f79da5 c9eb948 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
<mat-dialog-content class="version-management-container">
<h2 mat-dialog-title>
Manage Versions - {{ project.name }}
<mat-chip-listbox class="title-chips">
<mat-chip-option [disabled]="true">
<mat-icon>layers</mat-icon>
{{ versions.length }} versions
</mat-chip-option>
</mat-chip-listbox>
</h2>
<div class="dialog-content">
<!-- Version Selector -->
<div class="version-selector">
<mat-form-field appearance="outline" class="version-select">
<mat-label>Select Version</mat-label>
<mat-select [(value)]="selectedVersion" (selectionChange)="loadVersion($event.value)">
<mat-option *ngFor="let version of versions" [value]="version">
Version {{ version.no }} - {{ version.caption || 'No description' }}
<span class="version-status" *ngIf="version.published">[Published]</span>
</mat-option>
</mat-select>
</mat-form-field>
<div class="version-actions">
<button mat-raised-button color="primary" (click)="createVersion()" [disabled]="creating">
<mat-icon>add</mat-icon>
New Version
</button>
<button mat-button (click)="compareVersions()" [disabled]="versions.length < 2">
<mat-icon>compare_arrows</mat-icon>
Compare
</button>
</div>
</div>
<mat-progress-bar *ngIf="loading" mode="indeterminate"></mat-progress-bar>
<!-- Warning for published version -->
<div class="alert alert-warning" *ngIf="selectedVersion?.published">
<mat-icon>info</mat-icon>
This version is published and cannot be edited. Create a new version or unpublish to make changes.
</div>
<!-- Version Editor -->
<div class="version-editor" *ngIf="selectedVersion && !loading">
<form [formGroup]="versionForm">
<mat-tab-group [(selectedIndex)]="selectedTabIndex" dynamicHeight>
<!-- General Tab -->
<mat-tab label="General">
<div class="tab-content">
<div class="metadata-info">
<mat-chip-listbox>
<mat-chip-option>Version {{ selectedVersion.no }}</mat-chip-option>
<mat-chip-option *ngIf="selectedVersion.published" selected>Published</mat-chip-option>
<mat-chip-option *ngIf="!selectedVersion.published">Draft</mat-chip-option>
<mat-chip-option *ngIf="selectedVersion.last_update_date">
Last updated: {{ selectedVersion.last_update_date | date:'short' }}
</mat-chip-option>
</mat-chip-listbox>
</div>
<mat-form-field appearance="outline" class="full-width">
<mat-label>Caption</mat-label>
<input matInput formControlName="caption" placeholder="Version description" [readonly]="!canEdit">
</mat-form-field>
<mat-form-field appearance="outline" class="full-width">
<mat-label>General System Prompt</mat-label>
<textarea matInput
class="code-textarea"
formControlName="general_prompt"
rows="10"
placeholder="Define the assistant's behavior and capabilities..."
[readonly]="!canEdit"></textarea>
<mat-hint>This prompt defines the overall behavior of your assistant</mat-hint>
</mat-form-field>
<mat-form-field appearance="outline" class="full-width">
<mat-label>Welcome Prompt</mat-label>
<textarea matInput formControlName="welcome_prompt" rows="4" [readonly]="!canEdit"></textarea>
<mat-hint>Initial greeting message (use {{ '{{user_name}}' }} for personalization)</mat-hint>
</mat-form-field>
<div class="action-buttons">
<button mat-raised-button color="warn"
(click)="deleteVersion()"
[disabled]="selectedVersion.published"
*ngIf="!selectedVersion.published">
<mat-icon>delete</mat-icon>
Delete Version
</button>
</div>
</div>
</mat-tab>
<!-- LLM Configuration Tab -->
<mat-tab label="LLM">
<div class="tab-content" formGroupName="llm">
<mat-form-field appearance="outline" class="full-width">
<mat-label>Model Repository ID</mat-label>
<input matInput formControlName="repo_id"
placeholder="e.g., ytu-ce-cosmos/Turkish-Llama-8b-Instruct-v0.1"
[readonly]="!canEdit">
<mat-hint>HuggingFace model repository ID</mat-hint>
</mat-form-field>
<h4>Generation Configuration</h4>
<div formGroupName="generation_config" class="generation-config">
<mat-form-field appearance="outline">
<mat-label>Max New Tokens</mat-label>
<input matInput type="number" formControlName="max_new_tokens" [readonly]="!canEdit">
<mat-hint>Maximum tokens to generate (1-2048)</mat-hint>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Temperature</mat-label>
<input matInput type="number" step="0.1" formControlName="temperature" [readonly]="!canEdit">
<mat-hint>Controls randomness (0-2)</mat-hint>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Top P</mat-label>
<input matInput type="number" step="0.1" formControlName="top_p" [readonly]="!canEdit">
<mat-hint>Nucleus sampling (0-1)</mat-hint>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Repetition Penalty</mat-label>
<input matInput type="number" step="0.1" formControlName="repetition_penalty" [readonly]="!canEdit">
<mat-hint>Penalty for repetition (1-2)</mat-hint>
</mat-form-field>
</div>
<mat-divider></mat-divider>
<div class="fine-tune-section">
<mat-checkbox formControlName="use_fine_tune" [disabled]="!canEdit">
Use Fine-Tuned Model
</mat-checkbox>
<mat-form-field appearance="outline" class="full-width"
*ngIf="versionForm.get('llm.use_fine_tune')?.value">
<mat-label>Fine-Tune ZIP URL</mat-label>
<input matInput formControlName="fine_tune_zip"
placeholder="https://example.com/lora-adapter.zip"
[readonly]="!canEdit">
<mat-hint>URL to LoRA adapter ZIP file</mat-hint>
</mat-form-field>
</div>
</div>
</mat-tab>
<!-- Intents Tab -->
<mat-tab label="Intents" [matBadge]="intents.length" matBadgeColor="primary">
<div class="tab-content">
<div class="intents-header">
<h3>Intent Definitions</h3>
<button mat-raised-button color="primary" (click)="addIntent()" [disabled]="!canEdit">
<mat-icon>add</mat-icon>
Add Intent
</button>
</div>
<!-- Example Language Selector -->
<mat-form-field appearance="outline" class="locale-selector">
<mat-label>Example Language</mat-label>
<mat-select [(value)]="selectedExampleLocale">
<mat-option *ngFor="let locale of getAvailableLocales()" [value]="locale.code">
{{ locale.name }}
</mat-option>
</mat-select>
</mat-form-field>
<div formArrayName="intents" class="intents-list">
<mat-expansion-panel *ngFor="let intent of intents.controls; let i = index"
[formGroupName]="i">
<mat-expansion-panel-header>
<mat-panel-title>
{{ intent.get('name')?.value || 'New Intent' }}
</mat-panel-title>
<mat-panel-description>
{{ intent.get('caption')?.value || 'No description' }}
<mat-chip-listbox class="intent-chips">
<mat-chip-option>{{ getIntentParameters(i).length }} params</mat-chip-option>
<mat-chip-option>{{ intent.get('action')?.value || 'No API' }}</mat-chip-option>
</mat-chip-listbox>
</mat-panel-description>
</mat-expansion-panel-header>
<div class="intent-content">
<div class="intent-actions">
<button mat-button color="primary" (click)="editIntent(i)" [disabled]="!canEdit">
<mat-icon>edit</mat-icon>
Edit Details
</button>
<button mat-button color="warn" (click)="removeIntent(i)" [disabled]="!canEdit">
<mat-icon>delete</mat-icon>
Delete
</button>
</div>
<!-- Quick view of intent details -->
<div class="intent-summary">
<div class="summary-item">
<strong>Detection Prompt:</strong>
<p>{{ intent.get('detection_prompt')?.value || 'Not set' }}</p>
</div>
<div class="summary-item" *ngIf="getLocalizedExamples(intent.get('examples')?.value, selectedExampleLocale).length > 0">
<strong>Examples ({{ getLocaleName(selectedExampleLocale) }}):</strong>
<div class="examples-display">
<mat-chip-row *ngFor="let ex of getLocalizedExamples(intent.get('examples')?.value, selectedExampleLocale)">
{{ ex.example }}
</mat-chip-row>
</div>
</div>
<div class="summary-item" *ngIf="getIntentParameters(i).length > 0">
<strong>Parameters:</strong>
<mat-list>
<mat-list-item *ngFor="let param of getIntentParameters(i).controls">
<mat-icon matListItemIcon>
{{ param.get('required')?.value ? 'check_box' : 'check_box_outline_blank' }}
</mat-icon>
<div matListItemTitle>{{ param.get('name')?.value }}</div>
<div matListItemLine>
{{ getParameterCaptionDisplay(param.get('caption')?.value) }}
({{ param.get('type')?.value }})
</div>
</mat-list-item>
</mat-list>
</div>
</div>
</div>
</mat-expansion-panel>
</div>
<div class="empty-state" *ngIf="intents.length === 0">
<mat-icon>psychology</mat-icon>
<p>No intents defined yet.</p>
<button mat-raised-button color="primary" (click)="addIntent()" [disabled]="!canEdit">
Add First Intent
</button>
</div>
</div>
</mat-tab>
<!-- Test Tab -->
<mat-tab label="Test">
<div class="tab-content">
<h3>Test Intent Detection</h3>
<p>Enter a user message to test which intent would be detected.</p>
<mat-form-field appearance="outline" class="full-width">
<mat-label>User Message</mat-label>
<textarea matInput
[(ngModel)]="testUserMessage"
[ngModelOptions]="{standalone: true}"
rows="3"
placeholder="e.g., I want to book a flight from Istanbul to Ankara"></textarea>
</mat-form-field>
<button mat-raised-button color="accent"
(click)="testIntentDetection()"
[disabled]="testing || !testUserMessage">
<mat-icon>play_arrow</mat-icon>
{{ testing ? 'Testing...' : 'Test Intent Detection' }}
</button>
<div class="test-result" *ngIf="testResult">
<h4>Test Result:</h4>
<div class="result-card" [class.success]="testResult.intent" [class.no-match]="!testResult.intent">
<div class="result-header">
<mat-icon>{{ testResult.intent ? 'check_circle' : 'info' }}</mat-icon>
<span *ngIf="testResult.intent">Intent Detected: <strong>{{ testResult.intent }}</strong></span>
<span *ngIf="!testResult.intent">No intent matched</span>
</div>
<div class="result-details" *ngIf="testResult.intent">
<div class="confidence">
Confidence: {{ (testResult.confidence * 100).toFixed(0) }}%
<mat-progress-bar [value]="testResult.confidence * 100"></mat-progress-bar>
</div>
<div class="parameters" *ngIf="testResult.parameters.length > 0">
<h5>Parameters that would be extracted:</h5>
<mat-list>
<mat-list-item *ngFor="let param of testResult.parameters">
<mat-icon matListItemIcon [color]="param.extracted ? 'primary' : ''">
{{ param.extracted ? 'check_circle' : 'radio_button_unchecked' }}
</mat-icon>
<div matListItemTitle>{{ param.name }}</div>
<div matListItemLine>
{{ param.extracted ? 'Value: ' + param.value : 'Missing - would ask user' }}
</div>
</mat-list-item>
</mat-list>
</div>
</div>
</div>
</div>
</div>
</mat-tab>
</mat-tab-group>
</form>
</div>
<!-- No Version Selected -->
<div class="empty-state" *ngIf="!selectedVersion && !loading">
<mat-icon>layers</mat-icon>
<p>No version selected. Create a new version to get started.</p>
<button mat-raised-button color="primary" (click)="createVersion()">
Create First Version
</button>
</div>
</div>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button (click)="close()">Close</button>
<button mat-raised-button
color="primary"
(click)="saveVersion()"
[disabled]="!selectedVersion || !canEdit || versionForm.invalid || saving">
{{ saving ? 'Saving...' : 'Save Changes' }}
</button>
<button mat-raised-button
color="accent"
(click)="publishVersion()"
[disabled]="!selectedVersion || selectedVersion.published || publishing || isDirty || versionForm.invalid">
{{ publishing ? 'Publishing...' : 'Publish Version' }}
</button>
</mat-dialog-actions> |