feat: Major UI/UX improvements and production readiness
CI / backend-test (push) Successful in 4m9s
CI / frontend-test (push) Failing after 3m48s
CI / lint-python (push) Successful in 1m41s
CI / secret-scanning (push) Successful in 1m20s
CI / dependency-scan (push) Successful in 10m50s
CI / workflow-summary (push) Successful in 1m11s

## Features Added

### Document Reference System
- Implemented numbered document references (@1, @2, etc.) with autocomplete dropdown
- Added fuzzy filename matching for @filename references
- Document filtering now prioritizes numeric refs > filename refs > all documents
- Autocomplete dropdown appears when typing @ with keyboard navigation (Up/Down, Enter/Tab, Escape)
- Document numbers displayed in UI for easy reference

### Conversation Management
- Added conversation rename functionality with inline editing
- Implemented conversation search (by title and content)
- Search box always visible, even when no conversations exist
- Export reports now replace @N references with actual filenames

### UI/UX Improvements
- Removed debug toggle button
- Improved text contrast in dark mode (better visibility)
- Made input textarea expand to full available width
- Fixed file text color for better readability
- Enhanced document display with numbered badges

### Configuration & Timeouts
- Made HTTP client timeouts configurable (connect, write, pool)
- Added .env.example with all configuration options
- Updated timeout documentation

### Developer Experience
- Added `make test-setup` target for automated test conversation creation
- Test setup script supports TEST_MESSAGE and TEST_DOCS env vars
- Improved Makefile with dev and test-setup targets

### Documentation
- Updated ARCHITECTURE.md with all new features
- Created comprehensive deployment documentation
- Added GPU VM setup guides
- Removed unnecessary markdown files (CLAUDE.md, CONTRIBUTING.md, header.jpg)
- Organized documentation in docs/ directory

### GPU VM / Ollama (Stability + GPU Offload)
- Updated GPU VM docs to reflect the working systemd environment for remote Ollama
- Standardized remote Ollama port to 11434 (and added /v1/models verification)
- Documented required env for GPU offload on this VM:
  - `OLLAMA_MODELS=/mnt/data/ollama`, `HOME=/mnt/data/ollama/home`
  - `OLLAMA_LLM_LIBRARY=cuda_v12` (not `cuda`)
  - `LD_LIBRARY_PATH=/usr/local/lib/ollama:/usr/local/lib/ollama/cuda_v12`

## Technical Changes

### Backend
- Enhanced `docs_context.py` with reference parsing (numeric and filename)
- Added `update_conversation_title` to storage.py
- New endpoints: PATCH /api/conversations/{id}/title, GET /api/conversations/search
- Improved report generation with filename substitution

### Frontend
- Removed debugMode state and related code
- Added autocomplete dropdown component
- Implemented search functionality in Sidebar
- Enhanced ChatInterface with autocomplete and improved textarea sizing
- Updated CSS for better contrast and responsive design

## Files Changed
- Backend: config.py, council.py, docs_context.py, main.py, storage.py
- Frontend: App.jsx, ChatInterface.jsx, Sidebar.jsx, and related CSS files
- Documentation: README.md, ARCHITECTURE.md, new docs/ directory
- Configuration: .env.example, Makefile
- Scripts: scripts/test_setup.py

## Breaking Changes
None - all changes are backward compatible

## Testing
- All existing tests pass
- New test-setup script validates conversation creation workflow
- Manual testing of autocomplete, search, and rename features
This commit is contained in:
ira
2025-12-28 18:15:02 -05:00
commit 3546c04348
79 changed files with 13531 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
# Check if firewall might be blocking the connection
GPU_VM="10.0.30.63"
echo "=== Firewall Check ==="
echo ""
echo "The fact that Ollama shows ':::11434' means it's listening on all interfaces."
echo "If curl still times out, it's likely a firewall issue."
echo ""
echo "On the GPU VM, check firewall:"
echo " # Check if firewall is running:"
echo " sudo ufw status"
echo " # OR"
echo " sudo iptables -L -n | grep 11434"
echo ""
echo "If firewall is blocking, allow the port:"
echo " sudo ufw allow 11434/tcp"
echo " # OR for iptables:"
echo " sudo iptables -A INPUT -p tcp --dport 11434 -j ACCEPT"
echo ""
echo "Testing connection from local machine..."
timeout 3 curl -v http://$GPU_VM:11434/api/tags 2>&1 | grep -E "Connected|timeout|refused|Connection" | head -3
+60
View File
@@ -0,0 +1,60 @@
#!/bin/bash
# Check if Ollama models still exist on GPU VM
# Run this ON THE GPU VM
echo "=== Checking Ollama Models ==="
echo ""
# Check Ollama's model storage locations
echo "1. Checking Ollama API for models:"
curl -s http://localhost:11434/api/tags | python3 -m json.tool 2>/dev/null | grep -E '"name"|"model"' | head -10
echo ""
echo "2. Checking common model storage locations:"
echo " ~/.ollama/models:"
if [ -d ~/.ollama/models ]; then
du -sh ~/.ollama/models
ls -lh ~/.ollama/models | head -5
else
echo " ✗ Not found"
fi
echo ""
echo " /usr/share/ollama/models:"
if [ -d /usr/share/ollama/models ]; then
du -sh /usr/share/ollama/models
ls -lh /usr/share/ollama/models | head -5
else
echo " ✗ Not found"
fi
echo ""
echo " /var/lib/ollama/models:"
if [ -d /var/lib/ollama/models ]; then
du -sh /var/lib/ollama/models
ls -lh /var/lib/ollama/models | head -5
else
echo " ✗ Not found"
fi
echo ""
echo "3. Finding Ollama data directory:"
if command -v ollama > /dev/null; then
ollama show 2>&1 | head -5
fi
echo ""
echo "4. Checking systemd service for OLLAMA_MODELS path:"
systemctl show ollama | grep -i model || echo " No OLLAMA_MODELS env var set"
echo ""
echo "=== What we did ==="
echo "We only created: /etc/systemd/system/ollama.service.d/override.conf"
echo "This file only sets: OLLAMA_HOST=0.0.0.0:11434"
echo "It does NOT delete models."
echo ""
echo "If models are missing, they might be:"
echo " 1. In a different location (check above)"
echo " 2. Ollama needs to be restarted to see them"
echo " 3. Models were deleted separately (not by our script)"
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
# Script to configure Ollama on GPU VM to listen on all interfaces
# Run this on the GPU VM (10.0.30.63)
echo "Configuring Ollama to listen on all interfaces..."
# Method 1: Set environment variable (temporary, until reboot)
export OLLAMA_HOST=0.0.0.0:11434
echo "✓ Set OLLAMA_HOST=0.0.0.0:11434 (temporary)"
# Method 2: Create systemd override (permanent)
echo ""
echo "Creating systemd override for permanent configuration..."
sudo mkdir -p /etc/systemd/system/ollama.service.d
sudo tee /etc/systemd/system/ollama.service.d/override.conf > /dev/null <<EOF
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
EOF
echo "✓ Created override file: /etc/systemd/system/ollama.service.d/override.conf"
# Reload systemd and restart Ollama
echo ""
echo "Reloading systemd and restarting Ollama..."
sudo systemctl daemon-reload
sudo systemctl restart ollama
echo ""
echo "✓ Ollama restarted"
echo ""
echo "Verifying configuration..."
sleep 2
curl -s http://localhost:11434/api/tags | head -c 200
echo ""
echo ""
echo "✓ Configuration complete!"
echo ""
echo "You can now test from your local machine:"
echo " curl http://10.0.30.63:11434/api/tags"
+57
View File
@@ -0,0 +1,57 @@
#!/bin/bash
# Quick diagnostic script for GPU VM connection
GPU_VM="10.0.30.63"
echo "=== GPU VM Connection Diagnostics ==="
echo ""
echo "1. Testing basic connectivity..."
if ping -c 1 -W 2 $GPU_VM > /dev/null 2>&1; then
echo " ✓ GPU VM is reachable"
else
echo " ✗ Cannot reach GPU VM - check network/firewall"
exit 1
fi
echo ""
echo "2. Testing port 11434 (Ollama default)..."
if timeout 3 curl -s http://$GPU_VM:11434/api/tags > /dev/null 2>&1; then
echo " ✓ Port 11434 is open and responding"
echo " Models available:"
curl -s http://$GPU_VM:11434/api/tags | python3 -m json.tool 2>/dev/null | grep -E '"name"|"model"' | head -5
else
echo " ✗ Port 11434 not responding"
echo " Error details:"
timeout 3 curl -v http://$GPU_VM:11434/api/tags 2>&1 | grep -E "Connection|timeout|refused" | head -3
fi
echo ""
echo "3. Testing port 8000 (alternative)..."
if timeout 3 curl -s http://$GPU_VM:8000/v1/models > /dev/null 2>&1; then
echo " ✓ Port 8000 is open and responding"
else
echo " ✗ Port 8000 not responding"
fi
echo ""
echo "4. Checking your .env configuration..."
if [ -f .env ]; then
echo " OPENAI_COMPAT_BASE_URL: $(grep OPENAI_COMPAT_BASE_URL .env | grep -v '^#' | cut -d'=' -f2)"
echo " USE_LOCAL_OLLAMA: $(grep USE_LOCAL_OLLAMA .env | grep -v '^#' | cut -d'=' -f2)"
else
echo " ✗ .env file not found"
fi
echo ""
echo "=== Recommendations ==="
echo ""
echo "If port 11434 is not working:"
echo " 1. SSH to GPU VM: ssh root@$GPU_VM"
echo " 2. Check if Ollama is running: systemctl status ollama"
echo " 3. Check what port Ollama is listening on: netstat -tlnp | grep ollama"
echo " 4. If only listening on 127.0.0.1, configure it to listen on 0.0.0.0"
echo ""
echo "If you need to use a different port, update .env:"
echo " OPENAI_COMPAT_BASE_URL=http://$GPU_VM:PORT"
+59
View File
@@ -0,0 +1,59 @@
#!/bin/bash
# Find and verify Ollama models on GPU VM
# Run this ON THE GPU VM
echo "=== Finding Ollama Models ==="
echo ""
echo "1. Check what Ollama API reports:"
echo " Running: curl http://localhost:11434/api/tags"
curl -s http://localhost:11434/api/tags | python3 -m json.tool 2>/dev/null || curl -s http://localhost:11434/api/tags
echo ""
echo ""
echo "2. Find Ollama data directory:"
echo " Checking common locations..."
# Check for OLLAMA_MODELS env var
if [ -n "$OLLAMA_MODELS" ]; then
echo " OLLAMA_MODELS env var: $OLLAMA_MODELS"
if [ -d "$OLLAMA_MODELS" ]; then
echo " ✓ Found! Size: $(du -sh "$OLLAMA_MODELS" 2>/dev/null | cut -f1)"
echo " Models:"
ls -lh "$OLLAMA_MODELS" | head -10
fi
fi
# Check common locations
for dir in ~/.ollama/models ~/.ollama /usr/share/ollama/models /usr/share/ollama /var/lib/ollama/models /var/lib/ollama; do
if [ -d "$dir" ]; then
echo " Found: $dir"
echo " Size: $(du -sh "$dir" 2>/dev/null | cut -f1)"
if [ -d "$dir/models" ]; then
echo " Models in subdirectory:"
ls -lh "$dir/models" 2>/dev/null | head -5
fi
find "$dir" -name "*.gguf" -o -name "*.bin" 2>/dev/null | head -5
fi
done
echo ""
echo "3. Check Ollama process environment:"
sudo cat /proc/$(pgrep -f ollama | head -1)/environ 2>/dev/null | tr '\0' '\n' | grep -i model || echo " No OLLAMA_MODELS in process env"
echo ""
echo "4. Check systemd service environment:"
systemctl show ollama | grep -i environment
echo ""
echo "=== If models are missing ==="
echo "They might be in a different location. Ollama stores models in:"
echo " - Default: ~/.ollama/models (or /usr/share/ollama/models)"
echo " - Or wherever OLLAMA_MODELS env var points"
echo ""
echo "To re-download models:"
echo " ollama pull qwen2:latest"
echo " ollama pull qwen2.5:14b"
echo " ollama pull llama3.1:8b"
echo " ollama pull qwen2.5:7b"
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
# Run this ON THE GPU VM to fix firewall
echo "=== Fixing Firewall for Ollama ==="
echo ""
# Check what firewall is running
if command -v ufw > /dev/null 2>&1; then
echo "Detected UFW firewall"
echo "Current status:"
sudo ufw status | head -5
echo ""
echo "Allowing port 11434..."
sudo ufw allow 11434/tcp
echo "✓ Port 11434 allowed"
elif command -v firewall-cmd > /dev/null 2>&1; then
echo "Detected firewalld"
sudo firewall-cmd --permanent --add-port=11434/tcp
sudo firewall-cmd --reload
echo "✓ Port 11434 allowed"
else
echo "Checking iptables..."
if sudo iptables -L -n | grep -q 11434; then
echo "Found iptables rules for 11434"
else
echo "Adding iptables rule..."
sudo iptables -A INPUT -p tcp --dport 11434 -j ACCEPT
echo "✓ Rule added (may need to save: sudo iptables-save)"
fi
fi
echo ""
echo "Verifying Ollama is accessible..."
sleep 1
curl -s http://localhost:11434/api/tags | head -c 100
echo ""
echo ""
echo "✓ Done! Test from your local machine:"
echo " curl http://10.0.30.63:11434/api/tags"
+57
View File
@@ -0,0 +1,57 @@
#!/bin/bash
# Run this ON THE GPU VM (10.0.30.63) to fix Ollama remote access
echo "=== Fixing Ollama Remote Access ==="
echo ""
# Check if Ollama is running
if ! systemctl is-active --quiet ollama; then
echo "✗ Ollama is not running. Starting it..."
sudo systemctl start ollama
sleep 2
fi
echo "✓ Ollama is running"
echo ""
# Check what it's listening on
echo "Current Ollama listening status:"
sudo netstat -tlnp 2>/dev/null | grep 11434 || ss -tlnp 2>/dev/null | grep 11434
echo ""
# Create systemd override
echo "Creating systemd override to listen on all interfaces..."
sudo mkdir -p /etc/systemd/system/ollama.service.d
sudo tee /etc/systemd/system/ollama.service.d/override.conf > /dev/null <<'EOF'
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
EOF
echo "✓ Override file created"
echo ""
# Reload and restart
echo "Reloading systemd and restarting Ollama..."
sudo systemctl daemon-reload
sudo systemctl restart ollama
sleep 3
echo "✓ Ollama restarted"
echo ""
# Verify
echo "Verifying configuration..."
if sudo netstat -tlnp 2>/dev/null | grep -q "0.0.0.0:11434" || sudo ss -tlnp 2>/dev/null | grep -q "0.0.0.0:11434"; then
echo "✓ SUCCESS! Ollama is now listening on 0.0.0.0:11434"
echo ""
echo "Test from your local machine:"
echo " curl http://10.0.30.63:11434/api/tags"
else
echo "✗ Still not listening on 0.0.0.0 - checking status..."
sudo systemctl status ollama --no-pager | head -10
echo ""
echo "Try checking Ollama logs:"
echo " sudo journalctl -u ollama -n 20"
fi
+87
View File
@@ -0,0 +1,87 @@
#!/bin/bash
# Configure Ollama to use /mnt/data for model storage
# Run this ON THE GPU VM
echo "=== Fixing Ollama Storage Location ==="
echo ""
# Check current disk usage
echo "Current disk usage:"
df -h | grep -E "Filesystem|/dev/sda"
echo ""
# Create models directory on /mnt/data
echo "Creating Ollama models directory on /mnt/data..."
sudo mkdir -p /mnt/data/ollama/models
sudo chown -R ollama:ollama /mnt/data/ollama 2>/dev/null || sudo chown -R $(whoami):$(whoami) /mnt/data/ollama
echo "✓ Directory created: /mnt/data/ollama/models"
echo ""
# Check if there are existing models to move
if [ -d ~/.ollama/models ] && [ "$(ls -A ~/.ollama/models 2>/dev/null)" ]; then
echo "Found existing models in ~/.ollama/models"
echo "Moving to /mnt/data/ollama/models..."
sudo mv ~/.ollama/models/* /mnt/data/ollama/models/ 2>/dev/null
echo "✓ Models moved"
elif [ -d /usr/share/ollama/models ] && [ "$(ls -A /usr/share/ollama/models 2>/dev/null)" ]; then
echo "Found existing models in /usr/share/ollama/models"
echo "Moving to /mnt/data/ollama/models..."
sudo mv /usr/share/ollama/models/* /mnt/data/ollama/models/ 2>/dev/null
echo "✓ Models moved"
else
echo "No existing models found to move"
fi
echo ""
# Update systemd service to use new location
echo "Updating systemd service configuration..."
sudo mkdir -p /etc/systemd/system/ollama.service.d
# Check if override.conf exists and update it, or create new
if [ -f /etc/systemd/system/ollama.service.d/override.conf ]; then
echo "Updating existing override.conf..."
# Add OLLAMA_MODELS if not already there
if ! grep -q "OLLAMA_MODELS" /etc/systemd/system/ollama.service.d/override.conf; then
sudo sed -i '/\[Service\]/a Environment="OLLAMA_MODELS=/mnt/data/ollama/models"' /etc/systemd/system/ollama.service.d/override.conf
else
sudo sed -i 's|OLLAMA_MODELS=.*|OLLAMA_MODELS=/mnt/data/ollama/models|' /etc/systemd/system/ollama.service.d/override.conf
fi
else
echo "Creating new override.conf..."
sudo tee /etc/systemd/system/ollama.service.d/override.conf > /dev/null <<EOF
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_MODELS=/mnt/data/ollama/models"
EOF
fi
echo "✓ Systemd configuration updated"
echo ""
# Reload and restart
echo "Reloading systemd and restarting Ollama..."
sudo systemctl daemon-reload
sudo systemctl restart ollama
sleep 3
echo "✓ Ollama restarted with new storage location"
echo ""
# Verify
echo "Verifying configuration:"
echo " Storage location: /mnt/data/ollama/models"
echo " Disk space available:"
df -h /mnt/data | tail -1
echo ""
echo " Checking if Ollama is running:"
systemctl is-active ollama && echo " ✓ Ollama is running" || echo " ✗ Ollama is not running"
echo ""
echo "=== Done! ==="
echo "You can now pull models:"
echo " ollama pull qwen2:latest"
echo " ollama pull qwen2.5:14b"
echo " ollama pull llama3.1:8b"
echo " ollama pull qwen2.5:7b"
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
"""Quick test script to check GPU VM connection."""
import asyncio
import sys
sys.path.insert(0, '.')
from backend.llm_client import list_models
from backend.config import OPENAI_COMPAT_BASE_URL, COUNCIL_MODELS, CHAIRMAN_MODEL
async def test_connection():
print(f"Testing connection to: {OPENAI_COMPAT_BASE_URL}")
print(f"Configured council models: {COUNCIL_MODELS}")
print(f"Chairman model: {CHAIRMAN_MODEL}")
print("-" * 60)
try:
models = await list_models()
if models is None:
print("✗ Unable to list models (connection error, timeout, or incompatible endpoint).")
print("")
print("Next checks:")
print(f" - curl {OPENAI_COMPAT_BASE_URL.rstrip('/')}/api/tags")
print(f" - curl {OPENAI_COMPAT_BASE_URL.rstrip('/')}/v1/models")
print("")
print("If you're using Ollama remotely, the port is usually 11434.")
return
if models:
print(f"✓ Connection successful!")
print(f"Found {len(models)} available models:\n")
for model in models:
marker = "" if model in COUNCIL_MODELS else " "
chairman_marker = " (CHAIRMAN)" if model == CHAIRMAN_MODEL else ""
print(f" {marker} {model}{chairman_marker}")
print("\n" + "-" * 60)
missing = [m for m in COUNCIL_MODELS if m not in models]
if missing:
print(f"⚠ Warning: {len(missing)} configured models not found:")
for m in missing:
print(f" - {m}")
else:
print("✓ All configured council models are available!")
else:
print("✗ Connected, but the server returned an empty model list.")
print(" This is unusual for Ollama; double-check the base URL/port and server.")
except Exception as e:
print(f"✗ Connection failed: {type(e).__name__}: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
asyncio.run(test_connection())
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
"""Detailed test script to check GPU VM connection and endpoints."""
import asyncio
import sys
sys.path.insert(0, '.')
import httpx
from backend.config import OPENAI_COMPAT_BASE_URL
async def test_endpoints():
base_url = "http://10.0.30.63"
ports = [8000, 11434]
endpoints = [
"/v1/models",
"/api/tags",
"/api/version",
"/",
]
print("Testing GPU VM connection...")
print("=" * 60)
for port in ports:
print(f"\nTesting port {port}:")
print("-" * 60)
for endpoint in endpoints:
url = f"{base_url}:{port}{endpoint}"
try:
async with httpx.AsyncClient(timeout=5.0) as client:
resp = await client.get(url)
print(f" {endpoint:20} -> Status: {resp.status_code}")
if resp.status_code == 200:
try:
data = resp.json()
if isinstance(data, dict):
if 'data' in data:
models = data['data']
print(f" Found {len(models)} models via /v1/models")
if models:
print(f" First model: {models[0].get('id', models[0])}")
elif 'models' in data:
models = data['models']
print(f" Found {len(models)} models via /api/tags")
if models:
print(f" First model: {models[0].get('name', models[0])}")
else:
print(f" Response keys: {list(data.keys())[:5]}")
elif isinstance(data, list):
print(f" Found {len(data)} items")
except:
print(f" Response (first 200 chars): {resp.text[:200]}")
except httpx.TimeoutException:
print(f" {endpoint:20} -> Timeout")
except httpx.ConnectError:
print(f" {endpoint:20} -> Connection refused")
except Exception as e:
print(f" {endpoint:20} -> Error: {type(e).__name__}")
if __name__ == "__main__":
asyncio.run(test_endpoints())
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env python3
"""Test that we can actually query a model and get a response."""
import asyncio
import sys
sys.path.insert(0, '.')
from backend.llm_client import query_model
from backend.config import COUNCIL_MODELS
async def test_query():
"""Test querying one of the council models."""
if not COUNCIL_MODELS:
print("✗ No council models configured")
return False
test_model = COUNCIL_MODELS[0]
print(f"Testing query to model: {test_model}")
print("-" * 60)
try:
response = await query_model(
model=test_model,
messages=[{"role": "user", "content": "Say 'Hello, GPU Ollama is working!' in one sentence."}],
max_tokens_override=50, # Short response for quick test
timeout=30.0
)
if response and response.get('content'):
content = response['content'].strip()
print(f"✓ Query successful!")
print(f"\nResponse:")
print(f" {content}")
return True
else:
print(f"✗ Query returned no content")
print(f"Response: {response}")
return False
except Exception as e:
print(f"✗ Query failed: {type(e).__name__}: {e}")
import traceback
traceback.print_exc()
return False
if __name__ == "__main__":
success = asyncio.run(test_query())
sys.exit(0 if success else 1)
+70
View File
@@ -0,0 +1,70 @@
#!/usr/bin/env python3
"""Test script to diagnose model timeout issues."""
import asyncio
import time
import httpx
from backend.config import OPENAI_COMPAT_BASE_URL, LLM_TIMEOUT_SECONDS, DEBUG
async def test_model(model: str, max_tokens: int = 10):
"""Test a single model query."""
print(f"\n{'='*60}")
print(f"Testing model: {model}")
print(f"Timeout: {LLM_TIMEOUT_SECONDS}s")
print(f"Base URL: {OPENAI_COMPAT_BASE_URL}")
print(f"{'='*60}")
url = f"{OPENAI_COMPAT_BASE_URL}/v1/chat/completions"
payload = {
"model": model,
"messages": [{"role": "user", "content": "Say hello"}],
"max_tokens": max_tokens
}
start_time = time.time()
try:
async with httpx.AsyncClient(timeout=LLM_TIMEOUT_SECONDS) as client:
print(f"[{time.time() - start_time:.1f}s] Sending request...")
response = await client.post(url, json=payload)
elapsed = time.time() - start_time
print(f"[{elapsed:.1f}s] Response received: Status {response.status_code}")
if response.status_code == 200:
data = response.json()
content = data.get("choices", [{}])[0].get("message", {}).get("content", "")
print(f"✓ Success! Response: {content[:100]}")
return True
else:
print(f"✗ Error: {response.status_code}")
print(f" Response: {response.text[:200]}")
return False
except httpx.TimeoutException:
elapsed = time.time() - start_time
print(f"✗ Timeout after {elapsed:.1f}s (limit was {LLM_TIMEOUT_SECONDS}s)")
return False
except Exception as e:
elapsed = time.time() - start_time
print(f"✗ Error after {elapsed:.1f}s: {type(e).__name__}: {e}")
return False
async def main():
models = ["llama3.2:1b", "qwen2.5:0.5b", "gemma2:2b"]
print("Testing models sequentially to diagnose timeout issues...")
print(f"Current timeout setting: {LLM_TIMEOUT_SECONDS}s")
results = {}
for model in models:
results[model] = await test_model(model)
# Small delay between tests
await asyncio.sleep(1)
print(f"\n{'='*60}")
print("Summary:")
for model, success in results.items():
status = "✓ PASS" if success else "✗ FAIL"
print(f" {model}: {status}")
print(f"{'='*60}")
if __name__ == "__main__":
asyncio.run(main())
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
"""Test direct connection to Ollama on GPU VM."""
import asyncio
import httpx
async def test():
base = "http://10.0.30.63:11434"
urls = [
f"{base}/v1/models",
f"{base}/api/tags",
]
for url in urls:
print(f"\nTesting: {url}")
try:
async with httpx.AsyncClient(timeout=5.0) as client:
resp = await client.get(url)
print(f" Status: {resp.status_code}")
if resp.status_code == 200:
data = resp.json()
print(f" Keys: {list(data.keys())}")
if 'models' in data:
models = [m.get('name', m.get('model', m)) for m in data['models']]
print(f" Found {len(models)} models: {models}")
elif 'data' in data:
models = [m.get('id', m) for m in data['data']]
print(f" Found {len(models)} models: {models}")
except httpx.TimeoutException:
print(f" ✗ Timeout - Ollama may only be listening on localhost")
except Exception as e:
print(f" ✗ Error: {e}")
asyncio.run(test())
+140
View File
@@ -0,0 +1,140 @@
#!/usr/bin/env python3
"""Setup a test conversation with optional message and documents."""
import os
import sys
import httpx
import time
from datetime import datetime
from pathlib import Path
from dotenv import load_dotenv
from urllib.parse import quote
# Load .env file if it exists
load_dotenv()
API_BASE = "http://localhost:8001"
def create_test_conversation():
"""Create a new conversation with today's date/time as title."""
now = datetime.now()
title = now.strftime("%Y-%m-%d %H:%M:%S")
with httpx.Client(timeout=10.0) as client:
# Create conversation
response = client.post(f"{API_BASE}/api/conversations", json={})
if response.status_code != 200:
print(f"Error creating conversation: {response.text}", file=sys.stderr)
sys.exit(1)
conv = response.json()
conv_id = conv["id"]
# Update title
response = client.patch(
f"{API_BASE}/api/conversations/{conv_id}/title",
json={"title": title}
)
if response.status_code != 200:
print(f"Warning: Could not set title: {response.text}", file=sys.stderr)
print(f"Created conversation: {conv_id}")
print(f"Title: {title}")
return conv_id
def upload_document(conv_id, filepath):
"""Upload a document to a conversation."""
path = Path(filepath)
if not path.exists():
print(f"Warning: File not found: {filepath}", file=sys.stderr)
return False
with httpx.Client(timeout=30.0) as client:
with open(path, 'rb') as f:
files = {'file': (path.name, f.read(), 'text/markdown')}
response = client.post(
f"{API_BASE}/api/conversations/{conv_id}/documents",
files=files
)
if response.status_code != 200:
print(f"Warning: Could not upload {filepath}: {response.text}", file=sys.stderr)
return False
print(f"Uploaded: {path.name}")
return True
def send_message(conv_id, message):
"""Send a message to a conversation."""
# Use a very long timeout since the council process can take several minutes
# Default to 10 minutes, but allow override via env var
timeout_seconds = float(os.getenv("TEST_MESSAGE_TIMEOUT_SECONDS", "600.0"))
print(f"Sending message (this may take several minutes, timeout: {timeout_seconds}s)...")
with httpx.Client(timeout=timeout_seconds) as client:
try:
response = client.post(
f"{API_BASE}/api/conversations/{conv_id}/message",
json={"content": message}
)
if response.status_code != 200:
print(f"Warning: Could not send message: {response.text}", file=sys.stderr)
return False
print(f"✓ Message sent and processed: {message[:50]}...")
return True
except httpx.ReadTimeout:
print(f"Error: Request timed out after {timeout_seconds}s", file=sys.stderr)
print("The council process is still running. You can check the conversation in the UI.", file=sys.stderr)
print(f"Conversation ID: {conv_id}", file=sys.stderr)
return False
except httpx.RequestError as e:
print(f"Error sending message: {e}", file=sys.stderr)
return False
def main():
# Wait for backend to be ready
max_retries = 10
for i in range(max_retries):
try:
with httpx.Client(timeout=1.0) as client:
response = client.get(f"{API_BASE}/")
if response.status_code == 200:
break
except httpx.RequestError:
if i < max_retries - 1:
time.sleep(1)
else:
print(f"Error: Backend not available at {API_BASE}", file=sys.stderr)
print("Make sure the backend is running: uv run python -m backend.main", file=sys.stderr)
sys.exit(1)
# Create conversation
conv_id = create_test_conversation()
# Upload documents if specified
test_docs = os.getenv("TEST_DOCS", "")
if test_docs:
doc_paths = [p.strip() for p in test_docs.split(",") if p.strip()]
for doc_path in doc_paths:
upload_document(conv_id, doc_path)
# Note: TEST_MESSAGE is NOT sent automatically
# It's provided here for reference - user should type it in the UI
test_message = os.getenv("TEST_MESSAGE", "")
open_url = f"http://localhost:5173/?conversation={conv_id}"
if test_message:
open_url += f"&message={quote(test_message)}"
print(f"\n✓ Conversation created: {conv_id}")
print(f"CONVERSATION_ID={conv_id}") # For Makefile to parse
print(f"OPEN_URL={open_url}") # For Makefile to parse
print(f"Open in browser: {open_url}")
if test_message:
print(f"\n💡 Pre-filled message (copy/paste into input):")
print(f" {test_message}")
return conv_id
if __name__ == "__main__":
main()