Octopus Sensing SARA
An empathetic conversational AI companion with persistent memory, user profiling, and multi-LLM support. Part of the Octopus Sensing project ecosystem.
Built with FastAPI, LangChain, and React.
Features
- 🧠 Empathetic AI - Emotionally intelligent responses with advanced prompt engineering
- 💾 Persistent Memory - SQLite storage for conversations and user profiles
- 👤 User Profiling - Automatic extraction of preferences and personal information
- 🔌 Multi-LLM Support - OpenAI, Anthropic (Claude), Google Gemini, and Ollama
- 📝 Auto-Summarization - Long-term conversation summaries for context retention
- 🚀 Production-Ready - Docker deployment, type safety, async API
- 🎨 Modern UI - React frontend with shadcn/ui components
Quick Start
Prerequisites
- Docker and Docker Compose
- API key for your LLM provider (OpenAI, Anthropic, or Google)
Installation
-
Clone the repository
git clone https://github.com/octopus-sensing/octopus-sensing-sara.git cd octopus-sensing-sara
-
Configure environment
cp .env.example .env
-
Add your API key to
.env# Choose your provider LLM_PROVIDER=gemini LLM_MODEL=models/gemini-2.5-flash GOOGLE_API_KEY=your-api-key-here
-
Start the application
docker compose up --build
-
Access the application
- Frontend: http://localhost
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
Configuration
Configure SARA by editing the .env file:
| Variable | Description | Example |
|---|---|---|
LLM_PROVIDER |
AI provider | openai, anthropic, gemini, ollama |
LLM_MODEL |
Model name | models/gemini-2.5-flash, gpt-4, claude-3-opus |
LLM_TEMPERATURE |
Response creativity (0-2) | 0.7 |
LLM_MAX_TOKENS |
Max response length | 2000 |
SHORT_TERM_MEMORY_WINDOW |
Recent messages to remember | 10 |
LONG_TERM_MEMORY_SUMMARY_THRESHOLD |
Messages before summarization | 50 |
LLM Provider Setup
Google Gemini (Free Tier)
LLM_PROVIDER=gemini
LLM_MODEL=models/gemini-2.5-flash
GOOGLE_API_KEY=your-google-api-key
OpenAI
LLM_PROVIDER=openai
LLM_MODEL=gpt-4
OPENAI_API_KEY=sk-your-openai-key
Anthropic Claude
LLM_PROVIDER=anthropic
LLM_MODEL=claude-3-5-sonnet-20241022
ANTHROPIC_API_KEY=sk-ant-your-anthropic-key
API Reference
Send Message
curl -X POST http://localhost:8000/chat \
-H "Content-Type: application/json" \
-d '{
"user_id": "user123",
"message": "Hello, I need help with something."
}'
Get User Profile
curl http://localhost:8000/user/user123/profile
Get Conversation History
curl http://localhost:8000/conversation/{session_id}
Full API documentation: http://localhost:8000/docs
Architecture
┌─────────────────┐
│ React Frontend │
└────────┬────────┘
│
┌────────▼────────┐
│ FastAPI REST │
└────────┬────────┘
│
┌────────▼──────────────────────────┐
│ Conversation Service │
│ • Process messages │
│ • Extract user info │
│ • Manage memory & summarization │
└────────┬──────────────────────────┘
│
┌────────▼────────┬──────────┬──────────┐
│ Memory Service │ User │ LLM │
│ │ Service │ Factory │
└────────┬────────┴────┬─────┴────┬─────┘
│ │ │
┌────────▼─────────────▼──────────▼─────┐
│ SQLite Database (Persistent) │
│ • Conversations • Users • Messages │
└────────────────────────────────────────┘
Project Structure
octopus-sensing-sara/
├── server/
│ ├── octopus_sensing_sara/
│ │ ├── api/ # REST endpoints
│ │ ├── core/ # Config, LLM factory
│ │ ├── prompts/ # Modular prompt system
│ │ │ ├── system_prompt/
│ │ │ ├── summarization_prompt/
│ │ │ └── extraction_prompt/
│ │ ├── models/ # Database & schemas
│ │ ├── services/ # Business logic
│ │ ├── storage/ # Database layer
│ │ ├── main.py # FastAPI app
│ │ └── run.py # Entry point
│ ├── tests/
│ └── Dockerfile
│
├── octopus_sensing_sara_ui/
│ ├── src/
│ │ ├── components/ # UI components
│ │ └── pages/ # Page components
│ └── Dockerfile
│
├── docker-compose.yml
├── pyproject.toml # Poetry configuration & dependencies
└── poetry.lock
How It Works
1. Empathetic Conversations
SARA uses advanced prompt engineering to:
- Recognize emotional states from user messages
- Validate feelings before offering solutions
- Adapt tone based on user's emotional context
- Maintain warm, supportive communication
2. Memory System
Short-Term Memory
- Last 10 messages kept in memory
- Provides immediate conversation context
- Cached per session
Long-Term Memory
- All conversations stored in SQLite
- User profiles with extracted facts
- Automatic summarization after 50 messages
3. User Profiling
SARA automatically extracts and remembers:
- Name and personal details
- Preferences and interests
- Conversation history
- Emotional patterns
This data personalizes future interactions.
4. Modular Prompts
Prompts are organized by function:
system_prompt/- SARA's core personalitysummarization_prompt/- Conversation summariesextraction_prompt/- User information extraction
Each uses LangChain templates for consistency.
Docker Commands
Start application
docker compose up -d
View logs
docker compose logs -f backend
Restart after changes
docker compose restart backend
Stop application
docker compose down
Clean database (fresh start)
./clean.sh
Development
Local Setup (without Docker)
Backend
# Using Poetry (recommended)
poetry install
poetry run python -m octopus_sensing_sara.run
# OR using venv + pip
cd server
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -e .. # Install from pyproject.toml
python -m octopus_sensing_sara.run
Frontend
cd octopus_sensing_sara_ui
npm install
npm run dev
Adding a New LLM Provider
- Add API key field to
server/octopus_sensing_sara/core/config.py - Add provider logic to
server/octopus_sensing_sara/core/llm_factory.py - Update
docker-compose.ymlenvironment variables - Add to
.envfile
Tech Stack
FastAPI • LangChain • React • SQLite • Docker • Poetry
Metadata
Release files for octopus-sensing-sara 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| octopus_sensing_sara-1.0.tar.gz | 40.1 kB | Without provenance | Details for octopus_sensing_sara-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| octopus_sensing_sara-1.0-py3-none-any.whl | Python 3 | none | any | Details for octopus_sensing_sara-1.0-py3-none-any.whl |
Total release size: 93.4 kB
Release files / octopus_sensing_sara-1.0.tar.gz
| Download URL | octopus_sensing_sara-1.0.tar.gz |
|---|---|
| Size | 40.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b231cf3d51846b4aa8605e17a0d744b782ee22921cbfa21f5392938984075c9
|
|
BLAKE2b-256 checksum How to use checksums |
b749947a1da5ca7c0ffeea31a9cd6e3319265c128a31fe5fdf8683123a9d87b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-48-generic
|
Release files / octopus_sensing_sara-1.0-py3-none-any.whl
| Download URL | octopus_sensing_sara-1.0-py3-none-any.whl |
|---|---|
| Size | 53.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e6867858cf57c1fc19e88956052fc36931222c8f6f6b89ae09a709061b42cae
|
|
BLAKE2b-256 checksum How to use checksums |
c6f25d945aea84fdbb9d7c20e623c5d8361ea355277f5621295dbe2231810080
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-48-generic
|
Security for octopus-sensing-sara 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.