(session: Session)
| 209 | } |
| 210 | |
| 211 | function modifySessionBeforeSave(session: Session): Session { |
| 212 | const filteredHistory = session.history.filter((item) => { |
| 213 | return item.message.role !== "system"; |
| 214 | }); |
| 215 | |
| 216 | const modifiedHistory = filteredHistory.map((item) => { |
| 217 | if (item.message.role === "user") { |
| 218 | return { |
| 219 | ...item, |
| 220 | editorState: item.message.content, |
| 221 | }; |
| 222 | } |
| 223 | |
| 224 | return item; |
| 225 | }); |
| 226 | |
| 227 | return { |
| 228 | ...session, |
| 229 | history: modifiedHistory, |
| 230 | }; |
| 231 | } |
| 232 | |
| 233 | export function getSessionPersistenceSnapshot(session: Session): Session { |
| 234 | return modifySessionBeforeSave(session); |
no outgoing calls
no test coverage detected