(
memoryNode: IReactFlowNode | undefined,
incomingInput: IncomingInput,
chatId: string,
isInternal: boolean
)
| 1821 | * @returns {string} |
| 1822 | */ |
| 1823 | export const getMemorySessionId = ( |
| 1824 | memoryNode: IReactFlowNode | undefined, |
| 1825 | incomingInput: IncomingInput, |
| 1826 | chatId: string, |
| 1827 | isInternal: boolean |
| 1828 | ): string => { |
| 1829 | if (!isInternal) { |
| 1830 | // Provided in API body - incomingInput.overrideConfig: { sessionId: 'abc' } |
| 1831 | if (incomingInput.overrideConfig?.sessionId) { |
| 1832 | if (typeof incomingInput.overrideConfig.sessionId !== 'string') { |
| 1833 | throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Invalid sessionId: must be a string') |
| 1834 | } |
| 1835 | return incomingInput.overrideConfig.sessionId |
| 1836 | } |
| 1837 | // Provided in API body - incomingInput.chatId |
| 1838 | if (incomingInput.chatId) { |
| 1839 | if (typeof incomingInput.chatId !== 'string') { |
| 1840 | throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Invalid chatId: must be a string') |
| 1841 | } |
| 1842 | return incomingInput.chatId |
| 1843 | } |
| 1844 | } |
| 1845 | |
| 1846 | // Hard-coded sessionId in UI |
| 1847 | if (memoryNode && memoryNode.data.inputs?.sessionId) { |
| 1848 | if (typeof memoryNode.data.inputs.sessionId !== 'string') { |
| 1849 | throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Invalid sessionId: must be a string') |
| 1850 | } |
| 1851 | return memoryNode.data.inputs.sessionId |
| 1852 | } |
| 1853 | |
| 1854 | // Default chatId |
| 1855 | return chatId |
| 1856 | } |
| 1857 | |
| 1858 | /** |
| 1859 | * Get chat messages from sessionId |
no outgoing calls
no test coverage detected