feat: enhance chat service with documentation indexing and improved Docker configuration
Some checks failed
CI/CD Pipeline / Generate Documentation (push) Failing after 7m41s
CI/CD Pipeline / Lint Code (push) Failing after 7m44s
CI/CD Pipeline / Run Tests (push) Has been skipped
CI/CD Pipeline / Security Scanning (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (api) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (chat) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (frontend) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (worker) (push) Has been skipped
CI/CD Pipeline / Deploy to Staging (push) Has been skipped
CI/CD Pipeline / Deploy to Production (push) Has been skipped
Some checks failed
CI/CD Pipeline / Generate Documentation (push) Failing after 7m41s
CI/CD Pipeline / Lint Code (push) Failing after 7m44s
CI/CD Pipeline / Run Tests (push) Has been skipped
CI/CD Pipeline / Security Scanning (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (api) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (chat) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (frontend) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (worker) (push) Has been skipped
CI/CD Pipeline / Deploy to Staging (push) Has been skipped
CI/CD Pipeline / Deploy to Production (push) Has been skipped
This commit is contained in:
90
scripts/start_chat.py
Executable file
90
scripts/start_chat.py
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Startup script for chat service with documentation indexing.
|
||||
Runs indexing if needed, then starts the chat server.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s - %(levelname)s - %(message)s"
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
"""Main startup routine"""
|
||||
|
||||
logger.info("=" * 50)
|
||||
logger.info("Datacenter Documentation Chat Service")
|
||||
logger.info("Starting initialization...")
|
||||
logger.info("=" * 50)
|
||||
|
||||
# Check if vector store needs initialization
|
||||
vector_store_path = Path("/app/data/chroma_db")
|
||||
index_marker = vector_store_path / ".indexed"
|
||||
|
||||
if not index_marker.exists():
|
||||
logger.info("")
|
||||
logger.info("=" * 50)
|
||||
logger.info("First Time Setup")
|
||||
logger.info("=" * 50)
|
||||
logger.info("Indexing documentation into vector store...")
|
||||
logger.info("This may take a few minutes...")
|
||||
logger.info("")
|
||||
|
||||
# Run indexing script
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[sys.executable, "/app/scripts/index_docs.py"],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
logger.info(result.stdout)
|
||||
|
||||
# Create marker file
|
||||
vector_store_path.mkdir(parents=True, exist_ok=True)
|
||||
index_marker.touch()
|
||||
logger.info("")
|
||||
logger.info("✓ Documentation indexed successfully!")
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error("")
|
||||
logger.error(f"⚠ Warning: Documentation indexing failed: {e}")
|
||||
logger.error(e.stdout)
|
||||
logger.error(e.stderr)
|
||||
logger.error(" The chat service will still start but won't have access to indexed documentation.")
|
||||
else:
|
||||
logger.info(f"✓ Vector store already initialized (marker: {index_marker})")
|
||||
logger.info(" To re-index, delete the volume: docker volume rm datacenter-docs-chat-data-dev")
|
||||
|
||||
logger.info("")
|
||||
logger.info("=" * 50)
|
||||
logger.info("Starting Chat Server")
|
||||
logger.info("=" * 50)
|
||||
logger.info("Listening on port 8001...")
|
||||
logger.info("")
|
||||
|
||||
# Start the chat server by importing and running it
|
||||
# This keeps everything in the same process
|
||||
os.chdir("/app")
|
||||
sys.path.insert(0, "/app/src")
|
||||
|
||||
from datacenter_docs.chat import main as chat_main
|
||||
|
||||
# Run the chat server
|
||||
import uvicorn
|
||||
from datacenter_docs.chat.main import socket_app
|
||||
|
||||
uvicorn.run(socket_app, host="0.0.0.0", port=8001)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user