feat: implement answer-limited state handling in voice stream service
- Introduced handling for 'answer_limited' events from the server, allowing the UI to reflect when an assistant's answer has reached the output-token limit. - Updated the VoiceStreamService to manage limited and interrupted turns with bounded memory. - Enhanced the transcript component to display appropriate messages for limited answers, including a fallback for unavailable text. - Added styles to visually indicate limited answers in the UI. - Created unit tests for the new functionality, ensuring correct behavior for limited answers and their presentation.
This commit is contained in:
@@ -5,13 +5,23 @@
|
||||
[class.is-user]="message.role === 'user'"
|
||||
[class.is-partial]="!message.final"
|
||||
[class.is-interrupted]="message.interrupted"
|
||||
[class.is-limited]="message.limited && !message.interrupted"
|
||||
dir="rtl"
|
||||
>
|
||||
@if (message.text) {
|
||||
<span class="bubble-text">{{ message.text }}</span>
|
||||
} @else if (message.limited && !message.interrupted) {
|
||||
<!-- A limited answer with no transcript text: never manufacture spoken text. -->
|
||||
<span class="bubble-text is-missing">متن این پاسخ در دسترس نیست</span>
|
||||
}
|
||||
@if (message.interrupted) {
|
||||
<span class="bubble-tag">(قطع شد)</span>
|
||||
} @else if (message.limited) {
|
||||
<!-- Informational answer state: the answer is limited, not a failure and not complete. -->
|
||||
<span class="bubble-footer">
|
||||
<span class="bubble-tag is-limited">پاسخ محدود شده</span>
|
||||
<span class="bubble-help">برای توضیح بیشتر بگویید «ادامه بده».</span>
|
||||
</span>
|
||||
}
|
||||
@if (message.sources?.length) {
|
||||
<ul class="source-list" aria-label="منابع پاسخ">
|
||||
@@ -19,7 +29,7 @@
|
||||
<li
|
||||
class="source-chip"
|
||||
[class.is-unavailable]="source.available === false"
|
||||
[attr.title]="source.excerpt ?? null"
|
||||
[attr.title]="sourceTooltip(source)"
|
||||
>
|
||||
<span class="source-ref">{{ source.source_ref }}</span>
|
||||
<span class="source-label">{{ sourceLabel(source) }}</span>
|
||||
|
||||
Reference in New Issue
Block a user