Function
newMessage
(
role: ChatMessage["role"],
content: string,
)
Source from the content-addressed store, hash-verified
| 73 | } |
| 74 | |
| 75 | function newMessage( |
| 76 | role: ChatMessage["role"], |
| 77 | content: string, |
| 78 | ): ChatMessage { |
| 79 | return { |
| 80 | id: `${role[0]}-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`, |
| 81 | role, |
| 82 | content, |
| 83 | at: new Date().toISOString(), |
| 84 | }; |
| 85 | } |
| 86 | |
| 87 | export function ChatApp() { |
| 88 | const [session, setSession] = useState<ChatSession>(() => createSession()); |
Tested by
no test coverage detected