mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-27 01:11:40 +00:00
chore: fmt
This commit is contained in:
parent
c3eeb03e26
commit
9c2c9e3a3e
8 changed files with 236 additions and 69 deletions
|
|
@ -5,9 +5,20 @@ import { LONG_MSG, ROLE } from '../constants.js'
|
|||
import { hasAnsi, userDisplay } from '../lib/text.js'
|
||||
import type { Theme } from '../theme.js'
|
||||
import type { Msg } from '../types.js'
|
||||
|
||||
import { Md } from './markdown.js'
|
||||
|
||||
export const MessageLine = memo(function MessageLine({ cols, compact, msg, t }: { cols: number; compact?: boolean; msg: Msg; t: Theme }) {
|
||||
export const MessageLine = memo(function MessageLine({
|
||||
cols,
|
||||
compact,
|
||||
msg,
|
||||
t
|
||||
}: {
|
||||
cols: number
|
||||
compact?: boolean
|
||||
msg: Msg
|
||||
t: Theme
|
||||
}) {
|
||||
const { body, glyph, prefix } = ROLE[msg.role](t)
|
||||
const contentWidth = Math.max(20, cols - 5)
|
||||
|
||||
|
|
@ -20,8 +31,9 @@ export const MessageLine = memo(function MessageLine({ cols, compact, msg, t }:
|
|||
}
|
||||
|
||||
const content = (() => {
|
||||
if (msg.role === 'assistant')
|
||||
if (msg.role === 'assistant') {
|
||||
return hasAnsi(msg.text) ? <Text wrap="wrap">{msg.text}</Text> : <Md compact={compact} t={t} text={msg.text} />
|
||||
}
|
||||
|
||||
if (msg.role === 'user' && msg.text.length > LONG_MSG) {
|
||||
const [head, ...rest] = userDisplay(msg.text).split('[long message]')
|
||||
|
|
@ -29,7 +41,9 @@ export const MessageLine = memo(function MessageLine({ cols, compact, msg, t }:
|
|||
return (
|
||||
<Text color={body}>
|
||||
{head}
|
||||
<Text color={t.color.dim} dimColor>[long message]</Text>
|
||||
<Text color={t.color.dim} dimColor>
|
||||
[long message]
|
||||
</Text>
|
||||
{rest.join('')}
|
||||
</Text>
|
||||
)
|
||||
|
|
@ -40,16 +54,16 @@ export const MessageLine = memo(function MessageLine({ cols, compact, msg, t }:
|
|||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
{(msg.role === 'user' || msg.role === 'assistant') && <Text>{' '}</Text>}
|
||||
{(msg.role === 'user' || msg.role === 'assistant') && <Text> </Text>}
|
||||
|
||||
<Box>
|
||||
<Box flexShrink={0} width={3}>
|
||||
<Text bold={msg.role === 'user'} color={prefix}>{glyph} </Text>
|
||||
<Text bold={msg.role === 'user'} color={prefix}>
|
||||
{glyph}{' '}
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
<Box width={contentWidth}>
|
||||
{content}
|
||||
</Box>
|
||||
<Box width={contentWidth}>{content}</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue