MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / getMemorySessionId

Function getMemorySessionId

packages/server/src/utils/index.ts:1823–1856  ·  view source on GitHub ↗
(
    memoryNode: IReactFlowNode | undefined,
    incomingInput: IncomingInput,
    chatId: string,
    isInternal: boolean
)

Source from the content-addressed store, hash-verified

1821 * @returns {string}
1822 */
1823export 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

Callers 3

executeUpsertFunction · 0.90
getChatHistoryFunction · 0.90
executeFlowFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected