|
3 | 3 | @for (message of chat.messages; track message.id) { |
4 | 4 | <div class="message" [ngClass]="message.role"> |
5 | 5 | @for (part of message.parts; track $index) { |
6 | | - @switch (part.type) { |
7 | | - @case ('text') { |
8 | | - <div style="white-space: pre-wrap"> |
9 | | - {{ part.text }} |
10 | | - @if (part.state === 'streaming') { |
11 | | - <span class="typing-cursor">▮</span> |
12 | | - } |
| 6 | + @if (part.type === 'text') { |
| 7 | + <div style="white-space: pre-wrap"> |
| 8 | + {{ part.text }} |
| 9 | + @if (part.state === 'streaming') { |
| 10 | + <span class="typing-cursor">▮</span> |
| 11 | + } |
| 12 | + </div> |
| 13 | + } @else if (part.type === 'reasoning') { |
| 14 | + <details> |
| 15 | + <summary>Reasoning</summary> |
| 16 | + <div style="white-space: pre-wrap; font-size: 90%; opacity: 80%"> |
| 17 | + <div>{{ part.text }}</div> |
13 | 18 | </div> |
14 | | - } |
15 | | - @case ('reasoning') { |
16 | | - <details> |
17 | | - <summary>Reasoning</summary> |
18 | | - <div |
19 | | - style="white-space: pre-wrap; font-size: 90%; opacity: 80%" |
| 19 | + </details> |
| 20 | + } @else if (part.type === 'file') { |
| 21 | + <div class="file-part"> |
| 22 | + @if (part.mediaType.startsWith('image/')) { |
| 23 | + <img |
| 24 | + class="file-image" |
| 25 | + [src]="part.url" |
| 26 | + [alt]="part.filename ?? 'image attachment'" |
| 27 | + /> |
| 28 | + } @else { |
| 29 | + <a |
| 30 | + class="file-link" |
| 31 | + [href]="part.url" |
| 32 | + target="_blank" |
| 33 | + rel="noreferrer" |
20 | 34 | > |
21 | | - <div>{{ part.text }}</div> |
| 35 | + {{ part.filename ?? part.url }} |
| 36 | + </a> |
| 37 | + } |
| 38 | + <div class="file-meta">{{ part.mediaType }}</div> |
| 39 | + </div> |
| 40 | + } @else if (part.type === 'source-url') { |
| 41 | + <div class="source-part"> |
| 42 | + <a |
| 43 | + class="source-link" |
| 44 | + [href]="part.url" |
| 45 | + target="_blank" |
| 46 | + rel="noreferrer" |
| 47 | + > |
| 48 | + {{ part.title ?? part.url }} |
| 49 | + </a> |
| 50 | + <div class="source-meta">Source: {{ part.sourceId }}</div> |
| 51 | + </div> |
| 52 | + } @else if (part.type === 'source-document') { |
| 53 | + <div class="source-part"> |
| 54 | + <div class="source-title">{{ part.title }}</div> |
| 55 | + <div class="source-meta"> |
| 56 | + {{ part.filename ?? part.mediaType }} |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + } @else if (part.type === 'step-start') { |
| 60 | + <!-- <div class="step-separator">Step</div> --> |
| 61 | + } @else if (isToolPart(part)) { |
| 62 | + <div class="tool-call"> |
| 63 | + <div class="tool-name"> |
| 64 | + Tool: {{ part.type.replace('tool-', '') }} |
| 65 | + </div> |
| 66 | + <div class="tool-status">Status: {{ part.state }}</div> |
| 67 | + @if (part.input !== undefined) { |
| 68 | + <pre class="tool-input">{{ part.input | json }}</pre> |
| 69 | + } |
| 70 | + @if (part.output !== undefined) { |
| 71 | + <div class="tool-result-container"> |
| 72 | + <div class="tool-result-title">Result</div> |
| 73 | + <pre class="tool-result">{{ part.output | json }}</pre> |
22 | 74 | </div> |
23 | | - </details> |
24 | | - } |
25 | | - @default { |
26 | | - <code>{{ part | json }}</code> |
27 | | - } |
| 75 | + } |
| 76 | + @if (part.errorText) { |
| 77 | + <div class="tool-error">{{ part.errorText }}</div> |
| 78 | + } |
| 79 | + </div> |
| 80 | + } @else if (isDataPart(part)) { |
| 81 | + <div class="data-part"> |
| 82 | + <div class="data-title"> |
| 83 | + Data: {{ part.type.replace('data-', '') }} |
| 84 | + </div> |
| 85 | + <pre class="data-body">{{ part.data | json }}</pre> |
| 86 | + </div> |
| 87 | + } @else { |
| 88 | + <code>{{ part | json }}</code> |
28 | 89 | } |
29 | 90 | } |
30 | 91 | </div> |
|
0 commit comments