{
    "description": "Use long term memory like Zep to differentiate conversations between users with sessionId",
    "categories": "ChatOpenAI,Conversational Retrieval QA Chain,Zep Memory,Qdrant,Langchain",
    "framework": "Langchain",
    "nodes": [
        {
            "width": 300,
            "height": 480,
            "id": "conversationalRetrievalQAChain_0",
            "position": {
                "x": 2001.2622706097407,
                "y": 360.7347224947406
            },
            "type": "customNode",
            "data": {
                "id": "conversationalRetrievalQAChain_0",
                "label": "Conversational Retrieval QA Chain",
                "version": 3,
                "name": "conversationalRetrievalQAChain",
                "type": "ConversationalRetrievalQAChain",
                "baseClasses": ["ConversationalRetrievalQAChain", "BaseChain", "Runnable"],
                "category": "Chains",
                "description": "Document QA - built on RetrievalQAChain to provide a chat history component",
                "inputParams": [
                    {
                        "label": "Return Source Documents",
                        "name": "returnSourceDocuments",
                        "type": "boolean",
                        "optional": true,
                        "id": "conversationalRetrievalQAChain_0-input-returnSourceDocuments-boolean"
                    },
                    {
                        "label": "Rephrase Prompt",
                        "name": "rephrasePrompt",
                        "type": "string",
                        "description": "Using previous chat history, rephrase question into a standalone question",
                        "warning": "Prompt must include input variables: {chat_history} and {question}",
                        "rows": 4,
                        "additionalParams": true,
                        "optional": true,
                        "default": "Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.\n\nChat History:\n{chat_history}\nFollow Up Input: {question}\nStandalone Question:",
                        "id": "conversationalRetrievalQAChain_0-input-rephrasePrompt-string"
                    },
                    {
                        "label": "Response Prompt",
                        "name": "responsePrompt",
                        "type": "string",
                        "description": "Taking the rephrased question, search for answer from the provided context",
                        "warning": "Prompt must include input variable: {context}",
                        "rows": 4,
                        "additionalParams": true,
                        "optional": true,
                        "default": "You are a helpful assistant. Using the provided context, answer the user's question to the best of your ability using the resources provided.\nIf there is nothing in the context relevant to the question at hand, just say \"Hmm, I'm not sure.\" Don't try to make up an answer.\n------------\n{context}\n------------\nREMEMBER: If there is no relevant information within the context, just say \"Hmm, I'm not sure.\" Don't try to make up an answer.",
                        "id": "conversationalRetrievalQAChain_0-input-responsePrompt-string"
                    }
                ],
                "inputAnchors": [
                    {
                        "label": "Chat Model",
                        "name": "model",
                        "type": "BaseChatModel",
                        "id": "conversationalRetrievalQAChain_0-input-model-BaseChatModel"
                    },
                    {
                        "label": "Vector Store Retriever",
                        "name": "vectorStoreRetriever",
                        "type": "BaseRetriever",
                        "id": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever"
                    },
                    {
                        "label": "Memory",
                        "name": "memory",
                        "type": "BaseMemory",
                        "optional": true,
                        "description": "If left empty, a default BufferMemory will be used",
                        "id": "conversationalRetrievalQAChain_0-input-memory-BaseMemory"
                    },
                    {
                        "label": "Input Moderation",
                        "description": "Detect text that could generate harmful output and prevent it from being sent to the language model",
                        "name": "inputModeration",
                        "type": "Moderation",
                        "optional": true,
                        "list": true,
                        "id": "conversationalRetrievalQAChain_0-input-inputModeration-Moderation"
                    }
                ],
                "inputs": {
                    "inputModeration": "",
                    "model": "{{chatOpenAI_0.data.instance}}",
                    "vectorStoreRetriever": "{{qdrant_0.data.instance}}",
                    "memory": "{{ZepMemory_0.data.instance}}",
                    "returnSourceDocuments": true,
                    "rephrasePrompt": "Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.\n\nChat History:\n{chat_history}\nFollow Up Input: {question}\nStandalone Question:",
                    "responsePrompt": "You are a helpful assistant. Using the provided context, answer the user's question to the best of your ability using the resources provided.\nIf there is nothing in the context relevant to the question at hand, just say \"Hmm, I'm not sure.\" Don't try to make up an answer.\n------------\n{context}\n------------\nREMEMBER: If there is no relevant information within the context, just say \"Hmm, I'm not sure.\" Don't try to make up an answer."
                },
                "outputAnchors": [
                    {
                        "id": "conversationalRetrievalQAChain_0-output-conversationalRetrievalQAChain-ConversationalRetrievalQAChain|BaseChain|Runnable",
                        "name": "conversationalRetrievalQAChain",
                        "label": "ConversationalRetrievalQAChain",
                        "type": "ConversationalRetrievalQAChain | BaseChain | Runnable"
                    }
                ],
                "outputs": {},
                "selected": false
            },
            "selected": false,
            "positionAbsolute": {
                "x": 2001.2622706097407,
                "y": 360.7347224947406
            },
            "dragging": false
        },
        {
            "width": 300,
            "height": 329,
            "id": "openAIEmbeddings_0",
            "position": {
                "x": 789.6839176356616,
                "y": 167.70165941305987
            },
            "type": "customNode",
            "data": {
                "id": "openAIEmbeddings_0",
                "label": "OpenAI Embeddings",
                "version": 3,
                "name": "openAIEmbeddings",
                "type": "OpenAIEmbeddings",
                "baseClasses": ["OpenAIEmbeddings", "Embeddings"],
                "category": "Embeddings",
                "description": "OpenAI API to generate embeddings for a given text",
                "inputParams": [
                    {
                        "label": "Connect Credential",
                        "name": "credential",
                        "type": "credential",
                        "credentialNames": ["openAIApi"],
                        "id": "openAIEmbeddings_0-input-credential-credential"
                    },
                    {
                        "label": "Model Name",
                        "name": "modelName",
                        "type": "asyncOptions",
                        "loadMethod": "listModels",
                        "default": "text-embedding-ada-002",
                        "id": "openAIEmbeddings_0-input-modelName-options"
                    },
                    {
                        "label": "Strip New Lines",
                        "name": "stripNewLines",
                        "type": "boolean",
                        "optional": true,
                        "additionalParams": true,
                        "id": "openAIEmbeddings_0-input-stripNewLines-boolean"
                    },
                    {
                        "label": "Batch Size",
                        "name": "batchSize",
                        "type": "number",
                        "optional": true,
                        "additionalParams": true,
                        "id": "openAIEmbeddings_0-input-batchSize-number"
                    },
                    {
                        "label": "Timeout",
                        "name": "timeout",
                        "type": "number",
                        "optional": true,
                        "additionalParams": true,
                        "id": "openAIEmbeddings_0-input-timeout-number"
                    },
                    {
                        "label": "BasePath",
                        "name": "basepath",
                        "type": "string",
                        "optional": true,
                        "additionalParams": true,
                        "id": "openAIEmbeddings_0-input-basepath-string"
                    }
                ],
                "inputAnchors": [],
                "inputs": {
                    "stripNewLines": "",
                    "batchSize": "",
                    "timeout": "",
                    "basepath": "",
                    "modelName": "text-embedding-ada-002"
                },
                "outputAnchors": [
                    {
                        "id": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings",
                        "name": "openAIEmbeddings",
                        "label": "OpenAIEmbeddings",
                        "type": "OpenAIEmbeddings | Embeddings"
                    }
                ],
                "outputs": {},
                "selected": false
            },
            "selected": false,
            "positionAbsolute": {
                "x": 789.6839176356616,
                "y": 167.70165941305987
            },
            "dragging": false
        },
        {
            "width": 300,
            "height": 623,
            "id": "ZepMemory_0",
            "position": {
                "x": 420.8032935700942,
                "y": 92.41976641951993
            },
            "type": "customNode",
            "data": {
                "id": "ZepMemory_0",
                "label": "Zep Memory",
                "version": 2,
                "name": "ZepMemory",
                "type": "ZepMemory",
                "baseClasses": ["ZepMemory", "BaseChatMemory", "BaseMemory"],
                "category": "Memory",
                "description": "Summarizes the conversation and stores the memory in zep server",
                "inputParams": [
                    {
                        "label": "Connect Credential",
                        "name": "credential",
                        "type": "credential",
                        "optional": true,
                        "description": "Configure JWT authentication on your Zep instance (Optional)",
                        "credentialNames": ["zepMemoryApi"],
                        "id": "ZepMemory_0-input-credential-credential"
                    },
                    {
                        "label": "Base URL",
                        "name": "baseURL",
                        "type": "string",
                        "default": "http://127.0.0.1:8000",
                        "id": "ZepMemory_0-input-baseURL-string"
                    },
                    {
                        "label": "Session Id",
                        "name": "sessionId",
                        "type": "string",
                        "description": "If not specified, a random id will be used. Learn <a target=\"_blank\" href=\"https://docs.flowiseai.com/memory/long-term-memory#ui-and-embedded-chat\">more</a>",
                        "default": "",
                        "additionalParams": true,
                        "optional": true,
                        "id": "ZepMemory_0-input-sessionId-string"
                    },
                    {
                        "label": "Size",
                        "name": "k",
                        "type": "number",
                        "default": "10",
                        "step": 1,
                        "additionalParams": true,
                        "description": "Window of size k to surface the last k back-and-forths to use as memory.",
                        "id": "ZepMemory_0-input-k-number"
                    },
                    {
                        "label": "AI Prefix",
                        "name": "aiPrefix",
                        "type": "string",
                        "default": "ai",
                        "additionalParams": true,
                        "id": "ZepMemory_0-input-aiPrefix-string"
                    },
                    {
                        "label": "Human Prefix",
                        "name": "humanPrefix",
                        "type": "string",
                        "default": "human",
                        "additionalParams": true,
                        "id": "ZepMemory_0-input-humanPrefix-string"
                    },
                    {
                        "label": "Memory Key",
                        "name": "memoryKey",
                        "type": "string",
                        "default": "chat_history",
                        "additionalParams": true,
                        "id": "ZepMemory_0-input-memoryKey-string"
                    },
                    {
                        "label": "Input Key",
                        "name": "inputKey",
                        "type": "string",
                        "default": "input",
                        "additionalParams": true,
                        "id": "ZepMemory_0-input-inputKey-string"
                    },
                    {
                        "label": "Output Key",
                        "name": "outputKey",
                        "type": "string",
                        "default": "text",
                        "additionalParams": true,
                        "id": "ZepMemory_0-input-outputKey-string"
                    }
                ],
                "inputAnchors": [],
                "inputs": {
                    "baseURL": "http://127.0.0.1:8000",
                    "sessionId": "",
                    "k": "10",
                    "aiPrefix": "ai",
                    "humanPrefix": "human",
                    "memoryKey": "chat_history",
                    "inputKey": "input",
                    "outputKey": "text"
                },
                "outputAnchors": [
                    {
                        "id": "ZepMemory_0-output-ZepMemory-ZepMemory|BaseChatMemory|BaseMemory",
                        "name": "ZepMemory",
                        "label": "ZepMemory",
                        "type": "ZepMemory | BaseChatMemory | BaseMemory"
                    }
                ],
                "outputs": {},
                "selected": false
            },
            "selected": false,
            "positionAbsolute": {
                "x": 420.8032935700942,
                "y": 92.41976641951993
            },
            "dragging": false
        },
        {
            "width": 300,
            "height": 654,
            "id": "qdrant_0",
            "position": {
                "x": 1186.2560075381377,
                "y": -86.38901299105441
            },
            "type": "customNode",
            "data": {
                "id": "qdrant_0",
                "label": "Qdrant",
                "version": 1,
                "name": "qdrant",
                "type": "Qdrant",
                "baseClasses": ["Qdrant", "VectorStoreRetriever", "BaseRetriever"],
                "category": "Vector Stores",
                "description": "Upsert embedded data and perform similarity search upon query using Qdrant, a scalable open source vector database written in Rust",
                "inputParams": [
                    {
                        "label": "Connect Credential",
                        "name": "credential",
                        "type": "credential",
                        "description": "Only needed when using Qdrant cloud hosted",
                        "optional": true,
                        "credentialNames": ["qdrantApi"],
                        "id": "qdrant_0-input-credential-credential"
                    },
                    {
                        "label": "Qdrant Server URL",
                        "name": "qdrantServerUrl",
                        "type": "string",
                        "placeholder": "http://localhost:6333",
                        "id": "qdrant_0-input-qdrantServerUrl-string"
                    },
                    {
                        "label": "Qdrant Collection Name",
                        "name": "qdrantCollection",
                        "type": "string",
                        "id": "qdrant_0-input-qdrantCollection-string"
                    },
                    {
                        "label": "Vector Dimension",
                        "name": "qdrantVectorDimension",
                        "type": "number",
                        "default": 1536,
                        "additionalParams": true,
                        "id": "qdrant_0-input-qdrantVectorDimension-number"
                    },
                    {
                        "label": "Similarity",
                        "name": "qdrantSimilarity",
                        "description": "Similarity measure used in Qdrant.",
                        "type": "options",
                        "default": "Cosine",
                        "options": [
                            {
                                "label": "Cosine",
                                "name": "Cosine"
                            },
                            {
                                "label": "Euclid",
                                "name": "Euclid"
                            },
                            {
                                "label": "Dot",
                                "name": "Dot"
                            }
                        ],
                        "additionalParams": true,
                        "id": "qdrant_0-input-qdrantSimilarity-options"
                    },
                    {
                        "label": "Additional Collection Cofiguration",
                        "name": "qdrantCollectionConfiguration",
                        "description": "Refer to <a target=\"_blank\" href=\"https://qdrant.tech/documentation/concepts/collections\">collection docs</a> for more reference",
                        "type": "json",
                        "optional": true,
                        "additionalParams": true,
                        "id": "qdrant_0-input-qdrantCollectionConfiguration-json"
                    },
                    {
                        "label": "Top K",
                        "name": "topK",
                        "description": "Number of top results to fetch. Default to 4",
                        "placeholder": "4",
                        "type": "number",
                        "additionalParams": true,
                        "optional": true,
                        "id": "qdrant_0-input-topK-number"
                    },
                    {
                        "label": "Qdrant Search Filter",
                        "name": "qdrantFilter",
                        "description": "Only return points which satisfy the conditions",
                        "type": "json",
                        "additionalParams": true,
                        "optional": true,
                        "id": "qdrant_0-input-qdrantFilter-json"
                    }
                ],
                "inputAnchors": [
                    {
                        "label": "Document",
                        "name": "document",
                        "type": "Document",
                        "list": true,
                        "optional": true,
                        "id": "qdrant_0-input-document-Document"
                    },
                    {
                        "label": "Embeddings",
                        "name": "embeddings",
                        "type": "Embeddings",
                        "id": "qdrant_0-input-embeddings-Embeddings"
                    }
                ],
                "inputs": {
                    "document": "",
                    "embeddings": "{{openAIEmbeddings_0.data.instance}}",
                    "qdrantServerUrl": "",
                    "qdrantCollection": "",
                    "qdrantVectorDimension": 1536,
                    "qdrantSimilarity": "Cosine",
                    "qdrantCollectionConfiguration": "",
                    "topK": "",
                    "qdrantFilter": ""
                },
                "outputAnchors": [
                    {
                        "name": "output",
                        "label": "Output",
                        "type": "options",
                        "options": [
                            {
                                "id": "qdrant_0-output-retriever-Qdrant|VectorStoreRetriever|BaseRetriever",
                                "name": "retriever",
                                "label": "Qdrant Retriever",
                                "type": "Qdrant | VectorStoreRetriever | BaseRetriever"
                            },
                            {
                                "id": "qdrant_0-output-vectorStore-Qdrant|VectorStore",
                                "name": "vectorStore",
                                "label": "Qdrant Vector Store",
                                "type": "Qdrant | VectorStore"
                            }
                        ],
                        "default": "retriever"
                    }
                ],
                "outputs": {
                    "output": "retriever"
                },
                "selected": false
            },
            "selected": false,
            "positionAbsolute": {
                "x": 1186.2560075381377,
                "y": -86.38901299105441
            },
            "dragging": false
        },
        {
            "width": 300,
            "height": 574,
            "id": "chatOpenAI_0",
            "position": {
                "x": 1561.0993169664887,
                "y": -75.4103386563329
            },
            "type": "customNode",
            "data": {
                "id": "chatOpenAI_0",
                "label": "ChatOpenAI",
                "version": 6.0,
                "name": "chatOpenAI",
                "type": "ChatOpenAI",
                "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"],
                "category": "Chat Models",
                "description": "Wrapper around OpenAI large language models that use the Chat endpoint",
                "inputParams": [
                    {
                        "label": "Connect Credential",
                        "name": "credential",
                        "type": "credential",
                        "credentialNames": ["openAIApi"],
                        "id": "chatOpenAI_0-input-credential-credential"
                    },
                    {
                        "label": "Model Name",
                        "name": "modelName",
                        "type": "asyncOptions",
                        "loadMethod": "listModels",
                        "default": "gpt-3.5-turbo",
                        "id": "chatOpenAI_0-input-modelName-options"
                    },
                    {
                        "label": "Temperature",
                        "name": "temperature",
                        "type": "number",
                        "step": 0.1,
                        "default": 0.9,
                        "optional": true,
                        "id": "chatOpenAI_0-input-temperature-number"
                    },
                    {
                        "label": "Max Tokens",
                        "name": "maxTokens",
                        "type": "number",
                        "step": 1,
                        "optional": true,
                        "additionalParams": true,
                        "id": "chatOpenAI_0-input-maxTokens-number"
                    },
                    {
                        "label": "Top Probability",
                        "name": "topP",
                        "type": "number",
                        "step": 0.1,
                        "optional": true,
                        "additionalParams": true,
                        "id": "chatOpenAI_0-input-topP-number"
                    },
                    {
                        "label": "Frequency Penalty",
                        "name": "frequencyPenalty",
                        "type": "number",
                        "step": 0.1,
                        "optional": true,
                        "additionalParams": true,
                        "id": "chatOpenAI_0-input-frequencyPenalty-number"
                    },
                    {
                        "label": "Presence Penalty",
                        "name": "presencePenalty",
                        "type": "number",
                        "step": 0.1,
                        "optional": true,
                        "additionalParams": true,
                        "id": "chatOpenAI_0-input-presencePenalty-number"
                    },
                    {
                        "label": "Timeout",
                        "name": "timeout",
                        "type": "number",
                        "step": 1,
                        "optional": true,
                        "additionalParams": true,
                        "id": "chatOpenAI_0-input-timeout-number"
                    },
                    {
                        "label": "BasePath",
                        "name": "basepath",
                        "type": "string",
                        "optional": true,
                        "additionalParams": true,
                        "id": "chatOpenAI_0-input-basepath-string"
                    },
                    {
                        "label": "BaseOptions",
                        "name": "baseOptions",
                        "type": "json",
                        "optional": true,
                        "additionalParams": true,
                        "id": "chatOpenAI_0-input-baseOptions-json"
                    },
                    {
                        "label": "Allow Image Uploads",
                        "name": "allowImageUploads",
                        "type": "boolean",
                        "description": "Automatically uses gpt-4-vision-preview when image is being uploaded from chat. Only works with LLMChain, Conversation Chain, ReAct Agent, and Conversational Agent",
                        "default": false,
                        "optional": true,
                        "id": "chatOpenAI_0-input-allowImageUploads-boolean"
                    },
                    {
                        "label": "Image Resolution",
                        "description": "This parameter controls the resolution in which the model views the image.",
                        "name": "imageResolution",
                        "type": "options",
                        "options": [
                            {
                                "label": "Low",
                                "name": "low"
                            },
                            {
                                "label": "High",
                                "name": "high"
                            },
                            {
                                "label": "Auto",
                                "name": "auto"
                            }
                        ],
                        "default": "low",
                        "optional": false,
                        "additionalParams": true,
                        "id": "chatOpenAI_0-input-imageResolution-options"
                    }
                ],
                "inputAnchors": [
                    {
                        "label": "Cache",
                        "name": "cache",
                        "type": "BaseCache",
                        "optional": true,
                        "id": "chatOpenAI_0-input-cache-BaseCache"
                    }
                ],
                "inputs": {
                    "cache": "",
                    "modelName": "gpt-3.5-turbo-16k",
                    "temperature": 0.9,
                    "maxTokens": "",
                    "topP": "",
                    "frequencyPenalty": "",
                    "presencePenalty": "",
                    "timeout": "",
                    "basepath": "",
                    "baseOptions": "",
                    "allowImageUploads": true,
                    "imageResolution": "low"
                },
                "outputAnchors": [
                    {
                        "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable",
                        "name": "chatOpenAI",
                        "label": "ChatOpenAI",
                        "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable"
                    }
                ],
                "outputs": {},
                "selected": false
            },
            "selected": false,
            "positionAbsolute": {
                "x": 1561.0993169664887,
                "y": -75.4103386563329
            },
            "dragging": false
        }
    ],
    "edges": [
        {
            "source": "ZepMemory_0",
            "sourceHandle": "ZepMemory_0-output-ZepMemory-ZepMemory|BaseChatMemory|BaseMemory",
            "target": "conversationalRetrievalQAChain_0",
            "targetHandle": "conversationalRetrievalQAChain_0-input-memory-BaseMemory",
            "type": "buttonedge",
            "id": "ZepMemory_0-ZepMemory_0-output-ZepMemory-ZepMemory|BaseChatMemory|BaseMemory-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-memory-BaseMemory",
            "data": {
                "label": ""
            }
        },
        {
            "source": "openAIEmbeddings_0",
            "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings",
            "target": "qdrant_0",
            "targetHandle": "qdrant_0-input-embeddings-Embeddings",
            "type": "buttonedge",
            "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-qdrant_0-qdrant_0-input-embeddings-Embeddings",
            "data": {
                "label": ""
            }
        },
        {
            "source": "qdrant_0",
            "sourceHandle": "qdrant_0-output-retriever-Qdrant|VectorStoreRetriever|BaseRetriever",
            "target": "conversationalRetrievalQAChain_0",
            "targetHandle": "conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever",
            "type": "buttonedge",
            "id": "qdrant_0-qdrant_0-output-retriever-Qdrant|VectorStoreRetriever|BaseRetriever-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-vectorStoreRetriever-BaseRetriever",
            "data": {
                "label": ""
            }
        },
        {
            "source": "chatOpenAI_0",
            "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable",
            "target": "conversationalRetrievalQAChain_0",
            "targetHandle": "conversationalRetrievalQAChain_0-input-model-BaseChatModel",
            "type": "buttonedge",
            "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-conversationalRetrievalQAChain_0-conversationalRetrievalQAChain_0-input-model-BaseChatModel",
            "data": {
                "label": ""
            }
        }
    ]
}
