feat(voice): enhance streaming engine and improve system reliability
Improve the PCM playback worklet with robust resampling and buffer management. Refactor the voice-stream service for better session teardown and error handling. Fix authentication issues by enabling credentials in HttpService and using relative URLs. Add Jalali date support and an AI model configuration tab in settings. Enhance diagnostics for voice transport and the audio engine.
This commit is contained in:
@@ -69,6 +69,37 @@
|
||||
></span>
|
||||
}
|
||||
</button>
|
||||
|
||||
<div class="tab-divider w-px h-6 bg-black/25"></div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="tab-btn flex-1 flex items-center justify-center gap-2 px-4 py-3 text-sm font-medium text-[var(--text-muted)] transition-all duration-200 hover:text-[var(--text-primary)] relative"
|
||||
[class.tab-active]="activeTab() === 'models'"
|
||||
(click)="selectTab('models')"
|
||||
role="tab"
|
||||
[attr.aria-selected]="activeTab() === 'models'"
|
||||
>
|
||||
<svg
|
||||
class="w-4 h-4 transition-colors duration-200"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" />
|
||||
<path d="M19 10v2a7 7 0 0 1-14 0v-2" />
|
||||
<line x1="12" x2="12" y1="19" y2="22" />
|
||||
</svg>
|
||||
<span>تنظیمات مدلهای هوش مصنوعی</span>
|
||||
@if (activeTab() === 'models') {
|
||||
<span
|
||||
class="tab-indicator absolute bottom-0 left-1/2 -translate-x-1/2 w-6 h-0.5 bg-primary rounded-full"
|
||||
></span>
|
||||
}
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div class="settings-content p-6">
|
||||
@@ -313,13 +344,16 @@
|
||||
type="button"
|
||||
class="file-remove-btn p-1 text-[var(--text-muted)] rounded transition-colors hover:text-[var(--color-primary)]"
|
||||
(click)="retryUpload($index)"
|
||||
aria-label="دوبارهسعی آپلود"
|
||||
title="دوبارهسعی"
|
||||
aria-label="تلاش مجدد آپلود"
|
||||
title="تلاش مجدد"
|
||||
>
|
||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round">
|
||||
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
|
||||
<path d="M20 7v5h-5" />
|
||||
<path d="M4 17v-5h5" />
|
||||
<path d="M5.6 9a7 7 0 0 1 11.55-2.6L20 12" />
|
||||
<path d="M4 12l2.85 5.6A7 7 0 0 0 18.4 15" />
|
||||
</svg>
|
||||
</button>
|
||||
}
|
||||
@@ -332,12 +366,20 @@
|
||||
<div class="documents-section mt-8">
|
||||
@if (!isAdmin()) {
|
||||
<div class="documents-locked flex flex-col items-center justify-center gap-3 py-10 text-center">
|
||||
<svg class="w-10 h-10 text-[var(--text-muted)]" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
|
||||
stroke-linejoin="round">
|
||||
<path d="M12 1.75v20.5" />
|
||||
<path d="M4.25 12h15.5" />
|
||||
</svg>
|
||||
<svg
|
||||
class="w-5 h-5 text-primary"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
||||
<polyline points="14 2 14 8 20 8" />
|
||||
<line x1="8" y1="13" x2="16" y2="13" />
|
||||
<line x1="8" y1="17" x2="16" y2="17" />
|
||||
</svg>
|
||||
<p class="text-sm text-[var(--text-secondary)]">مدیریت و لیست اسناد فقط برای ادمینها در دسترس است.</p>
|
||||
</div>
|
||||
}
|
||||
@@ -346,18 +388,19 @@
|
||||
<div class="section-header mb-4">
|
||||
<h2 class="text-xl font-semibold text-[var(--text-primary)] mb-1 flex items-center gap-2">
|
||||
<svg
|
||||
class="w-5 h-5 text-primary"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
||||
<polyline points="14 2 14 8 20 8" />
|
||||
<polyline points="14 8 20 8 20 14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8z" />
|
||||
</svg>
|
||||
class="w-5 h-5 text-primary"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
||||
<polyline points="14 2 14 8 20 8" />
|
||||
<line x1="8" y1="13" x2="16" y2="13" />
|
||||
<line x1="8" y1="17" x2="16" y2="17" />
|
||||
</svg>
|
||||
اسناد آپلود شده
|
||||
</h2>
|
||||
<p class="text-sm text-[var(--text-muted)]">
|
||||
@@ -367,13 +410,20 @@
|
||||
|
||||
@if (documentsLoading() && documents().length === 0) {
|
||||
<div class="documents-loading flex items-center justify-center gap-2 py-10 text-[var(--text-muted)]">
|
||||
<svg class="w-5 h-5 animate-spin" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<line x1="12" y1="5" x2="12" y2="19" />
|
||||
<path d="M19 12a7 7 0 1 1-14 0a7 7 0 0 1 14 0z" />
|
||||
</svg>
|
||||
<span>در حال بارگذاری اسناد...</span>
|
||||
</div>
|
||||
<svg
|
||||
class="w-5 h-5 animate-spin"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<circle cx="12" cy="12" r="9" stroke-opacity="0.2" />
|
||||
<path d="M21 12a9 9 0 0 0-9-9" />
|
||||
</svg>
|
||||
<span>در حال بارگذاری اسناد...</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (documentsError() && documents().length === 0) {
|
||||
@@ -389,7 +439,7 @@
|
||||
<div class="documents-filters mb-3 flex items-center justify-between gap-2">
|
||||
<div class="flex items-center gap-2">
|
||||
<select
|
||||
class="form-select bg-[var(--input-bg)] text-[var(--text-secondary)] border border-[var(--input-border)] rounded-lg px-3 py-1.5 text-xs min-w-[130px] cursor-pointer"
|
||||
class="form-select bg-[var(--color-input-bg)] text-[var(--text-secondary)] border border-[var(--color-input-border)] rounded-lg px-3 py-1.5 text-xs min-w-[130px] cursor-pointer"
|
||||
[value]="activeFilter()"
|
||||
(change)="activeFilter.set($any($event.target).value); applyDocumentFilters()"
|
||||
>
|
||||
@@ -407,11 +457,20 @@
|
||||
<span class="text-xs text-[var(--text-muted)]">فقط فعال</span>
|
||||
</div>
|
||||
<button type="button" class="btn btn--outline" (click)="refreshDocuments()" [disabled]="documentsLoading()">
|
||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M3 12a9 9 0 0 1 9-9a9 9 0 1 1 0 18a9 9 0 0 1 0-18z" />
|
||||
<path d="M12 8v4l2 2" />
|
||||
</svg>
|
||||
<svg
|
||||
class="w-4 h-4"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M20 7v5h-5" />
|
||||
<path d="M4 17v-5h5" />
|
||||
<path d="M5.6 9a7 7 0 0 1 11.55-2.6L20 12" />
|
||||
<path d="M4 12l2.85 5.6A7 7 0 0 0 18.4 15" />
|
||||
</svg>
|
||||
<span>بهروزرسانی</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -472,12 +531,17 @@
|
||||
@if (doc.status === 'ready' && !isReviewNeeded(doc) && isAdmin()) {
|
||||
@if (togglingDocId() === doc.id) {
|
||||
<div class="flex items-center gap-1.5 text-xs text-[var(--text-muted)]">
|
||||
<svg class="w-3 h-3 animate-spin" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round">
|
||||
<line x1="12" y1="5" x2="12" y2="19" />
|
||||
<path d="M19 12a7 7 0 0 1-14 0a7 7 0 0 1 14 0z" />
|
||||
</svg>
|
||||
<svg
|
||||
class="w-3 h-3 animate-spin"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
>
|
||||
<circle cx="12" cy="12" r="9" stroke-opacity="0.2" />
|
||||
<path d="M21 12a9 9 0 0 0-9-9" />
|
||||
</svg>
|
||||
<span>در حال بهروزرسانی</span>
|
||||
</div>
|
||||
} @else {
|
||||
@@ -493,8 +557,8 @@
|
||||
} @else {
|
||||
<span
|
||||
class="text-xs"
|
||||
[class.text-[var(--color-success)]="doc.is_active"
|
||||
[class.text-[var(--text-muted)]="!doc.is_active"
|
||||
[class.status-ready]="doc.is_active"
|
||||
[class.status-failed]="!doc.is_active"
|
||||
>{{ doc.is_active ? 'فعال' : 'غیرفعال' }}</span
|
||||
>
|
||||
}
|
||||
@@ -508,13 +572,19 @@
|
||||
[disabled]="reviewingDocId() === doc.id"
|
||||
(click)="openReview(doc)"
|
||||
>
|
||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round">
|
||||
<path d="M2 12s9-7 19-7c2.6 0 4.5 2 4.5 4.5S23.6 19 21 19s-4.5-2.5-4.5-4.5S17.4 7 9 7" />
|
||||
<path d="M2 12s9 7 19 7c2.6 0 4.5-2 4.5-4.5S23.6 7 21 7s-4.5 2.5-4.5 4.5S16.6 17 21 17" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg>
|
||||
<svg
|
||||
class="w-4 h-4"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg>
|
||||
<span>بازبینی سند</span>
|
||||
</button>
|
||||
}
|
||||
@@ -524,12 +594,21 @@
|
||||
class="btn btn--outline"
|
||||
(click)="retryDocument(doc)"
|
||||
>
|
||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round">
|
||||
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
|
||||
<svg
|
||||
class="w-4 h-4"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M20 7v5h-5" />
|
||||
<path d="M4 17v-5h5" />
|
||||
<path d="M5.6 9a7 7 0 0 1 11.55-2.6L20 12" />
|
||||
<path d="M4 12l2.85 5.6A7 7 0 0 0 18.4 15" />
|
||||
</svg>
|
||||
<span>دوبارهسعی</span>
|
||||
<span>تلاشمجدد</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
@@ -595,12 +674,18 @@
|
||||
<div class="review-modal-body">
|
||||
@if (reviewLoading()) {
|
||||
<div class="review-loading flex items-center justify-center gap-2 py-8 text-[var(--text-muted)]">
|
||||
<svg class="w-5 h-5 animate-spin" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round">
|
||||
<line x1="12" y1="5" x2="12" y2="19" />
|
||||
<path d="M19 12a7 7 0 0 1-14 0a7 7 0 0 1 14 0z" />
|
||||
</svg>
|
||||
<svg
|
||||
class="w-5 h-5 animate-spin"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<circle cx="12" cy="12" r="9" stroke-opacity="0.2" />
|
||||
<path d="M21 12a9 9 0 0 0-9-9" />
|
||||
</svg>
|
||||
<span>در حال بارگذاری شواهد...</span>
|
||||
</div>
|
||||
}
|
||||
@@ -742,11 +827,22 @@
|
||||
<footer class="review-modal-footer border-t border-[var(--color-card-border)] p-3 flex justify-end gap-2">
|
||||
@if (canRetryAfterReview()) {
|
||||
<button type="button" class="btn btn--primary" (click)="finishReviewAndRetry()">
|
||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M21 12A9 9 0 0 0 6.6 7.5l-3 3m0 0 3 3-3-3Z" />
|
||||
</svg>
|
||||
<span>بستن و دوبارهسعی پردازش</span>
|
||||
<svg
|
||||
class="w-4 h-4"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path d="M3 2v6h6" />
|
||||
<path d="M21 12a9 9 0 0 0-15-6.7L3 8" />
|
||||
<path d="M21 22v-6h-6" />
|
||||
<path d="M3 12a9 9 0 0 0 15 6.7L21 16" />
|
||||
</svg>
|
||||
<span>بستن و تلاش مجدد پردازش</span>
|
||||
</button>
|
||||
}
|
||||
<button type="button" class="btn btn--outline" (click)="closeReview()">
|
||||
@@ -809,7 +905,7 @@
|
||||
<span class="text-xs text-[var(--text-muted)] block mt-0.5">
|
||||
در صورت فعال بودن، محتوای استخراجشده از اسناد باید توسط ادمین بازبینی و تأیید شود.
|
||||
</span>
|
||||
<span class="text-xs text-[var(--color-warning)] mt-0.5">پیشنویس — ذخیرهسازی در فاز MVP پشتیبانی نمیشود</span>
|
||||
<!-- <span class="text-xs text-[var(--color-warning)] mt-0.5">پیشنویس — ذخیرهسازی در فاز MVP پشتیبانی نمیشود</span> -->
|
||||
</div>
|
||||
<div class="setting-control shrink-0">
|
||||
<label class="toggle-switch" [class.toggle-active]="ocrAdminApproval()">
|
||||
@@ -820,8 +916,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-8">
|
||||
<h3 class="text-lg font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2">
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (activeTab() === 'models') {
|
||||
<section class="models-section animate-fade-in">
|
||||
<div class="section-header mb-6">
|
||||
<h2 class="text-xl font-semibold text-[var(--text-primary)] mb-1 flex items-center gap-2">
|
||||
<svg class="w-5 h-5 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" />
|
||||
@@ -829,42 +930,42 @@
|
||||
<line x1="12" x2="12" y1="19" y2="22" />
|
||||
</svg>
|
||||
تنظیمات مدلهای هوش مصنوعی
|
||||
</h3>
|
||||
<p class="text-xs text-[var(--text-muted)] mb-4">
|
||||
</h2>
|
||||
<p class="text-sm text-[var(--text-muted)]">
|
||||
هر کارت بهصورت مستقل پیکربندی میشود. در فاز MVP، این تنظیمات در حافظه نگهداری میشوند و به سرور ارسال نمیشوند.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="ai-models-grid grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<app-ai-model-config-card
|
||||
title="تنظیمات مدل هوش مصنوعی"
|
||||
task="text"
|
||||
[config]="textModelConfig()"
|
||||
(configChange)="textModelConfig.set($event)"
|
||||
[connected]="textModelConnected()"
|
||||
(save)="saveModelConfig('text')"
|
||||
(testConnection)="testModelConnection('text')"
|
||||
></app-ai-model-config-card>
|
||||
<div class="ai-models-grid grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<app-ai-model-config-card
|
||||
title="تنظیمات مدل هوش مصنوعی"
|
||||
task="text"
|
||||
[config]="textModelConfig()"
|
||||
(configChange)="textModelConfig.set($event)"
|
||||
[connected]="textModelConnected()"
|
||||
(save)="saveModelConfig('text')"
|
||||
(testConnection)="testModelConnection('text')"
|
||||
></app-ai-model-config-card>
|
||||
|
||||
<app-ai-model-config-card
|
||||
title="تنظیمات مدل امبدینگ"
|
||||
task="embedding"
|
||||
[config]="embeddingModelConfig()"
|
||||
(configChange)="embeddingModelConfig.set($event)"
|
||||
[connected]="embeddingModelConnected()"
|
||||
(save)="saveModelConfig('embedding')"
|
||||
(testConnection)="testModelConnection('embedding')"
|
||||
></app-ai-model-config-card>
|
||||
<app-ai-model-config-card
|
||||
title="تنظیمات مدل امبدینگ"
|
||||
task="embedding"
|
||||
[config]="embeddingModelConfig()"
|
||||
(configChange)="embeddingModelConfig.set($event)"
|
||||
[connected]="embeddingModelConnected()"
|
||||
(save)="saveModelConfig('embedding')"
|
||||
(testConnection)="testModelConnection('embedding')"
|
||||
></app-ai-model-config-card>
|
||||
|
||||
<app-ai-model-config-card
|
||||
title="تنظیمات مدل OCR"
|
||||
task="ocr"
|
||||
[config]="ocrModelConfig()"
|
||||
(configChange)="ocrModelConfig.set($event)"
|
||||
[connected]="ocrModelConnected()"
|
||||
(save)="saveModelConfig('ocr')"
|
||||
(testConnection)="testModelConnection('ocr')"
|
||||
></app-ai-model-config-card>
|
||||
</div>
|
||||
<app-ai-model-config-card
|
||||
title="تنظیمات مدل OCR"
|
||||
task="ocr"
|
||||
[config]="ocrModelConfig()"
|
||||
(configChange)="ocrModelConfig.set($event)"
|
||||
[connected]="ocrModelConnected()"
|
||||
(save)="saveModelConfig('ocr')"
|
||||
(testConnection)="testModelConnection('ocr')"
|
||||
></app-ai-model-config-card>
|
||||
</div>
|
||||
|
||||
<div class="mt-8">
|
||||
|
||||
Reference in New Issue
Block a user