Skip to content

Commit 426de54

Browse files
committed
assistant message info title tells when custom prompt used
1 parent 77f0c20 commit 426de54

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

src/client/components/ChatV2/Conversation.tsx

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import { LoadingMessage } from './general/LoadingMessage'
1010
import { preprocessMath } from './util'
1111
import 'katex/dist/katex.min.css'
1212
import 'katex/dist/contrib/mhchem'
13-
import CopyToClipboardButton from './CopyToClipboardButton'
14-
import { t } from 'i18next'
13+
import { ArrowRight } from '@mui/icons-material'
1514
import FormatQuoteIcon from '@mui/icons-material/FormatQuote'
15+
import { t } from 'i18next'
16+
import { useId, useMemo } from 'react'
17+
import { useTranslation } from 'react-i18next'
18+
import type { AssistantMessage, ChatMessage, MessageGenerationInfo, ToolCallResultEvent, ToolCallStatusEvent, UserMessage } from '../../../shared/chat'
1619
import useLocalStorageState from '../../hooks/useLocalStorageState'
20+
import CopyToClipboardButton from './CopyToClipboardButton'
1721
import { BlueButton } from './general/Buttons'
18-
import type { AssistantMessage, ChatMessage, MessageGenerationInfo, ToolCallResultEvent, ToolCallStatusEvent, UserMessage } from '../../../shared/chat'
19-
import { useId, useMemo } from 'react'
20-
import { ArrowRight } from '@mui/icons-material'
2122

2223
const UserMessageItem = ({ message }: { message: UserMessage }) => (
2324
<Box
@@ -104,12 +105,13 @@ const ToolResult = ({ toolResult, handleToolResult }: { toolResult: ToolCallResu
104105
}
105106

106107
const AssistantMessageInfo = ({ message }: { message: AssistantMessage }) => {
108+
const { t } = useTranslation()
107109
if (!message.generationInfo) return null
108110

109111
const title =
110112
message.generationInfo.promptInfo.type === 'saved'
111113
? `${message.generationInfo.promptInfo.name} (${message.generationInfo.model})`
112-
: `${message.generationInfo.model}`
114+
: `${message.generationInfo.model}` + (message.generationInfo.promptInfo.systemMessage.length > 0 ? ` (${t('chat:customPrompt')})` : '')
113115

114116
return (
115117
<Box sx={{ display: 'flex', opacity: 0.7, alignItems: 'center' }}>
@@ -246,7 +248,11 @@ const AssistantMessageItem = ({ message, setActiveToolResult }: { message: Assis
246248
id={codeBlockId}
247249
copied={String(children)}
248250
iconColor="#FFF"
249-
buttonStyle={{ position: 'absolute', top: '8px', right: '8px' }}
251+
buttonStyle={{
252+
position: 'absolute',
253+
top: '8px',
254+
right: '8px',
255+
}}
250256
/>
251257
</Box>
252258
</Box>
@@ -336,13 +342,30 @@ export const Conversation = ({
336342
{isStreaming &&
337343
messages.length > 0 &&
338344
(completion.length > 0 ? (
339-
<MessageItem message={{ role: 'assistant', content: completion, generationInfo }} setActiveToolResult={setActiveToolResult} />
345+
<MessageItem
346+
message={{
347+
role: 'assistant',
348+
content: completion,
349+
generationInfo,
350+
}}
351+
setActiveToolResult={setActiveToolResult}
352+
/>
340353
) : (
341354
<LoadingMessage toolCalls={toolCalls} />
342355
))}
343356
</Box>
344357
{!reminderSeen && !isStreaming && messages.length > 15 && (
345-
<Paper variant="outlined" sx={{ display: 'flex', flexDirection: 'row', gap: 2, fontStyle: 'italic', alignItems: 'center', padding: 2 }}>
358+
<Paper
359+
variant="outlined"
360+
sx={{
361+
display: 'flex',
362+
flexDirection: 'row',
363+
gap: 2,
364+
fontStyle: 'italic',
365+
alignItems: 'center',
366+
padding: 2,
367+
}}
368+
>
346369
<Typography>{t('chat:emptyReminder')}</Typography>
347370
<BlueButton sx={{ marginLeft: 'auto' }} onClick={() => setReminderSeen(true)}>
348371
OK

src/client/locales/en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@
111111
"email": "The conversation will be sent to {{email}}",
112112
"cancelResponse": "Canceling responses is currently not supported",
113113
"searchResults": "Search results",
114-
"warning": "The new chat view is experiencing problems and the response generation is very slow. The old chat view is working normally."
114+
"warning": "The new chat view is experiencing problems and the response generation is very slow. The old chat view is working normally.",
115+
"customPrompt": "custom prompt"
115116
},
116117
"settings": {
117118
"prompt": "Conversation prompt",
@@ -357,4 +358,4 @@
357358
"nameLabel": "Collection name",
358359
"nameHelperText": "Use a descriptive name (for example the full name of the course)"
359360
}
360-
}
361+
}

src/client/locales/fi.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@
111111
"email": "Keskustelu lähetetään osoitteeseen {{email}}",
112112
"cancelResponse": "Vastausten keskeyttäminen on toistaiseksi pois käytöstä.",
113113
"searchResults": "Hakutulokset",
114-
"warning": "Uudessa chattinäkymässä on tällä hetkellä ongelmia ja vastausten generointi on hidastunut. Vanha chattinäkymä toimii normaalisti."
114+
"warning": "Uudessa chattinäkymässä on tällä hetkellä ongelmia ja vastausten generointi on hidastunut. Vanha chattinäkymä toimii normaalisti.",
115+
"customPrompt": "Kustomoitu alustus"
115116
},
116117
"settings": {
117118
"prompt": "Keskustelun alustus",

0 commit comments

Comments
 (0)