|
2 | 2 | import { Button } from '@sveltestrap/sveltestrap'; |
3 | 3 | import moment from 'moment'; |
4 | 4 | import { replaceNewLine } from '$lib/helpers/http'; |
5 | | - import { UserRole } from '$lib/helpers/enums'; |
| 5 | + import { ContentLogSource } from '$lib/helpers/enums'; |
6 | 6 |
|
7 | 7 | /** @type {import('$types').ConversationContentLogModel} */ |
8 | 8 | export let data; |
9 | 9 |
|
10 | 10 | let logBackground = ''; |
11 | 11 | let is_collapsed = true; |
12 | | - const excludedRoles = [ |
13 | | - UserRole.User, |
14 | | - UserRole.Assistant |
| 12 | + const includedSources = [ |
| 13 | + ContentLogSource.Prompt |
15 | 14 | ]; |
16 | 15 |
|
17 | 16 | $: { |
18 | | - if (data.role == UserRole.Assistant) { |
| 17 | + if (data.source === ContentLogSource.AgentResponse) { |
19 | 18 | logBackground = 'bg-info'; |
20 | | - } else if (data.role == UserRole.Function) { |
| 19 | + } else if (data.source === ContentLogSource.FunctionCall) { |
21 | 20 | logBackground = 'bg-secondary'; |
| 21 | + } else if (data.source === ContentLogSource.Prompt) { |
| 22 | + logBackground = 'bg-danger'; |
| 23 | + } else if (data.source === ContentLogSource.HardRule) { |
| 24 | + logBackground = "bg-warning"; |
22 | 25 | } |
23 | 26 | } |
24 | 27 |
|
|
34 | 37 | <b>{`[${data?.name?.length > 0 ? data?.name + ' ' : ''}${moment.utc(data?.created_at).local().format('hh:mm:ss.SSS A, MMM DD YYYY')}]`}</b> |
35 | 38 | </div> |
36 | 39 | <br> |
37 | | - <div class="log-content" class:log-collapse={!excludedRoles.includes(data.role) && !!is_collapsed}> |
| 40 | + <div class="log-content" class:log-collapse={includedSources.includes(data.source) && !!is_collapsed}> |
38 | 41 | {@html replaceNewLine(data?.content)} |
39 | 42 | </div> |
40 | | - {#if !excludedRoles.includes(data.role)} |
| 43 | + {#if includedSources.includes(data.source)} |
41 | 44 | <Button class='toggle-btn' color="link" on:click={(e) => toggleText(e)}> |
42 | 45 | {`${is_collapsed ? 'More +' : 'Less -'}`} |
43 | 46 | </Button> |
|
0 commit comments