Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Luisotee/messaging #24

Open
wants to merge 75 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
5d1c846
Initial api
Luisotee Dec 3, 2024
2d7bc83
changed lc to llamaindex
Luisotee Dec 7, 2024
98a479b
Added Zep, refactored classifier
Luisotee Dec 8, 2024
626084a
Enhance classifier route to generate unique user IDs using UUID
Luisotee Dec 9, 2024
4ee6758
Refactor classifier functions to include conversation context and imp…
Luisotee Dec 10, 2024
a0336d9
Working whatsapp
Luisotee Dec 14, 2024
3017f48
Refactor imports in classifier, audio_utils, and memory modules for i…
Luisotee Dec 14, 2024
b9d04ec
Integrated AI api
Luisotee Dec 14, 2024
2c16eb5
Audio and image handling
Luisotee Dec 14, 2024
3bc40e5
Process response from crewai
Luisotee Dec 14, 2024
b8df9b1
Translate command responses and error messages to Portuguese for bett…
Luisotee Dec 14, 2024
af2debb
Linting
Luisotee Dec 15, 2024
1a0a711
Ignored some sherif linting rules
Luisotee Dec 15, 2024
b8b5393
Enhance logging and configuration for WhatsApp integration
Luisotee Dec 17, 2024
b0ae989
fix errors
Luisotee Dec 27, 2024
4447de4
Changed to messaging api between whatsapp and ai_api
Luisotee Dec 27, 2024
1568cba
Fix: audio messages not working
Luisotee Dec 29, 2024
e59c509
Removed get endpoint in messaging
Luisotee Dec 29, 2024
53ffbee
saving incoming and outgoing messages in supabase
Luisotee Dec 29, 2024
14b2664
Getting message history from supabase
Luisotee Dec 29, 2024
37ba821
trigger test
Luisotee Dec 30, 2024
d3125ee
Revert "trigger test"
Luisotee Jan 5, 2025
800e492
Add PORT configuration to .env.example and clean up message.ts format…
Luisotee Jan 6, 2025
98a73a1
Refactor classifier and grant routes to use API calls instead of crew…
Luisotee Jan 6, 2025
3ba2471
Mem0 initial cfg
Luisotee Jan 9, 2025
70b1436
Integrate Mem0ConversationManager for enhanced session management and…
Luisotee Jan 11, 2025
18fec06
Disable Mem0 memory manager and update user ID references in Supabase…
Luisotee Jan 11, 2025
e75841b
Add platform support to classifier and messaging routes
Luisotee Jan 11, 2025
2290309
Add Supabase ID handling for message processing and storage
Luisotee Jan 11, 2025
96e0e5f
Implement API call monitoring and logging for message processing
Luisotee Jan 16, 2025
638c460
Trigger working
Luisotee Jan 18, 2025
3f75e72
Add configuration management with TypeScript and Python support
Luisotee Jan 19, 2025
2660b85
Refactor WhatsApp constants and configuration for improved structure …
Luisotee Jan 19, 2025
ae3bf95
Refactor configuration schemas into separate types file for better or…
Luisotee Jan 19, 2025
210ade8
Update example configuration with local database settings and enable …
Luisotee Jan 19, 2025
a9e0463
Initial python config package
Luisotee Jan 21, 2025
c797d76
Python package cleanup
Luisotee Jan 21, 2025
9e71e0e
Replace some .env with config
Luisotee Jan 21, 2025
ccb0577
Update Astro configuration to use dynamic server port from config
Luisotee Jan 21, 2025
d9be9c4
Removed env from dashboard
Luisotee Jan 21, 2025
19711d3
Fix error in landingpage + remove .env
Luisotee Jan 21, 2025
4b4e4de
Fix: Variable error
Luisotee Jan 21, 2025
77989c7
Using config for message api
Luisotee Jan 22, 2025
5977a87
Use config in whatsapp
Luisotee Jan 22, 2025
ff86fea
Refactor: Remove .env.example and generate env file from config durin…
Luisotee Jan 22, 2025
a01eda5
Fixed trigger related issues
Luisotee Jan 22, 2025
0cee3f7
Refactor: Update Neo4j deployment to use environment variables and ad…
Luisotee Jan 22, 2025
1deaa50
Refactor: Update langtrace deployment to use a script for environment…
Luisotee Jan 22, 2025
60e659a
Refactor: Remove example environment files and update Supabase client…
Luisotee Jan 22, 2025
7a2d427
Refactor: Replace environment variables with centralized config for A…
Luisotee Jan 22, 2025
2399e27
Refactor: Remove unused example environment files from grant_plugin a…
Luisotee Jan 22, 2025
8b0f467
Refactor: Update example configuration with specific database credent…
Luisotee Jan 22, 2025
72938f8
Refactor: Add README documentation for Messaging API with features, i…
Luisotee Jan 22, 2025
9ade4ec
Lint
Luisotee Jan 22, 2025
ce1e95b
Refactor: Update GitHub Actions workflow to use Bun for dependency ma…
Luisotee Jan 22, 2025
8828845
Update stacks.yaml
Luisotee Jan 22, 2025
8c80db6
Refactor: Update GitHub Actions workflow to install UV and activate v…
Luisotee Jan 22, 2025
a8f6587
Refactor: Improve GitHub Actions workflow by reorganizing steps and a…
Luisotee Jan 22, 2025
29bdd3b
Refactor: Update CI workflow and configuration for PostgreSQL and Cli…
Luisotee Jan 22, 2025
6d860be
Refactor: Update CI workflow to set up UV and streamline dependency i…
Luisotee Jan 22, 2025
16e93d2
Refactor: Simplify CI workflow and update package versions; streamlin…
Luisotee Jan 22, 2025
26b7f45
Refactor: Update configuration for database ports and remove unused d…
Luisotee Jan 22, 2025
b5080b0
Refactor: Enhance CI workflow by skipping config packages during endp…
Luisotee Jan 22, 2025
96a14e2
Refactor: Update endpoint testing to skip config packages and improve…
Luisotee Jan 22, 2025
5161803
Fix lint errors, stack.yml
Luisotee Jan 23, 2025
0f5b47f
Fix whatsapp lint
Luisotee Jan 23, 2025
57343e5
Fixed analytics lint
Luisotee Jan 23, 2025
313f459
Lint supabase
Luisotee Jan 23, 2025
2a42d19
Build and lint errors
Luisotee Jan 23, 2025
5949a69
Enhance service readiness checks in CI workflow and add get-port script
Luisotee Jan 23, 2025
b56cf03
Fixed langtrace configuration
Luisotee Jan 23, 2025
6d76488
Remove redundant service readiness checks from deployment workflow
Luisotee Jan 23, 2025
9bdac0c
Add special handling for Neo4j in get-port script
Luisotee Jan 23, 2025
fc9288a
Enhance service endpoint testing with detailed logging and network ch…
Luisotee Jan 23, 2025
5abc0d6
Add health check for containers in deployment workflow
Luisotee Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ jobs:
with:
bun-version: latest

- name: Setup UV
uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: bun install

- name: Setup config
run: |
cp config.example.yaml config.yaml
bun run build:config

- name: Run builds
run: bun run build

# - name: Run tests
# run: bun run test
# run: bun run test
145 changes: 109 additions & 36 deletions .github/workflows/stacks.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Deployment Stacks

on:
push:
paths:
- 'deploy/**'
pull_request:
paths:
- 'deploy/**'
Expand All @@ -15,70 +12,146 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install UV
uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: |
bun install
uv venv
. .venv/bin/activate

- name: Setup config
run: |
cp config.example.yaml config.yaml
bun run build:config

- name: Create Docker network
run: docker network create eda-network || true

- name: Find and process deploy directories
run: |
# Create dirs file
touch $GITHUB_WORKSPACE/deploy_dirs.txt

for dir in deploy/*/; do
if [ -d "$dir" ]; then
echo "Processing $dir"
cd "$dir"

# Copy environment file
cp .env.example .env
# Generate env from config
bun run export-config.ts > .env

# Start containers
docker compose up -d

# Store the directory name for later use
# Store directory
echo "${dir%/}" >> $GITHUB_WORKSPACE/deploy_dirs.txt

# Wait for containers to be fully up
echo "Waiting for containers to initialize..."
sleep 15

# Check if all containers are healthy
docker compose ps --format "{{.Name}} {{.Status}}" | while read -r line; do
if [[ ! $line =~ "(healthy)" ]] && [[ ! $line =~ "Up" ]]; then
echo "Container not healthy: $line"
docker compose logs
exit 1
fi
done

cd $GITHUB_WORKSPACE
fi
done

- name: Wait for services to be ready
run: sleep 50

- name: Test endpoints
run: |
while IFS= read -r dir; do
echo "Testing endpoints for $dir"
service_name=$(basename "$dir" | sed 's/-stack//')
echo "=== Testing endpoints for service: $service_name ==="

# Extract the service name from directory path
service_name=$(basename "$dir")
# Show container status
echo "Docker container status:"
docker ps -a | grep $service_name || true

# First check for HEALTHCHECK URL in .env file
if [ -f "$dir/.env" ]; then
healthcheck_url=$(grep '^HEALTHCHECK=' "$dir/.env" | cut -d '=' -f2)
if [ -n "$healthcheck_url" ]; then
test_url="$healthcheck_url"
else
# If no HEALTHCHECK, fall back to PORT
port=$(grep '^PORT=' "$dir/.env" | cut -d '=' -f2)
if [ -z "$port" ]; then
echo "No PORT found in .env for $service_name, using default 3000"
port=3000
fi
test_url="http://localhost:${port}/"
fi
else
echo "No .env file found for $service_name, using default 3000"
test_url="http://localhost:3000/"
# Show container logs
echo "Container logs:"
docker logs $service_name 2>&1 || true

# Skip config packages
if [[ "$service_name" == "config" ]]; then
echo "Skipping config package: $service_name"
continue
fi

# Test the endpoint
curl --fail "$test_url" || {
# Get and verify port
port=$(bun run -b --bun ./tooling/scripts/get-port.ts ${service_name})
echo "Retrieved port: $port"

if [ -z "$port" ]; then
echo "No port found for $service_name in config, skipping..."
continue
fi

# Network connectivity check
echo "Testing network connectivity:"
nc -zv localhost $port 2>&1 || true

test_url="http://localhost:${port}/"
echo "Testing URL: $test_url"

# More verbose curl
curl -v --fail --retry 5 --retry-delay 10 --retry-connrefused "$test_url" || {
echo "=== Error Details ==="
echo "Failed to reach $test_url for $service_name"
echo "Container status:"
docker ps -a | grep $service_name || true
echo "Latest logs:"
docker logs --tail 50 ${service_name} 2>&1 || true
echo "Network status:"
netstat -tulpn | grep $port || true
exit 1
}

echo "=== Test completed for $service_name ==="
done < $GITHUB_WORKSPACE/deploy_dirs.txt
- name: Cleanup
if: always()

- name: Check service health
run: |
while IFS= read -r dir; do
cd "$dir"
docker compose down
cd $GITHUB_WORKSPACE
service_name=$(basename "$dir" | sed 's/-stack//')
echo "Checking health for $service_name..."

# Get port from config
port=$(bun run -b --bun ./tooling/scripts/get-port.ts ${service_name})

# Skip if no port found
if [ -z "$port" ]; then
echo "No port configured for $service_name, skipping..."
continue
fi

# Wait for port to be available
timeout 60 bash -c "until nc -z localhost $port; do sleep 2; done" || {
echo "Service $service_name not ready on port $port"
docker logs ${service_name} || true
exit 1
}
done < $GITHUB_WORKSPACE/deploy_dirs.txt

- name: Cleanup
if: always()
run: |
if [ -f "$GITHUB_WORKSPACE/deploy_dirs.txt" ]; then
while IFS= read -r dir; do
cd "$dir"
docker compose down
cd $GITHUB_WORKSPACE
done < $GITHUB_WORKSPACE/deploy_dirs.txt
fi
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ media/
apps/whatsapp-store/message_db.json
*.zip
observations_db.json
old
old
config.yaml
!config.example.yaml
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
Expand Down
7 changes: 0 additions & 7 deletions apps/ai_api/.env.example

This file was deleted.

4 changes: 3 additions & 1 deletion apps/ai_api/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ hang-closing = True
# E133 - closing bracket is missing indentation (conflicts with black)
# E203 - whitespace before ‘:’ (conflicts with black)
# W503 - line break before binary operator
# W504 - line break after binary operator
# F401 - module imported but unused
# F403 - ‘from module import *’ used; unable to detect undefined names
#
Expand All @@ -95,7 +96,8 @@ hang-closing = True
ignore =
E133,
E203,
W503
W503,
W504
# Specify the list of error codes you wish Flake8 to report.
select =
E,
Expand Down
4 changes: 4 additions & 0 deletions apps/ai_api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@ ENV/
# mypy
.mypy_cache/
.idea/

# CSV Reports
*.csv
report_*.csv
Loading
Loading