Skip to content

Commit cf3b62f

Browse files
committed
Merge remote-tracking branch 'chronicle/fix/cleanup-model' into fix/cleanup-model
2 parents 9fc4572 + 686f357 commit cf3b62f

29 files changed

+2152
-1734
lines changed

.github/workflows/advanced-docker-compose-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ jobs:
199199
cd ../../extras/asr-services
200200
for cuda_variant in cu121 cu126 cu128; do
201201
echo "Building parakeet-asr-${cuda_variant}"
202-
export CUDA_VERSION="${cuda_variant}"
202+
export PYTORCH_CUDA_VERSION="${cuda_variant}"
203203
docker compose build parakeet-asr
204204
205205
img_id=$(docker compose images -q parakeet-asr | head -n1)

.github/workflows/robot-tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ jobs:
6363
python-version: "3.12"
6464
cache: 'pip'
6565

66+
- name: Install uv
67+
uses: astral-sh/setup-uv@v4
68+
with:
69+
version: "latest"
70+
6671
- name: Install Robot Framework and dependencies
6772
run: |
68-
pip install --upgrade pip
69-
pip install robotframework robotframework-requests python-dotenv websockets
73+
uv pip install --system robotframework robotframework-requests python-dotenv websockets
7074
7175
- name: Create test environment file
7276
working-directory: tests/setup

Docs/init-system.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,33 @@ uv run --with-requirements setup-requirements.txt python services.py start backe
148148
# Check service status
149149
uv run --with-requirements setup-requirements.txt python services.py status
150150

151+
# Restart all services
152+
uv run --with-requirements setup-requirements.txt python services.py restart --all
153+
154+
# Restart specific services
155+
uv run --with-requirements setup-requirements.txt python services.py restart backend
156+
151157
# Stop all services
152158
uv run --with-requirements setup-requirements.txt python services.py stop --all
153159

154-
# Stop specific services
160+
# Stop specific services
155161
uv run --with-requirements setup-requirements.txt python services.py stop asr-services openmemory-mcp
156162
```
157163

164+
**Convenience Scripts:**
165+
```bash
166+
# Quick start (from project root)
167+
./start.sh
168+
169+
# Quick restart (from project root)
170+
./restart.sh
171+
```
172+
173+
**Important Notes:**
174+
- **Restart** restarts containers without rebuilding - use for configuration changes (.env updates)
175+
- **For code changes**, use `stop` + `start --build` to rebuild images
176+
- Example: `uv run --with-requirements setup-requirements.txt python services.py stop --all && uv run --with-requirements setup-requirements.txt python services.py start --all --build`
177+
158178
### Manual Service Management
159179
You can also manage services individually:
160180

Docs/ports-and-access.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,24 @@ uv run --with-requirements setup-requirements.txt python services.py start --all
101101
# Start only specific services
102102
uv run --with-requirements setup-requirements.txt python services.py start backend speaker-recognition
103103

104+
# Restart all services
105+
uv run --with-requirements setup-requirements.txt python services.py restart --all
106+
107+
# Restart specific services
108+
uv run --with-requirements setup-requirements.txt python services.py restart backend
109+
104110
# Stop all services
105111
uv run --with-requirements setup-requirements.txt python services.py stop --all
106112
```
107113

114+
**Convenience Scripts:**
115+
```bash
116+
./start.sh # Quick start all configured services
117+
./restart.sh # Quick restart all configured services
118+
```
119+
120+
**Important:** Use `restart` for configuration changes (.env updates). For code changes, use `stop` + `start --build` to rebuild images.
121+
108122
---
109123

110124
## Microphone Access Requirements
@@ -128,7 +142,7 @@ If you encounter port conflicts:
128142
1. **Check running services**: `uv run --with-requirements setup-requirements.txt python services.py status`
129143
2. **Stop conflicting services**: `uv run --with-requirements setup-requirements.txt python services.py stop --all`
130144
3. **Change ports in .env files** if needed
131-
4. **Restart services**: `uv run --with-requirements setup-requirements.txt python services.py start --all`
145+
4. **Restart services**: `uv run --with-requirements setup-requirements.txt python services.py restart --all` or `./restart.sh`
132146

133147
---
134148

backends/advanced/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ services:
1919
- MISTRAL_MODEL=${MISTRAL_MODEL}
2020
- TRANSCRIPTION_PROVIDER=${TRANSCRIPTION_PROVIDER}
2121
- PARAKEET_ASR_URL=${PARAKEET_ASR_URL}
22-
- OFFLINE_ASR_TCP_URI=${OFFLINE_ASR_TCP_URI}
22+
- OLLAMA_BASE_URL=${OLLAMA_BASE_URL}
2323
- HF_TOKEN=${HF_TOKEN}
2424
- SPEAKER_SERVICE_URL=${SPEAKER_SERVICE_URL}
2525
- ADMIN_PASSWORD=${ADMIN_PASSWORD}

backends/advanced/init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def setup_transcription(self):
191191
self.console.print("[yellow][WARNING][/yellow] No API key provided - transcription will not work")
192192

193193
elif choice == "3":
194-
self.config["TRANSCRIPTION_PROVIDER"] = "offline"
194+
self.config["TRANSCRIPTION_PROVIDER"] = "parakeet"
195195
self.console.print("[blue][INFO][/blue] Offline Parakeet ASR selected")
196196
parakeet_url = self.prompt_value("Parakeet ASR URL", "http://host.docker.internal:8767")
197197
self.config["PARAKEET_ASR_URL"] = parakeet_url

backends/advanced/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ dependencies = [
2525
"redis>=5.0.0",
2626
"rq>=1.16.0",
2727
"soundfile>=0.12.1",
28+
"google-api-python-client>=2.0.0",
29+
"google-auth-oauthlib>=1.0.0",
30+
"google-auth-httplib2>=0.2.0",
2831
"websockets>=12.0",
2932
]
3033

backends/advanced/run-test.sh

Lines changed: 72 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,74 @@ print_info "Advanced Backend Integration Test Runner"
3939
print_info "========================================"
4040

4141
# Load environment variables (CI or local)
42-
if [ -f ".env" ] && [ -z "$DEEPGRAM_API_KEY" ]; then
42+
# Priority: CI environment > .env.test > .env
43+
if [ -n "$DEEPGRAM_API_KEY" ]; then
44+
print_info "Using environment variables from CI/environment..."
45+
elif [ -f ".env.test" ]; then
46+
print_info "Loading environment variables from .env.test..."
47+
set -a
48+
source .env.test
49+
set +a
50+
elif [ -f ".env" ]; then
4351
print_info "Loading environment variables from .env..."
4452
set -a
4553
source .env
4654
set +a
47-
elif [ -n "$DEEPGRAM_API_KEY" ]; then
48-
print_info "Using environment variables from CI..."
4955
else
50-
print_error "Neither .env file nor CI environment variables found!"
51-
print_info "For local development: cp .env.template .env and configure API keys"
52-
print_info "For CI: ensure DEEPGRAM_API_KEY and OPENAI_API_KEY secrets are set"
56+
print_error "Neither .env.test nor .env file found, and no environment variables set!"
57+
print_info "For local development: cp .env.template .env and configure required API keys"
58+
print_info "For CI: ensure required API keys are set based on configured providers"
5359
exit 1
5460
fi
5561

56-
# Verify required environment variables
57-
if [ -z "$DEEPGRAM_API_KEY" ]; then
58-
print_error "DEEPGRAM_API_KEY not set"
59-
exit 1
60-
fi
61-
62-
if [ -z "$OPENAI_API_KEY" ]; then
63-
print_error "OPENAI_API_KEY not set"
64-
exit 1
65-
fi
66-
67-
print_info "DEEPGRAM_API_KEY length: ${#DEEPGRAM_API_KEY}"
68-
print_info "OPENAI_API_KEY length: ${#OPENAI_API_KEY}"
62+
# Verify required environment variables based on configured providers
63+
TRANSCRIPTION_PROVIDER=${TRANSCRIPTION_PROVIDER:-deepgram}
64+
LLM_PROVIDER=${LLM_PROVIDER:-openai}
65+
66+
print_info "Configured providers:"
67+
print_info " TRANSCRIPTION_PROVIDER: $TRANSCRIPTION_PROVIDER"
68+
print_info " LLM_PROVIDER: $LLM_PROVIDER"
69+
70+
# Check transcription provider API key
71+
case "$TRANSCRIPTION_PROVIDER" in
72+
deepgram)
73+
if [ -z "$DEEPGRAM_API_KEY" ]; then
74+
print_error "DEEPGRAM_API_KEY not set (required for TRANSCRIPTION_PROVIDER=deepgram)"
75+
exit 1
76+
fi
77+
print_info "DEEPGRAM_API_KEY length: ${#DEEPGRAM_API_KEY}"
78+
;;
79+
mistral)
80+
if [ -z "$MISTRAL_API_KEY" ]; then
81+
print_error "MISTRAL_API_KEY not set (required for TRANSCRIPTION_PROVIDER=mistral)"
82+
exit 1
83+
fi
84+
print_info "MISTRAL_API_KEY length: ${#MISTRAL_API_KEY}"
85+
;;
86+
offline|parakeet)
87+
print_info "Using offline/local transcription - no API key required"
88+
;;
89+
*)
90+
print_warning "Unknown TRANSCRIPTION_PROVIDER: $TRANSCRIPTION_PROVIDER"
91+
;;
92+
esac
93+
94+
# Check LLM provider API key (for memory extraction)
95+
case "$LLM_PROVIDER" in
96+
openai)
97+
if [ -z "$OPENAI_API_KEY" ]; then
98+
print_error "OPENAI_API_KEY not set (required for LLM_PROVIDER=openai)"
99+
exit 1
100+
fi
101+
print_info "OPENAI_API_KEY length: ${#OPENAI_API_KEY}"
102+
;;
103+
ollama)
104+
print_info "Using Ollama for LLM - no API key required"
105+
;;
106+
*)
107+
print_warning "Unknown LLM_PROVIDER: $LLM_PROVIDER"
108+
;;
109+
esac
69110

70111
# memory_config.yaml deprecated; using config.yml for memory settings
71112

@@ -114,9 +155,19 @@ export DOCKER_BUILDKIT=0
114155

115156
# Run the integration test with extended timeout (mem0 needs time for comprehensive extraction)
116157
print_info "Starting integration test (timeout: 15 minutes)..."
117-
timeout 900 uv run pytest tests/test_integration.py::test_full_pipeline_integration -v -s --tb=short --log-cli-level=INFO
158+
if timeout 900 uv run pytest tests/test_integration.py::test_full_pipeline_integration -v -s --tb=short --log-cli-level=INFO; then
159+
print_success "Integration tests completed successfully!"
160+
else
161+
TEST_EXIT_CODE=$?
162+
print_error "Integration tests FAILED with exit code: $TEST_EXIT_CODE"
118163

119-
print_success "Integration tests completed successfully!"
164+
# Clean up test containers before exiting
165+
print_info "Cleaning up test containers after failure..."
166+
docker compose -f docker-compose-test.yml down -v || true
167+
docker system prune -f || true
168+
169+
exit $TEST_EXIT_CODE
170+
fi
120171

121172
# Clean up test containers
122173
print_info "Cleaning up test containers..."

backends/advanced/src/advanced_omi_backend/app_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ def __init__(self):
8686
# Memory service configuration
8787
self.memory_service_supports_threshold = self.memory_provider == "chronicle"
8888

89+
self.gdrive_credentials_path = "data/gdrive_service_account.json"
90+
self.gdrive_scopes = ["https://www.googleapis.com/auth/drive.readonly"]
91+
8992

9093
# Global configuration instance
9194
app_config = AppConfig()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
from google.oauth2.service_account import Credentials
3+
from googleapiclient.discovery import build
4+
from advanced_omi_backend.app_config import get_app_config
5+
6+
_drive_client_cache = None
7+
8+
def get_google_drive_client():
9+
"""Singleton Google Drive client."""
10+
global _drive_client_cache
11+
12+
if _drive_client_cache:
13+
return _drive_client_cache
14+
15+
config = get_app_config()
16+
17+
if not os.path.exists(config.gdrive_credentials_path):
18+
raise FileNotFoundError(
19+
f"Missing Google Drive credentials at {config.gdrive_credentials_path}"
20+
)
21+
22+
creds = Credentials.from_service_account_file(
23+
config.gdrive_credentials_path,
24+
scopes=config.gdrive_scopes
25+
)
26+
27+
_drive_client_cache = build("drive", "v3", credentials=creds)
28+
29+
return _drive_client_cache

0 commit comments

Comments
 (0)