Python Version | PyLint Score | Test Coverage |
---|---|---|
Python 3.8 | ||
Python 3.10 |
A psychological AI backend using Supabase for knowledge storage and retrieval.
By leveraging pgvector's capabilities, there was created a more psychologically-informed AI assistant that can identify recurring themes and potential areas of psychological distress.
Caption: A brain map illustrating how past events (eg. trauma, symbolized by a broken heart), strongly influences current behavior through highlighted neural pathways.
This innovation represents a significant step forward in therapeutic chatbots because:
-
Pattern Recognition: Rather than treating each user message in isolation, I'm using vector similarity to build a psychological profile over time
-
Depth-oriented Responses: The system now adapts its therapeutic approach based on detected pain points, similar to how a real therapist would follow threads of significance
-
User-centered Experience: By remembering and recognizing when users circle back to important topics, the conversation feels more coherent and thoughtful
-
Efficient Vector Processing: By performing most similarity operations directly in the database with pgvector, I maintain good performance while gaining rich psychological insights
-
Dynamic Topic Detection: Using natural language processing to identify psychological topics in user messages and retrieve relevant knowledge from my database
-
Token-Aware Text Generation: Implementing token-based prompt management to ensure optimal utilization of model context windows and prevent truncation issues
-
Template Optimization: Creating concise templates that maintain therapeutic quality while fitting within model constraints
-
Fallback Mechanisms: Implementing multi-level fallbacks to ensure reliable responses even when primary generation methods encounter issues
My technical infrastructure has been enhanced with:
-
Vector Search needs to be adjusted: Truncate each sentence into valuable pieces before indexing or querying. This improves retrieval accuracy and ensures the most relevant information is represented in the vector database.
-
Custom Logger Integration prismalog: Replaced standard logging with own colorful, more readable, fast prismalog system
-
Memory Optimization: Added GPU memory management to gracefully handle CUDA out-of-memory scenarios with automatic CPU fallback
-
Distributed Knowledge Management: Implemented a system that can dynamically query the knowledge base mid-conversation when specific psychological topics arise
-
Token-Based Prompt Management: Added intelligent token counting and optimization to ensure prompts never exceed model context limits
-
Smart Truncation: Implemented priority-based truncation that preserves system instructions and user questions while reducing less essential content
-
Token Monitoring: Added detailed logging of token counts to track model utilization and identify optimization opportunities
-
Add Full Customization Integrate full customization via separate program and logging configuration files to tailor user interactions and system behavior based on individual needs and preferences.
Planned Enhancements
-
Adjust policy: Work in Progress. CREATE POLICY "Users can access their own data" ON your_table FOR SELECT, INSERT, UPDATE, DELETE USING (user_id = auth.uid()); with singe schema instead of user=schema.
-
Integrate vector search in chatbot: The hipothese about "every thought is connected" was proven in one of the 'test_real_data' folder testing Script. Now there is need to integrate it to the Chat.
3*. Emotion Trajectory: Track a client’s emotional changes over time.
4*. AI Integration: Expand AI in the project with a 'knowledge database' to enhance response generation from user input on life, problems, and therapy expectations.
- ✅ Basic pain point detection architecture
- ✅ Vector similarity clustering
- ✅ Dynamic template selection
- ✅ Psychological topic extraction
- ✅ Memory-efficient processing
- ✅ Custom logging integration
- ✅ Add Full Customization
- ✅ Token-aware text generation
- ✅ Smart prompt truncation
- ✅ Enhanced Prompt Manager
- ✅ Token-efficient templates
- ✅ Migration on self-hosted Supabase
- ✅ Enhancing Vector Search by Segmenting Text into Meaningful Units
- 📅 Integrating implemented Vector Search by Segmenting Text in real chat-bot (planned)
- 📅 Integrating Emotional trajectory tracking (planned)
- 📅 AI Integration (planned)
By continuing to refine these capabilities, I'm building an AI therapeutic assistant that provides increasingly personalized, psychologically-informed support while maintaining operational efficiency. Looking forward to collaborate with interested people.
The code I have written for this project is licensed under the MIT License. See LICENSE for details.
Please refer to manual how to get required free supabase anon key and project url required by this program Supabase Setup Manual
*Beaware, these project uses libraries which may have their own respective licenses.
*Disclaimer: This AI tool is not a replacement for professional therapy and should not be used as a substitute for qualified mental health care.