Second-Me/scripts/start_local.sh
ryangyuan 9fe511f0f2
Feature/0416/add thinking mode (#264)
* fix: modify thinking_model loading configuration

* feat: realize thinkModel ui

* feat:store

* feat: add combined_llm_config_dto

* add thinking_model_config & database migration

* directly add thinking model to user_llm_config

* delete thinking model repo dto service

* delete thinkingmodel table migration

* add is_cot config

* feat: allow define  is_cot

* feat: simplify logs info

* feat: add training model

* feat: fix is_cot problem

* fix: fix chat message

* fix: fix progress error

* fix: disable no settings thinking

* feat: add thinking warning

* fix: fix start service error

* feat:fix init trainparams problem

* feat: change playGround prompt

* feat: Add Dimension Mismatch Handling for ChromaDB (#157) (#207)

* Fix Issue #157

Add chroma_utils.py to manage chromaDB and added docs for explanation

* Add logging and debugging process

- Enhanced the`reinitialize_chroma_collections` function in`chroma_utils.py` to properly check if collections exist before attempting to delete them, preventing potential errors when collections don't exist.
- Improved error handling in the`_handle_dimension_mismatch` method in`embedding_service.py` by adding more robust exception handling and verification steps after reinitialization.
- Enhanced the collection initialization process in`embedding_service.py` to provide more detailed error messages and better handle cases where collections still have incorrect dimensions after reinitialization.
- Added additional verification steps to ensure that collection dimensions match the expected dimension after creation or retrieval.
- Improved logging throughout the code to provide more context in error messages, making debugging easier.

* Change topics_generator timeout to 30 (#263)

* quick fix

* fix: shade -> shade_merge_info (#265)

* fix: shade -> shade_merge_info

* add convert array

* quick fix import error

* add log

* add heartbeat

* new strategy

* sse version

* add heartbeat

* zh to en

* optimize code

* quick fix convert function

* Feat/new branch management (#267)

* feat: new branch management

* feat: fix multi-upload

* optimize contribute management

---------

Co-authored-by: Crabboss Mr <1123357821@qq.com>
Co-authored-by: Ye Xiangle <yexiangle@mail.mindverse.ai>
Co-authored-by: Xinghan Pan <sampan090611@gmail.com>
Co-authored-by: doubleBlack2 <108928143+doubleBlack2@users.noreply.github.com>
Co-authored-by: kevin-mindverse <kevin@mindverse.ai>
Co-authored-by: KKKKKKKevin <115385420+kevin-mindverse@users.noreply.github.com>
2025-04-24 14:19:23 +08:00

96 lines
3.3 KiB
Bash
Executable file

#!/bin/bash
# Source the logging utilities
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/utils/logging.sh"
# Activate Poetry virtual environment if available (but only if not already activated)
log_info "Setting up Python environment..."
# Check if Python environment is already activated by looking for specific environment markers
if [[ "$VIRTUAL_ENV" != "" ]]; then
log_info "Python virtual environment already activated: $VIRTUAL_ENV"
else
POETRY_ENV_PATH=""
if command -v poetry &>/dev/null; then
POETRY_ENV_PATH=$(poetry env info -p 2>/dev/null)
if [ -n "$POETRY_ENV_PATH" ] && [ -f "$POETRY_ENV_PATH/bin/activate" ]; then
log_info "Activating Poetry virtual environment: $POETRY_ENV_PATH"
source "$POETRY_ENV_PATH/bin/activate"
else
# Try using the local activation script if it exists
if [ -f ".poetry-venv/activate" ]; then
log_info "Activating Poetry environment via local script"
source ".poetry-venv/activate"
else
log_warning "Poetry environment not found. Some dependencies might be missing."
fi
fi
else
log_warning "Poetry is not installed. Some dependencies might be missing."
fi
fi
# Set environment variables
log_info "Setting environment variables..."
export PYTHONPATH=$(pwd):${PYTHONPATH}
# Load environment variables from .env file
set -a
source .env
set +a
# Use local base directory
export BASE_DIR=${LOCAL_BASE_DIR}
# Ensure using the correct Python environment
log_info "Checking Python environment..."
PYTHON_PATH=$(which python)
log_info "Using Python: $PYTHON_PATH"
PYTHON_VERSION=$(python --version)
log_info "Python version: $PYTHON_VERSION"
# Check necessary Python packages
log_info "Checking necessary Python packages..."
python -c "import flask" || { log_error "Error: Missing flask package"; exit 1; }
python -c "import chromadb" || { log_error "Error: Missing chromadb package"; exit 1; }
# Initialize database
log_info "Initializing database..."
SQLITE_DB_PATH="${BASE_DIR}/data/sqlite/lpm.db"
mkdir -p "${BASE_DIR}/data/sqlite"
if [ ! -f "$SQLITE_DB_PATH" ]; then
log_info "Initializing database..."
cat docker/sqlite/init.sql | sqlite3 "$SQLITE_DB_PATH"
log_success "Database initialization completed"
else
log_info "Database already exists"
fi
# Ensure necessary directories exist
log_info "Checking necessary directories..."
mkdir -p ${BASE_DIR}/data/chroma_db
mkdir -p ${LOCAL_LOG_DIR}
#mkdir -p ${BASE_DIR}/raw_content
#mkdir -p ${BASE_DIR}/data_pipeline
# Initialize ChromaDB
log_info "Initializing ChromaDB..."
python docker/app/init_chroma.py
# Get local IP address (excluding localhost and docker networks)
LOCAL_IP=$(ifconfig | grep "inet " | grep -v "127.0.0.1" | grep "192.168" | awk '{print $2}' | head -n 1)
# Run database migrations first
log_info "Running database migrations..."
python scripts/run_migrations.py
# Start Flask application
log_info "Starting Flask application..."
log_info "Application will run at the following addresses:"
log_info "- Local access: http://localhost:${LOCAL_APP_PORT}"
log_info "- LAN access: http://${LOCAL_IP}:${LOCAL_APP_PORT}"
# Output logs to file
exec python -m flask run --host=0.0.0.0 --port=${LOCAL_APP_PORT} >> "${LOCAL_LOG_DIR}/backend.log" 2>&1