(from, text, rag)
| 11 | const { subscribe, update } = writable({ state: chatStates.IDLE, data: [] }); |
| 12 | |
| 13 | function addMessage(from, text, rag) { |
| 14 | const newId = Math.random().toString(36).substring(2, 9); |
| 15 | update((state) => { |
| 16 | const message = { id: newId, from, text, rag }; |
| 17 | state.data.push(message); |
| 18 | return state; |
| 19 | }); |
| 20 | return newId; |
| 21 | } |
| 22 | |
| 23 | function updateMessage(existingId, text, model = null) { |
| 24 | if (!existingId) { |