mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-16 22:51:24 +00:00
feat: Add examples and modify deploy documents
This commit is contained in:
68
scripts/examples/load_examples.bat
Normal file
68
scripts/examples/load_examples.bat
Normal file
@@ -0,0 +1,68 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
:: Get script location and set working directory
|
||||
for %%i in (%0) do set SCRIPT_LOCATION=%%~dpi
|
||||
cd %SCRIPT_LOCATION%
|
||||
cd ..
|
||||
cd ..
|
||||
set WORK_DIR=%CD%
|
||||
|
||||
:: Check if sqlite3 is installed
|
||||
where sqlite3 >nul 2>nul
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo sqlite3 not found, please install sqlite3
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Default file paths
|
||||
set DEFAULT_DB_FILE=DB-GPT\pilot\data\default_sqlite.db
|
||||
set DEFAULT_SQL_FILE=DB-GPT\docker\examples\sqls\*_sqlite.sql
|
||||
set DB_FILE=%WORK_DIR%\pilot\data\default_sqlite.db
|
||||
set SQL_FILE=
|
||||
|
||||
:argLoop
|
||||
if "%1"=="" goto argDone
|
||||
if "%1"=="-d" goto setDBFile
|
||||
if "%1"=="--db-file" goto setDBFile
|
||||
if "%1"=="-f" goto setSQLFile
|
||||
if "%1"=="--sql-file" goto setSQLFile
|
||||
if "%1"=="-h" goto printUsage
|
||||
if "%1"=="--help" goto printUsage
|
||||
goto argError
|
||||
|
||||
:setDBFile
|
||||
shift
|
||||
set DB_FILE=%1
|
||||
shift
|
||||
goto argLoop
|
||||
|
||||
:setSQLFile
|
||||
shift
|
||||
set SQL_FILE=%1
|
||||
shift
|
||||
goto argLoop
|
||||
|
||||
:argError
|
||||
echo Invalid argument: %1
|
||||
goto printUsage
|
||||
|
||||
:printUsage
|
||||
echo USAGE: %0 [--db-file sqlite db file] [--sql-file sql file path to run]
|
||||
echo [-d|--db-file sqlite db file path] default: %DEFAULT_DB_FILE%
|
||||
echo [-f|--sql-file sqlite file to run] default: %DEFAULT_SQL_FILE%
|
||||
echo [-h|--help] Usage message
|
||||
exit /b 0
|
||||
|
||||
:argDone
|
||||
|
||||
if "%SQL_FILE%"=="" (
|
||||
if not exist "%WORK_DIR%\pilot\data" mkdir "%WORK_DIR%\pilot\data"
|
||||
for %%f in (%WORK_DIR%\docker\examples\sqls\*_sqlite.sql) do (
|
||||
echo execute sql file: %%f
|
||||
sqlite3 "%DB_FILE%" < "%%f"
|
||||
)
|
||||
) else (
|
||||
echo Execute SQL file %SQL_FILE%
|
||||
sqlite3 "%DB_FILE%" < "%SQL_FILE%"
|
||||
)
|
69
scripts/examples/load_examples.sh
Executable file
69
scripts/examples/load_examples.sh
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
# Only support SQLite now
|
||||
|
||||
SCRIPT_LOCATION=$0
|
||||
cd "$(dirname "$SCRIPT_LOCATION")"
|
||||
WORK_DIR=$(pwd)
|
||||
WORK_DIR="$WORK_DIR/../.."
|
||||
|
||||
if ! command -v sqlite3 > /dev/null 2>&1
|
||||
then
|
||||
echo "sqlite3 not found, please install sqlite3"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEFAULT_DB_FILE="DB-GPT/pilot/data/default_sqlite.db"
|
||||
DEFAULT_SQL_FILE="DB-GPT/docker/examples/sqls/*_sqlite.sql"
|
||||
DB_FILE="$WORK_DIR/pilot/data/default_sqlite.db"
|
||||
SQL_FILE=""
|
||||
|
||||
usage () {
|
||||
echo "USAGE: $0 [--db-file sqlite db file] [--sql-file sql file path to run]"
|
||||
echo " [-d|--db-file sqlite db file path] default: ${DEFAULT_DB_FILE}"
|
||||
echo " [-f|--sql-file sqlte file to run] default: ${DEFAULT_SQL_FILE}"
|
||||
echo " [-h|--help] Usage message"
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
case $key in
|
||||
-d|--db-file)
|
||||
DB_FILE="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
-f|--sql-file)
|
||||
SQL_FILE="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
help="true"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $help ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n $SQL_FILE ];then
|
||||
mkdir -p $WORK_DIR/pilot/data
|
||||
for file in $WORK_DIR/docker/examples/sqls/*_sqlite.sql
|
||||
do
|
||||
echo "execute sql file: $file"
|
||||
sqlite3 $DB_FILE < "$file"
|
||||
done
|
||||
|
||||
else
|
||||
echo "Execute SQL file ${SQL_FILE}"
|
||||
sqlite3 $DB_FILE < $SQL_FILE
|
||||
fi
|
||||
|
||||
|
47
scripts/llama_cpp_install.sh
Executable file
47
scripts/llama_cpp_install.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get cuda version by torch
|
||||
CUDA_VERSION=`python -c "import torch;print(torch.version.cuda.replace('.', '') if torch.cuda.is_available() else '')"`
|
||||
|
||||
DEVICE="cpu"
|
||||
CPU_OPT="basic"
|
||||
|
||||
if [ "${CUDA_VERSION}" = "" ]; then
|
||||
echo "CUDA not support, use cpu version"
|
||||
else
|
||||
DEVICE="cu${CUDA_VERSION//./}"
|
||||
echo "CUDA version: $CUDA_VERSION, download path: $DEVICE"
|
||||
fi
|
||||
|
||||
echo "Checking CPU support:"
|
||||
CPU_SUPPORT=$(lscpu)
|
||||
|
||||
echo "$CPU_SUPPORT" | grep -q "avx "
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "CPU supports AVX."
|
||||
# CPU_OPT="AVX"
|
||||
# TODO AVX will failed on my cpu
|
||||
else
|
||||
echo "CPU does not support AVX."
|
||||
fi
|
||||
|
||||
echo "$CPU_SUPPORT" | grep -q "avx2"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "CPU supports AVX2."
|
||||
CPU_OPT="AVX2"
|
||||
else
|
||||
echo "CPU does not support AVX2."
|
||||
fi
|
||||
|
||||
echo "$CPU_SUPPORT" | grep -q "avx512"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "CPU supports AVX512."
|
||||
CPU_OPT="AVX512"
|
||||
else
|
||||
echo "CPU does not support AVX512."
|
||||
fi
|
||||
|
||||
EXTRA_INDEX_URL="https://jllllll.github.io/llama-cpp-python-cuBLAS-wheels/$CPU_OPT/$DEVICE"
|
||||
|
||||
echo "install llama-cpp-python from --extra-index-url ${EXTRA_INDEX_URL}"
|
||||
python -m pip install llama-cpp-python --force-reinstall --no-cache --prefer-binary --extra-index-url=$EXTRA_INDEX_URL
|
Reference in New Issue
Block a user