How notmeher/memory-based-ai-chatbot-with-gpt works
Main Components
• User Interface: This is the Streamlit app (app.py) that acts as the front end where users can log in, ask questions, and view past conversations.
• AI Engine / Agent: The agent.py file likely implements the core logic for communicating with OpenAI’s API (gpt-4 or gpt-3.5-turbo), processing user queries, and formatting responses.
• Conversation Memory & Storage: ChromaDB is used for storing user messages, metadata (role, timestamp, conversation IDs), and managing persistent conversation histories.
• Authentication Module: The application handles user sign-up/login, where user passwords are securely hashed (using SHA-256) and verified during authentication.
Relationships and Interactions
• The UI layer (Streamlit front end) collects user input and displays chat history.
• The agent or backend component (agent.py) processes user requests, calls the OpenAI API for generating responses, and interacts with ChromaDB for storing and retrieving conversation data.
• The authentication process verifies user credentials (after hashing) before allowing access to the chat and conversation history.
• External Services: The OpenAI API serves as an external service to provide GPT model responses.
Architectural Patterns & Design Principles
• Layered Architecture: Separate the presentation layer (Streamlit app) from the business logic (agent module) and data access (ChromaDB interactions).
• Integration with External APIs: Clearly show the connection between the business logic and OpenAI’s API.
• Persistent Data Storage: Emphasize the role of ChromaDB to index and store conversations securely.
• Environment-based Configuration: Utilize .env for managing sensitive API keys and configuration variables.
Relevant Technologies & Frameworks
• Streamlit for building the web interface.
• Python as the core programming language.
• ChromaDB as the persistent storage solution.
• OpenAI API for processing input and generating responses.
• dotenv for environment variable management.
• Security (SHA-256 hashing for passwords) in the authentication process.
Elements
• Clear labels for each component (e.g., “Streamlit UI”, “Agent Module”, “Authentication Service”, “ChromaDB”, “OpenAI API”).
• Notations on important processes (like user authentication, conversation persistence, and API integrations).