Skip to content

Latest commit

Β 

History

7 Commits

Folders and files

Repository files navigation

🧠 MindSpace AI Agent

An intelligent mental wellness companion powered by AI

Built with Python Β· FastAPI Β· Streamlit Β· LangChain


MindSpace Chatbot Diagram


πŸ“– Overview

MindSpace is an AI-powered mental wellness assistant that combines the power of large language models, intelligent agent workflows, and real-time tools to create a supportive conversational experience. It understands user queries, responds naturally and empathetically, and can trigger helpful actions like emergency assistance or expert support routing.


✨ Features

Feature Description
πŸ’¬ Conversational AI Natural, empathetic mental health focused dialogue
πŸ€– AI Agent Workflow Tool-calling agent built with LangChain / LangGraph
⚑ FastAPI Backend High-performance async REST API
🎨 Streamlit Frontend Clean, calming chat interface
πŸ”§ Modular Tools Pluggable tool system for external services
🧠 Multi-LLM Support Works with OpenAI, Groq, and Ollama
πŸ“ Extensible Easy to add new tools, workflows, and integrations

πŸ“‚ Project Structure

MIND_SPACE_AI_AGENT/
β”‚
β”œβ”€β”€ back-end/
β”‚   β”œβ”€β”€ ai_agent.py          # Core AI agent logic & LLM interaction
β”‚   β”œβ”€β”€ config.py            # Configuration & environment variables
β”‚   β”œβ”€β”€ main.py              # FastAPI entry point & API routes
β”‚   └── tools.py             # Agent tools, helpers & service integrations
β”‚
β”œβ”€β”€ frontend.py              # Streamlit chat interface
β”œβ”€β”€ main.py                  # Application runner
β”œβ”€β”€ requirements.txt         # Project dependencies
β”œβ”€β”€ pyproject.toml           # Alternative dependency config
β”œβ”€β”€ .env                     # Environment variables (not committed)
β”œβ”€β”€ .gitignore
└── README.md

βš™οΈ Tech Stack

  • Runtime β€” Python 3.10+
  • Backend β€” FastAPI + Uvicorn
  • Frontend β€” Streamlit
  • AI / LLM β€” OpenAI, Groq, Ollama
  • Agent Framework β€” LangChain, LangGraph
  • HTTP Client β€” Requests, HTTPX
  • Config β€” python-dotenv

πŸš€ Getting Started

1️⃣ Clone the Repository

git clone <your-repository-url>
cd MIND_SPACE_AI_AGENT

2️⃣ Create a Virtual Environment

Windows

python -m venv .venv
.venv\Scripts\activate

Mac / Linux

python3 -m venv .venv
source .venv/bin/activate

3️⃣ Install Dependencies

pip install -r requirements.txt

Or if using pyproject.toml:

pip install .

4️⃣ Set Up Environment Variables

Create a .env file in the root directory:

# LLM Provider Keys (add whichever you use)
OPENAI_API_KEY=your_openai_key_here
GROQ_API_KEY=your_groq_key_here

# Optional: Ollama runs locally, no key needed
# OLLAMA_BASE_URL=http://localhost:11434

▢️ Running the Project

Start the FastAPI Backend

cd back-end
uvicorn main:app --reload

Backend will be available at: http://127.0.0.1:8000

API docs auto-generated at: http://127.0.0.1:8000/docs

Start the Streamlit Frontend

Open a new terminal and run:

streamlit run frontend.py

Frontend will open at: http://localhost:8501


🧠 How It Works

User (Streamlit UI)
       β”‚
       β–Ό
  FastAPI Backend  ──►  AI Agent (LangChain)
                              β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό         β–Ό         β–Ό
                  LLM      Tools    Workflows
            (GPT/Groq/  (Emergency/ (LangGraph
             Ollama)     Expert...)   chains)
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                       Final Response
                              β”‚
                       Back to User
  1. User types a message in the Streamlit chat interface
  2. Request is forwarded to the FastAPI backend via REST API
  3. The AI agent processes the query using the configured LLM
  4. If needed, the agent calls tools (emergency services, expert routing, etc.)
  5. The final response is returned and displayed in the chat

πŸ”§ Module Reference

ai_agent.py

  • Agent workflow orchestration
  • Prompt template management
  • LLM interaction & response parsing
  • Tool invocation logic

tools.py

  • External service integrations
  • Custom action implementations
  • Helper utilities
  • Emergency & support routing

config.py

  • API key management
  • Environment variable loading
  • Model configuration
  • App-wide settings

🌱 Roadmap

  • πŸŽ™οΈ Voice interaction support
  • πŸ‘¨β€βš•οΈ Therapist recommendation system
  • 🚨 Emergency calling integration
  • 🧠 Memory-enabled conversations
  • πŸ€– Multi-agent workflow
  • πŸ” User authentication system
  • πŸ“œ Persistent conversation history
  • πŸ“Š Mood tracking & analytics

πŸ“Έ UI Preview

Screenshots and demo GIFs coming soon.


🀝 Contributing

Contributions, ideas, and improvements are always welcome!

# 1. Fork the repository
# 2. Create your feature branch
git checkout -b feature/your-feature-name

# 3. Commit your changes
git commit -m "Add: your feature description"

# 4. Push and open a Pull Request
git push origin feature/your-feature-name

πŸ“œ License

This project is built for educational and development purposes.


πŸ‘¨β€πŸ’» Author

Paras Patel

Built with curiosity, late-night debugging, and lots of coffee β˜•


If this project helped you, consider giving it a ⭐ on GitHub!

About

🧠 MindSpace: AI-Powered Mental Wellness Agent built with FastAPI, LangChain, and Streamlit. An intelligent conversational AI agent featuring tool-calling workflows, multi-LLM support (OpenAI, Groq, Ollama), and real-time mental health assistance. Production-ready Python backend with async REST API and extensible agentic architecture.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages