From bc8e23cae741f359dc959d6462b9127a53df5be2 Mon Sep 17 00:00:00 2001 From: Santhosh Janardhanan Date: Mon, 13 Apr 2026 13:19:56 -0400 Subject: [PATCH] chore: scaffold companion project with deps and config --- .gitignore | 11 ++++ companion/__init__.py | 0 config.json | 149 ++++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 27 ++++++++ 4 files changed, 187 insertions(+) create mode 100644 .gitignore create mode 100644 companion/__init__.py create mode 100644 config.json create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b59a711 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +__pycache__/ +*.py[cod] +*$py.class +*.egg-info/ +.pytest_cache/ +.mypy_cache/ +.venv/ +venv/ +.companion/ +dist/ +build/ diff --git a/companion/__init__.py b/companion/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config.json b/config.json new file mode 100644 index 0000000..9062ee0 --- /dev/null +++ b/config.json @@ -0,0 +1,149 @@ +{ + "companion": { + "name": "SAN", + "persona": { + "role": "companion", + "tone": "reflective", + "style": "questioning", + "boundaries": [ + "does_not_impersonate_user", + "no_future_predictions", + "no_medical_or_legal_advice" + ] + }, + "memory": { + "session_turns": 20, + "persistent_store": "~/.companion/memory.db", + "summarize_after": 10 + }, + "chat": { + "streaming": true, + "max_response_tokens": 2048, + "default_temperature": 0.7, + "allow_temperature_override": true + } + }, + "vault": { + "path": "./sample-data/Default", + "indexing": { + "auto_sync": true, + "auto_sync_interval_minutes": 1440, + "watch_fs_events": true, + "file_patterns": ["*.md"], + "deny_dirs": [".obsidian", ".trash", "zzz-Archive", ".git", ".logseq"], + "deny_patterns": ["*.tmp", "*.bak", "*conflict*", ".*"] + }, + "chunking_rules": { + "default": { + "strategy": "sliding_window", + "chunk_size": 500, + "chunk_overlap": 100 + }, + "Journal/**": { + "strategy": "section", + "section_tags": ["#DayInShort", "#mentalhealth", "#physicalhealth", "#work", "#finance", "#Relations"], + "chunk_size": 300, + "chunk_overlap": 50 + }, + "zzz-Archive/**": { + "strategy": "sliding_window", + "chunk_size": 800, + "chunk_overlap": 150 + } + } + }, + "rag": { + "embedding": { + "provider": "ollama", + "model": "mxbai-embed-large", + "base_url": "http://localhost:11434", + "dimensions": 1024, + "batch_size": 32 + }, + "vector_store": { + "type": "lancedb", + "path": "./.companion/vectors.lance" + }, + "search": { + "default_top_k": 8, + "max_top_k": 20, + "similarity_threshold": 0.75, + "hybrid_search": { + "enabled": true, + "keyword_weight": 0.3, + "semantic_weight": 0.7 + }, + "filters": { + "date_range_enabled": true, + "tag_filter_enabled": true, + "directory_filter_enabled": true + } + } + }, + "model": { + "inference": { + "backend": "llama.cpp", + "model_path": "~/.companion/models/companion-7b-q4.gguf", + "context_length": 8192, + "gpu_layers": 35, + "batch_size": 512, + "threads": 8 + }, + "fine_tuning": { + "base_model": "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit", + "output_dir": "~/.companion/training", + "lora_rank": 16, + "lora_alpha": 32, + "learning_rate": 0.0002, + "batch_size": 4, + "gradient_accumulation_steps": 4, + "num_epochs": 3, + "warmup_steps": 100, + "save_steps": 500, + "eval_steps": 250, + "training_data_path": "~/.companion/training_data/", + "validation_split": 0.1 + }, + "retrain_schedule": { + "auto_reminder": true, + "default_interval_days": 90, + "reminder_channels": ["chat_stream", "log"] + } + }, + "api": { + "host": "127.0.0.1", + "port": 7373, + "cors_origins": ["http://localhost:5173"], + "auth": { + "enabled": false + } + }, + "ui": { + "web": { + "enabled": true, + "theme": "obsidian", + "features": { + "streaming": true, + "citations": true, + "source_preview": true + } + }, + "cli": { + "enabled": true, + "rich_output": true + } + }, + "logging": { + "level": "INFO", + "file": "./.companion/logs/companion.log", + "max_size_mb": 100, + "backup_count": 5 + }, + "security": { + "local_only": true, + "vault_path_traversal_check": true, + "sensitive_content_detection": true, + "sensitive_patterns": ["#mentalhealth", "#physicalhealth", "#finance", "#Relations"], + "require_confirmation_for_external_apis": true + } +} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cf56b66 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,27 @@ +[project] +name = "companion" +version = "0.1.0" +description = "Personal companion AI with local RAG" +requires-python = ">=3.11" +dependencies = [ + "pydantic>=2.0", + "lancedb>=0.9.0", + "pyarrow>=15.0.0", + "requests>=2.31.0", + "watchdog>=4.0.0", + "typer>=0.12.0", + "rich>=13.0.0", + "numpy>=1.26.0", +] + +[project.optional-dependencies] +dev = [ + "pytest>=8.0.0", + "pytest-asyncio>=0.23.0", + "httpx>=0.27.0", + "respx>=0.21.0", +] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build"