Skip to main content
Glama

Notion MCP Server V2

by ankitmalik84
5-chatbot_agentic_v3.mdโ€ข4.08 kB
# ๐Ÿง  Agentic Chatbot v3 โ€” With Long-Term Semantic Memory This third version builds on the agentic design of v2, but adds a powerful new layer: **vector database integration** for semantic memory. With this, the chatbot becomes more context-aware, capable of retrieving relevant past conversations even if the wording is different. It simulates long-term memory, something that wasn't possible in the earlier versions. --- ## ๐Ÿ” Core Functionalities ### 1. ๐Ÿงฑ Initialization As before, the chatbot loads all the foundational components: - OpenAI client - Configurations - Session ID - SQL-based managers But now it adds: - **`VectorDBManager`** โ€” connects to a vector database (e.g., Chroma) for storing and retrieving embeddings of past conversations. It also updates the list of tools (functions the agent can call) to include: - `add_user_info_to_database` - `search_vector_db` (replacing `search_chat_history` from v2) --- ### 2. โš™๏ธ Function Execution The chatbot supports OpenAI function calling. Now, when the model asks to search memory, it can do so **semantically** using vector similarity rather than keyword matching. This leads to more relevant, nuanced, and context-aware behavior. --- ### 3. ๐Ÿ” Conversational Loop Same looping architecture as v2: - The chatbot keeps prompting the model until a final response is ready - It handles tool calls, updates chat history, and builds a dynamic system prompt using: - User info - Chat summary - Chat history - Function call results - And now: vector memory! The system prompt uses a new builder: `prepare_system_prompt_for_agentic_chatbot_v2` โ€” designed to support semantic memory and vector search results. --- ### 4. ๐Ÿง  Vector Memory Update After every conversation: ```python msg_pair = f"user: {user_message}, assistant: {assistant_response}" self.vector_db_manager.update_vector_db(msg_pair) ``` This message pair is embedded and stored in the vector database. That means the next time the user asks a related question, the chatbot can recall this past exchange even if it's phrased differently. --- ## ๐Ÿ”„ Key Differences from the Previous Versions | Feature | **V1: Basic Chatbot** | **V2: Agentic Chatbot** | **V3: Vector-Aware Agentic Chatbot (This)** | |--------|-----------------------|--------------------------|--------------------------------------------| | **Chat Flow** | Simple Q&A | Agent loop with function calls | Agent loop with memory + vector updates | | **Function Calling** | โŒ None | โœ… Basic agent functions | โœ… Includes vector DB search | | **Tools** | None | `add_user_info_to_database`, `search_chat_history` | `add_user_info_to_database`, `search_vector_db` | | **Search Capability** | โŒ None | โœ… Keyword/phrase-based search on SQL database (not semantic) | โœ… Semantic search using vector embeddings (stored in a vector database) | | **Prompt Strategy** | Simple prompt | Prompt with function call context | Prompt with function call context | **Fallback Strategy** | โŒ None | โœ… Includes a fallback mechanism| โœ… Includes a fallback mechanism| | **Memory System** | Chat history + summary | Chat history + summary + **SQL db search result** | Chat hirsoty + summary + **long-term memory (vector DB)** | | **System Prompt** | `prepare_system_prompt` | `prepare_system_prompt_for_agentic_chatbot_v1` | `...v2` with vector support context | | **Knowledge Retention** | Temporary, short-term | Contextually limited | **Semantically indexed for long-term reasoning** | --- ## ๐Ÿง  Final Thoughts This chatbot represents a **hybrid agent** โ€” blending dynamic tool use with smart, long-term memory. It: - Understands conversations across sessions - Grows more intelligent over time - Uses semantic reasoning to bring relevant context into its responses This is the blueprint for building **truly intelligent assistants** โ€” not just reactive models, but adaptive agents. --- ## ๐Ÿงพ Architecture Overview Here's the architecture of Agentic Chatbot v3: ![Agentic Chatbot v3 Schema](../images/agentic_chatbot_v3.png)

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ankitmalik84/Agentic_Longterm_Memory'

If you have feedback or need assistance with the MCP directory API, please join our Discord server