mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-27 01:11:40 +00:00
5 lines
224 B
TypeScript
5 lines
224 B
TypeScript
import type { Msg, Role } from '../types.js'
|
|
|
|
export function upsert(prev: Msg[], role: Role, text: string): Msg[] {
|
|
return prev.at(-1)?.role === role ? [...prev.slice(0, -1), { role, text }] : [...prev, { role, text }]
|
|
}
|