mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 11:07:06 +00:00
(improvement)(project) rename llm to llmParser and optimizing python start scripts and optimizing and optimizing build/start scripts (#91)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# pip path
|
||||
pip_path="/usr/local/bin/pip3"
|
||||
|
||||
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
||||
runtimeDir=$baseDir/runtime
|
||||
@@ -14,7 +17,9 @@ rm -fr dist
|
||||
mvn -f $baseDir/../ clean package -DskipTests
|
||||
|
||||
#2. move package to build
|
||||
cp $baseDir/../launchers/standalone/target/*.tar.gz ${buildDir}/supersonic.tar.gz
|
||||
cp $baseDir/../launchers/semantic/target/*.tar.gz ${buildDir}/supersonic-semantic.tar.gz
|
||||
cp $baseDir/../launchers/chat/target/*.tar.gz ${buildDir}/supersonic-chat.tar.gz
|
||||
cp $baseDir/../launchers/standalone/target/*.tar.gz ${buildDir}/supersonic-standalone.tar.gz
|
||||
|
||||
#3. build frontend webapp
|
||||
chmod +x $baseDir/../webapp/start-fe-prod.sh
|
||||
@@ -27,3 +32,8 @@ cd $buildDir
|
||||
tar xvf supersonic-webapp.tar.gz
|
||||
mv supersonic-webapp webapp
|
||||
mv webapp ../../launchers/standalone/target/classes
|
||||
|
||||
#5. build backend python modules
|
||||
requirementPath=$baseDir/../chat/core/src/main/python/requirements.txt
|
||||
${pip_path} install -r ${requirementPath}
|
||||
echo "install python modules success"
|
||||
@@ -1,5 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
python_path="/usr/local/bin/python3"
|
||||
readonly CHAT_APP_NAME="supersonic_chat"
|
||||
readonly SEMANTIC_APP_NAME="supersonic_semantic"
|
||||
readonly LLMPARSER_APP_NAME="supersonic_llmparser"
|
||||
readonly STANDALONE_APP_NAME="supersonic_standalone"
|
||||
readonly CHAT_SERVICE="chat"
|
||||
readonly SEMANTIC_SERVICE="semantic"
|
||||
readonly LLMPARSER_SERVICE="llmparser"
|
||||
readonly STANDALONE_SERVICE="standalone"
|
||||
|
||||
sbinDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
||||
runtimeDir=$baseDir/../runtime
|
||||
@@ -8,91 +18,203 @@ buildDir=$baseDir/build
|
||||
command=$1
|
||||
service=$2
|
||||
|
||||
if [ -z "$service" ]; then
|
||||
service=${STANDALONE_SERVICE}
|
||||
fi
|
||||
|
||||
app_name=$STANDALONE_APP_NAME
|
||||
main_class="com.tencent.supersonic.StandaloneLauncher"
|
||||
model_name=$service
|
||||
|
||||
if [ "$service" == "llmparser" ]; then
|
||||
model_name=${STANDALONE_SERVICE}
|
||||
fi
|
||||
|
||||
cd $baseDir
|
||||
if [[ "$service" == "semantic" || -z "$service" ]] && [ "$command" != "stop" ]; then
|
||||
#1. clear file
|
||||
mkdir -p ${runtimeDir}
|
||||
rm -fr ${runtimeDir}/*
|
||||
|
||||
#2. package lib
|
||||
tar -zxvf ${buildDir}/supersonic.tar.gz -C ${runtimeDir}
|
||||
mv ${runtimeDir}/launchers-standalone-* ${runtimeDir}/supersonic-standalone
|
||||
tar -zxvf ${buildDir}/supersonic-webapp.tar.gz -C ${buildDir}
|
||||
mkdir -p ${runtimeDir}/supersonic-standalone/webapp
|
||||
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-standalone/webapp
|
||||
rm -fr ${buildDir}/supersonic-webapp
|
||||
fi
|
||||
if [[ "$service" == "semantic" ]]; then
|
||||
json=$(cat ${runtimeDir}/supersonic-semantic/webapp/supersonic.config.json)
|
||||
json=$(echo $json | jq '.env="semantic"')
|
||||
echo $json > ${runtimeDir}/supersonic-semantic/webapp/supersonic.config.json
|
||||
fi
|
||||
function setMainClass {
|
||||
if [ "$service" == $CHAT_SERVICE ]; then
|
||||
main_class="com.tencent.supersonic.ChatLauncher"
|
||||
elif [ "$service" == $SEMANTIC_SERVICE ]; then
|
||||
main_class="com.tencent.supersonic.SemanticLauncher"
|
||||
fi
|
||||
}
|
||||
|
||||
function setAppName {
|
||||
if [ "$service" == $CHAT_SERVICE ]; then
|
||||
app_name=$CHAT_APP_NAME
|
||||
elif [ "$service" == $SEMANTIC_SERVICE ]; then
|
||||
app_name=$SEMANTIC_APP_NAME
|
||||
elif [ "$service" == $LLMPARSER_SERVICE ]; then
|
||||
app_name=$LLMPARSER_APP_NAME
|
||||
fi
|
||||
}
|
||||
|
||||
function setEnvToWeb {
|
||||
if [[ "$service" == $CHAT_SERVICE || "$service" == $SEMANTIC_SERVICE ]]; then
|
||||
json='{"env": "'$service'"}'
|
||||
echo $json > ${runtimeDir}/supersonic-${model_name}/webapp/supersonic.config.json
|
||||
fi
|
||||
}
|
||||
|
||||
function resetEnvironment {
|
||||
if [[ "$command" == "start" || "$command" == "restart" ]]; then
|
||||
#1. clear file
|
||||
mkdir -p ${runtimeDir}
|
||||
rm -fr ${runtimeDir}/supersonic-${model_name}
|
||||
#2. package lib
|
||||
tar -zxvf ${buildDir}/supersonic-${model_name}.tar.gz -C ${runtimeDir}
|
||||
mv ${runtimeDir}/launchers-${model_name}-* ${runtimeDir}/supersonic-${model_name}
|
||||
|
||||
tar -zxvf ${buildDir}/supersonic-webapp.tar.gz -C ${buildDir}
|
||||
mkdir -p ${runtimeDir}/supersonic-${model_name}/webapp
|
||||
cp -fr ${buildDir}/supersonic-webapp/* ${runtimeDir}/supersonic-${model_name}/webapp
|
||||
rm -fr ${buildDir}/supersonic-webapp
|
||||
fi
|
||||
}
|
||||
|
||||
setAppName
|
||||
resetEnvironment
|
||||
setEnvToWeb
|
||||
setMainClass
|
||||
|
||||
function runJavaService {
|
||||
javaRunDir=${runtimeDir}/supersonic-${model_name}
|
||||
local_app_name=$1
|
||||
libDir=$javaRunDir/lib
|
||||
confDir=$javaRunDir/conf
|
||||
|
||||
CLASSPATH=""
|
||||
CLASSPATH=$CLASSPATH:$confDir
|
||||
|
||||
for jarPath in $libDir/*.jar; do
|
||||
CLASSPATH=$CLASSPATH:$jarPath
|
||||
done
|
||||
|
||||
export CLASSPATH
|
||||
export LANG="zh_CN.UTF-8"
|
||||
|
||||
cd $javaRunDir
|
||||
if [[ "$JAVA_HOME" == "" ]]; then
|
||||
JAVA_HOME=$(ls /usr/jdk64/jdk* -d 2>/dev/null | xargs | awk '{print "'$local_app_name'"}')
|
||||
fi
|
||||
export PATH=$JAVA_HOME/bin:$PATH
|
||||
command="-Dfile.encoding="UTF-8" -Duser.language="Zh" -Duser.region="CN" -Duser.timezone="GMT+08" -Dapp_name=${local_app_name} -Xms1024m -Xmx2048m "$main_class
|
||||
|
||||
mkdir -p $javaRunDir/logs
|
||||
if [[ "$is_test" == "true" ]]; then
|
||||
java -Dspring.profiles.active="dev" $command >/dev/null 2>$javaRunDir/logs/error.log &
|
||||
else
|
||||
java $command $javaRunDir >/dev/null 2>$javaRunDir/logs/error.log &
|
||||
fi
|
||||
}
|
||||
|
||||
function runPythonService {
|
||||
pythonRunDir=${runtimeDir}/supersonic-${model_name}/llmparser
|
||||
cd $pythonRunDir
|
||||
nohup ${python_path} supersonic_llmparser.py > $pythonRunDir/llmparser.log 2>&1 &
|
||||
sleep 4
|
||||
}
|
||||
|
||||
function reloadExamples {
|
||||
pythonRunDir=${runtimeDir}/supersonic-${model_name}/llmparser
|
||||
cd $pythonRunDir/sql
|
||||
${python_path} examples_reload_run.py
|
||||
}
|
||||
|
||||
function getProcesName {
|
||||
process_name=$main_class
|
||||
if [[ ${app_name} == $LLMPARSER_APP_NAME ]]; then
|
||||
process_name=$app_name
|
||||
fi
|
||||
echo $process_name
|
||||
}
|
||||
|
||||
function start()
|
||||
{
|
||||
local_app_name=$1
|
||||
pid=$(ps aux |grep ${local_app_name} | grep -v grep | awk '{print $2}')
|
||||
if [[ "$pid" == "" ]]; then
|
||||
if [[ ${local_app_name} == $LLMPARSER_APP_NAME ]]; then
|
||||
runPythonService ${local_app_name}
|
||||
else
|
||||
runJavaService ${local_app_name}
|
||||
fi
|
||||
else
|
||||
echo "Process (PID = $pid) is running."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function stop()
|
||||
{
|
||||
pid=$(ps aux | grep $1 | grep -v grep | awk '{print $2}')
|
||||
if [[ "$pid" == "" ]]; then
|
||||
echo "Process $1 is not running !"
|
||||
return 1
|
||||
else
|
||||
kill -9 $pid
|
||||
echo "Process (PID = $pid) is killed !"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
function reload()
|
||||
{
|
||||
if [[ $1 == $LLMPARSER_APP_NAME ]]; then
|
||||
reloadExamples
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "$service" == "chat" ]]; then
|
||||
json=$(cat ${runtimeDir}/supersonic-chat/webapp/supersonic.config.json)
|
||||
json=$(echo $json | jq '.env="chat"')
|
||||
echo $json > ${runtimeDir}/supersonic-chat/webapp/supersonic.config.json
|
||||
fi
|
||||
echo $command
|
||||
echo $service
|
||||
case "$command" in
|
||||
start)
|
||||
if [[ "$service" == "semantic" ]];then
|
||||
echo -e "Starting semantic java service"
|
||||
sh ${runtimeDir}/supersonic-semantic/bin/service.sh start
|
||||
elif [[ "$service" == "chat" ]];then
|
||||
echo -e "Starting chat java service"
|
||||
sh ${runtimeDir}/supersonic-chat/bin/service.sh start
|
||||
elif [[ "$service" == "llmparser" ]];then
|
||||
echo -e "Starting llmparser python service"
|
||||
sh ${runtimeDir}/supersonic-standalone/llm/bin/service.sh start
|
||||
elif [[ -z "$service" ]]; then
|
||||
echo -e "Starting supersonic services"
|
||||
sh ${runtimeDir}/supersonic-standalone/bin/service.sh start
|
||||
sh ${runtimeDir}/supersonic-standalone/llm/bin/service.sh start
|
||||
if [ "$service" == $STANDALONE_SERVICE ]; then
|
||||
echo "Starting $LLMPARSER_APP_NAME"
|
||||
start $LLMPARSER_APP_NAME
|
||||
echo "Starting $app_name"
|
||||
start $app_name
|
||||
else
|
||||
echo "Use command {chat|semantic|llmparser} to run."
|
||||
echo "Starting $app_name"
|
||||
start $app_name
|
||||
fi
|
||||
echo "Start success"
|
||||
;;
|
||||
stop)
|
||||
if [[ "$service" == "semantic" ]];then
|
||||
echo -e "Stopping semantic java service"
|
||||
sh ${runtimeDir}/supersonic-semantic/bin/service.sh stop
|
||||
elif [[ "$service" == "chat" ]];then
|
||||
echo -e "Stopping chat java service"
|
||||
sh ${runtimeDir}/supersonic-chat/bin/service.sh stop
|
||||
elif [[ "$service" == "llmparser" ]];then
|
||||
echo -e "Stopping llmparser python service"
|
||||
sh ${runtimeDir}/supersonic-standalone/llm/bin/service.sh stop
|
||||
elif [[ -z "$service" ]]; then
|
||||
echo -e "Stopping supersonic services"
|
||||
sh ${runtimeDir}/supersonic-standalone/bin/service.sh stop
|
||||
sh ${runtimeDir}/supersonic-standalone/llm/bin/service.sh stop
|
||||
if [ "$service" == $STANDALONE_SERVICE ]; then
|
||||
echo "Stopping $LLMPARSER_APP_NAME"
|
||||
stop $LLMPARSER_APP_NAME
|
||||
echo "Stopping $app_name"
|
||||
stop $app_name
|
||||
else
|
||||
echo "Use command {chat|semantic|llmparser} to run."
|
||||
echo "Stopping $app_name"
|
||||
stop ${app_name}
|
||||
fi
|
||||
echo "Stop success"
|
||||
;;
|
||||
reload)
|
||||
echo "Reloading ${app_name}"
|
||||
reload ${app_name}
|
||||
echo "Reload success"
|
||||
;;
|
||||
restart)
|
||||
if [[ "$service" == "semantic" ]];then
|
||||
echo -e "Restarting semantic java service"
|
||||
sh ${runtimeDir}/supersonic-semantic/bin/service.sh restart
|
||||
elif [[ "$service" == "chat" ]];then
|
||||
echo -e "Restarting chat java service"
|
||||
sh ${runtimeDir}/supersonic-chat/bin/service.sh restart
|
||||
elif [[ "$service" == "llmparser" ]];then
|
||||
echo -e "Restarting llmparser python service"
|
||||
sh ${runtimeDir}/supersonic-standalone/llm/bin/service.sh restart
|
||||
elif [[ -z "$service" ]]; then
|
||||
echo -e "Restarting supersonic services"
|
||||
sh ${runtimeDir}/supersonic-standalone/bin/service.sh restart
|
||||
sh ${runtimeDir}/supersonic-standalone/llm/bin/service.sh restart
|
||||
if [ "$service" == $STANDALONE_SERVICE ]; then
|
||||
echo "Stopping ${app_name}"
|
||||
stop ${app_name}
|
||||
echo "Stopping ${LLMPARSER_APP_NAME}"
|
||||
stop $LLMPARSER_APP_NAME
|
||||
echo "Starting ${LLMPARSER_APP_NAME}"
|
||||
start $LLMPARSER_APP_NAME
|
||||
echo "Starting ${app_name}"
|
||||
start ${app_name}
|
||||
else
|
||||
echo "Use command {chat|semantic|llmparser} to run."
|
||||
echo "Stopping ${app_name}"
|
||||
stop ${app_name}
|
||||
echo "Starting ${app_name}"
|
||||
start ${app_name}
|
||||
fi
|
||||
echo "Restart success"
|
||||
;;
|
||||
*)
|
||||
echo "Use command {start|stop|status|restart} to run."
|
||||
echo "Use command {start|stop|restart} to run."
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit 0
|
||||
esac
|
||||
@@ -6,14 +6,6 @@
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<fileSets>
|
||||
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/src/main/bin</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<fileMode>0777</fileMode>
|
||||
<directoryMode>0755</directoryMode>
|
||||
</fileSet>
|
||||
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<outputDirectory>conf</outputDirectory>
|
||||
@@ -30,7 +22,7 @@
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/../../chat/core/src/main/python</directory>
|
||||
<outputDirectory>llm</outputDirectory>
|
||||
<outputDirectory>llmparser</outputDirectory>
|
||||
<fileMode>0777</fileMode>
|
||||
<directoryMode>0755</directoryMode>
|
||||
</fileSet>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# python path
|
||||
export python_path="/usr/local/bin/python3"
|
||||
# pip path
|
||||
export pip_path="/usr/local/bin/pip3"
|
||||
# host
|
||||
export llm_host="127.0.0.1"
|
||||
# port
|
||||
export llm_port=9092
|
||||
# start name
|
||||
export start_name=api_service
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
binDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$binDir/.." && pwd -P)
|
||||
echo $binDir
|
||||
|
||||
source ${binDir}/env.sh
|
||||
|
||||
${pip_path} install -r $baseDir/requirements.txt
|
||||
|
||||
if ${python_path} -c "import langchain,fastapi,chromadb,tiktoken,uvicorn" >/dev/null 2>&1
|
||||
then
|
||||
echo "install ok, will pass"
|
||||
else
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "install ok"
|
||||
else
|
||||
echo "install fail ,pls check your install error log. cmd is : "
|
||||
echo ${pip_path} install -r $baseDir/requirements.txt
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
llm_host=$1
|
||||
llm_port=$2
|
||||
|
||||
binDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$binDir/.." && pwd -P)
|
||||
|
||||
source ${baseDir}/bin/env.sh
|
||||
|
||||
if [ "${llm_host}" = "" ] || [ "${llm_port}" = "" ]
|
||||
then
|
||||
echo "llm_host llm_port is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ "${python_path}" = "" ] || [ "${pip_path}" = "" ]
|
||||
then
|
||||
echo "please set env value python_path , pip_path to python, pip path by export cmd "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chmod +x $binDir/install.sh
|
||||
$binDir/install.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd $baseDir/llm
|
||||
nohup ${python_path} -m uvicorn ${start_name}:app --port ${llm_port} --host ${llm_host} > $baseDir/llm.log 2>&1 &
|
||||
@@ -1,53 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
binDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$binDir/.." && pwd -P)
|
||||
source ${baseDir}/bin/env.sh
|
||||
|
||||
command=$1
|
||||
|
||||
function start()
|
||||
{
|
||||
pid=$(ps aux |grep ${start_name} | grep -v grep )
|
||||
if [[ "$pid" == "" ]]; then
|
||||
$baseDir/bin/run.sh && echo "Process started."
|
||||
return 0
|
||||
else
|
||||
echo "Process (PID = $pid) is running."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function stop()
|
||||
{
|
||||
pid=$(ps aux | grep ${start_name} | grep -v grep | awk '{print $2}')
|
||||
if [[ "$pid" == "" ]]; then
|
||||
echo "Process is not running !"
|
||||
return 1
|
||||
else
|
||||
kill -9 $pid
|
||||
echo "Process (PID = $pid) is killed !"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
case "$command" in
|
||||
start)
|
||||
echo -e "Starting ${start_name}"
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
echo -e "Stopping ${start_name}"
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
echo -e "Resetting ${start_name}E"
|
||||
stop
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo "Use command {start|stop|status|restart} to run."
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
llm_host=$1
|
||||
llm_port=$2
|
||||
|
||||
baseDir=$(cd "$binDir/.." && pwd -P)
|
||||
|
||||
cd $baseDir/llm/sql
|
||||
|
||||
${python_path} examples_reload_run.py ${llm_port} ${llm_host}
|
||||
|
||||
|
||||
|
||||
@@ -4,5 +4,4 @@ fastapi==0.95.1
|
||||
chromadb==0.3.21
|
||||
tiktoken==0.3.3
|
||||
uvicorn[standard]==0.21.1
|
||||
|
||||
|
||||
pandas==1.5.3
|
||||
@@ -3,6 +3,9 @@ import os
|
||||
|
||||
PROJECT_DIR_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
LLMPARSER_HOST = "127.0.0.1"
|
||||
LLMPARSER_PORT = 9092
|
||||
|
||||
MODEL_NAME = "gpt-3.5-turbo-16k"
|
||||
OPENAI_API_KEY = "YOUR_API_KEY"
|
||||
|
||||
@@ -20,4 +23,6 @@ HF_TEXT2VEC_MODEL_NAME = "GanymedeNil/text2vec-large-chinese"
|
||||
if __name__ == '__main__':
|
||||
print('PROJECT_DIR_PATH: ', PROJECT_DIR_PATH)
|
||||
print('EMB_MODEL_PATH: ', HF_TEXT2VEC_MODEL_NAME)
|
||||
print('CHROMA_DB_PERSIST_PATH: ', CHROMA_DB_PERSIST_PATH)
|
||||
print('CHROMA_DB_PERSIST_PATH: ', CHROMA_DB_PERSIST_PATH)
|
||||
print('LLMPARSER_HOST: ', LLMPARSER_HOST)
|
||||
print('LLMPARSER_PORT: ', LLMPARSER_PORT)
|
||||
@@ -10,11 +10,15 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from run_config import TEXT2DSL_FEW_SHOTS_EXAMPLE_NUM
|
||||
from few_shot_example.sql_exampler import examplars as sql_examplars
|
||||
from run_config import LLMPARSER_HOST
|
||||
from run_config import LLMPARSER_PORT
|
||||
|
||||
def text2dsl_setting_update(llm_host:str, llm_port:str,
|
||||
|
||||
def text2dsl_setting_update(llm_parser_host:str, llm_parser_port:str,
|
||||
sql_examplars:List[Mapping[str, str]], example_nums:int):
|
||||
|
||||
url = f"http://{llm_host}:{llm_port}/query2sql_setting_update/"
|
||||
url = f"http://{llm_parser_host}:{llm_parser_port}/query2sql_setting_update/"
|
||||
print("url: ", url)
|
||||
payload = {"sqlExamplars":sql_examplars, "exampleNums":example_nums}
|
||||
headers = {'content-type': 'application/json'}
|
||||
response = requests.post(url, data=json.dumps(payload), headers=headers)
|
||||
@@ -23,9 +27,5 @@ def text2dsl_setting_update(llm_host:str, llm_port:str,
|
||||
|
||||
if __name__ == "__main__":
|
||||
arguments = sys.argv
|
||||
|
||||
llm_host = str(arguments[1])
|
||||
llm_port = str(arguments[2])
|
||||
|
||||
text2dsl_setting_update(llm_host, llm_port,
|
||||
text2dsl_setting_update(LLMPARSER_HOST, LLMPARSER_PORT,
|
||||
sql_examplars, TEXT2DSL_FEW_SHOTS_EXAMPLE_NUM)
|
||||
@@ -2,6 +2,7 @@
|
||||
import os
|
||||
import logging
|
||||
import sys
|
||||
import uvicorn
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
@@ -20,9 +21,13 @@ from preset_retrieval.preset_query_db import (add2preset_query_collection, updat
|
||||
|
||||
from plugin_call.run import plugin_selection_run
|
||||
|
||||
from run_config import LLMPARSER_HOST
|
||||
from run_config import LLMPARSER_PORT
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
|
||||
@app.post("/query2sql/")
|
||||
async def din_query2sql(query_body: Mapping[str, Any]):
|
||||
if 'queryText' not in query_body:
|
||||
@@ -147,3 +152,6 @@ async def tool_selection(query_body: Mapping[str, Any]):
|
||||
resp = plugin_selection_run(query_text=query_text, plugin_configs=plugin_configs)
|
||||
|
||||
return resp
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(app, host=LLMPARSER_HOST, port=LLMPARSER_PORT)
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
export APP_NAME=supersonic-chat
|
||||
export MAIN_CLASS=com.tencent.supersonic.ChatLauncher
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
binDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
||||
libDir=$baseDir/lib
|
||||
confDir=$baseDir/conf
|
||||
webDir=$baseDir/webapp
|
||||
|
||||
source ${baseDir}/bin/env.sh
|
||||
|
||||
|
||||
CLASSPATH=""
|
||||
CLASSPATH=$CLASSPATH:$confDir
|
||||
|
||||
for jarPath in $libDir/*.jar; do
|
||||
CLASSPATH=$CLASSPATH:$jarPath
|
||||
done
|
||||
|
||||
|
||||
|
||||
export CLASSPATH
|
||||
export LANG="zh_CN.UTF-8"
|
||||
|
||||
cd $baseDir
|
||||
|
||||
if [[ "$JAVA_HOME" == "" ]]; then
|
||||
JAVA_HOME=$(ls /usr/jdk64/jdk* -d 2>/dev/null | xargs | awk '{print "'$APP_NAME'"}')
|
||||
fi
|
||||
export PATH=$JAVA_HOME/bin:$PATH
|
||||
|
||||
command="-Dfile.encoding="UTF-8" -Duser.language="Zh" -Duser.region="CN" -Duser.timezone="GMT+08" -Xms1024m -Xmx2048m "$MAIN_CLASS
|
||||
|
||||
mkdir -p $baseDir/logs
|
||||
if [[ "$is_test" == "true" ]]; then
|
||||
java -Dspring.profiles.active="dev" $command >/dev/null 2>$baseDir/logs/error.log &
|
||||
else
|
||||
java $command $baseDir >/dev/null 2>$baseDir/logs/error.log &
|
||||
fi
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
binDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$sbinDir/.." && pwd -P)
|
||||
confDir=$baseDir/conf
|
||||
source ${baseDir}/bin/env.sh
|
||||
|
||||
command=$1
|
||||
|
||||
function start()
|
||||
{
|
||||
pid=$(ps aux | grep $MAIN_CLASS | grep -v grep |grep $baseDir | awk '{print "'$APP_NAME'"}')
|
||||
if [[ "$pid" == "" ]]; then
|
||||
logs=$baseDir/logs/service.sh.log
|
||||
env DEPLOY=true $baseDir/bin/run.sh $MAIN_CLASS && echo "Process started, see logs/error with logs/error command"
|
||||
return 0
|
||||
else
|
||||
echo "Process (PID = $pid) is running."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function stop()
|
||||
{
|
||||
pid=$(ps aux | grep $MAIN_CLASS | grep -v grep|grep $baseDir| awk '{print $2}')
|
||||
if [[ "$pid" == "" ]]; then
|
||||
echo "Process is not running !"
|
||||
return 1
|
||||
else
|
||||
kill -9 $pid
|
||||
echo "Process (PID = $pid) is killed !"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
case "$command" in
|
||||
start)
|
||||
echo -e "Starting $APP_NAME"
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
echo -e "Stopping $APP_NAME"
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
echo -e "Resetting $APP_NAME"
|
||||
stop
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo "Use command {start|stop|status|restart} to run."
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -13,7 +13,7 @@ spring:
|
||||
password: chat
|
||||
|
||||
server:
|
||||
port: 9080
|
||||
port: 9082
|
||||
|
||||
authentication:
|
||||
enable: true
|
||||
|
||||
10
launchers/chat/src/main/resources/optimization.properties
Normal file
10
launchers/chat/src/main/resources/optimization.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
one.detection.size=8
|
||||
one.detection.max.size=20
|
||||
metric.dimension.min.threshold=0.3
|
||||
metric.dimension.threshold=0.3
|
||||
dimension.value.threshold=0.5
|
||||
function.bonus.threshold=201
|
||||
long.text.threshold=0.8
|
||||
short.text.threshold=0.5
|
||||
query.text.length.threshold=10
|
||||
candidate.threshold=0.2
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
export APP_NAME=supersonic-semantic
|
||||
export MAIN_CLASS=com.tencent.supersonic.SemanticLauncher
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
binDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$binDir/.." && pwd -P)
|
||||
libDir=$baseDir/lib
|
||||
confDir=$baseDir/conf
|
||||
webDir=$baseDir/webapp
|
||||
|
||||
source ${baseDir}/bin/env.sh
|
||||
|
||||
|
||||
CLASSPATH=""
|
||||
CLASSPATH=$CLASSPATH:$confDir
|
||||
|
||||
for jarPath in $libDir/*.jar; do
|
||||
CLASSPATH=$CLASSPATH:$jarPath
|
||||
done
|
||||
|
||||
|
||||
|
||||
export CLASSPATH
|
||||
export LANG="zh_CN.UTF-8"
|
||||
|
||||
cd $baseDir
|
||||
|
||||
if [[ "$JAVA_HOME" == "" ]]; then
|
||||
JAVA_HOME=$(ls /usr/jdk64/jdk* -d 2>/dev/null | xargs | awk '{print "'$APP_NAME'"}')
|
||||
fi
|
||||
export PATH=$JAVA_HOME/bin:$PATH
|
||||
|
||||
command="-Dfile.encoding="UTF-8" -Duser.language="Zh" -Duser.region="CN" -Duser.timezone="GMT+08" -Xms1024m -Xmx2048m "$MAIN_CLASS
|
||||
|
||||
mkdir -p $baseDir/logs
|
||||
if [[ "$is_test" == "true" ]]; then
|
||||
java -Dspring.profiles.active="dev" $command >/dev/null 2>$baseDir/logs/error.log &
|
||||
else
|
||||
java $command $baseDir >/dev/null 2>$baseDir/logs/error.log &
|
||||
fi
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
binDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$binDir/.." && pwd -P)
|
||||
confDir=$baseDir/conf
|
||||
source ${baseDir}/bin/env.sh
|
||||
|
||||
command=$1
|
||||
|
||||
function start()
|
||||
{
|
||||
pid=$(ps aux | grep $MAIN_CLASS | grep -v grep |grep $baseDir | awk '{print "'$APP_NAME'"}')
|
||||
if [[ "$pid" == "" ]]; then
|
||||
logs=$baseDir/logs/service.sh.log
|
||||
env DEPLOY=true $baseDir/bin/run.sh $MAIN_CLASS && echo "Process started, see logs/error with logs/error command"
|
||||
return 0
|
||||
else
|
||||
echo "Process (PID = $pid) is running."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function stop()
|
||||
{
|
||||
pid=$(ps aux | grep $MAIN_CLASS | grep -v grep|grep $baseDir| awk '{print $2}')
|
||||
if [[ "$pid" == "" ]]; then
|
||||
echo "Process is not running !"
|
||||
return 1
|
||||
else
|
||||
kill -9 $pid
|
||||
echo "Process (PID = $pid) is killed !"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
case "$command" in
|
||||
start)
|
||||
echo -e "Starting $APP_NAME"
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
echo -e "Stopping $APP_NAME"
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
echo -e "Resetting $APP_NAME"
|
||||
stop
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo "Use command {start|stop|status|restart} to run."
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
export APP_NAME=supersonic-standalone
|
||||
export MAIN_CLASS=com.tencent.supersonic.StandaloneLauncher
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
binDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$binDir/.." && pwd -P)
|
||||
libDir=$baseDir/lib
|
||||
confDir=$baseDir/conf
|
||||
webDir=$baseDir/webapp
|
||||
|
||||
source ${baseDir}/bin/env.sh
|
||||
|
||||
|
||||
CLASSPATH=""
|
||||
CLASSPATH=$CLASSPATH:$confDir
|
||||
|
||||
for jarPath in $libDir/*.jar; do
|
||||
CLASSPATH=$CLASSPATH:$jarPath
|
||||
done
|
||||
|
||||
|
||||
|
||||
export CLASSPATH
|
||||
export LANG="zh_CN.UTF-8"
|
||||
|
||||
cd $baseDir
|
||||
|
||||
if [[ "$JAVA_HOME" == "" ]]; then
|
||||
JAVA_HOME=$(ls /usr/jdk64/jdk* -d 2>/dev/null | xargs | awk '{print "'$APP_NAME'"}')
|
||||
fi
|
||||
export PATH=$JAVA_HOME/bin:$PATH
|
||||
|
||||
command="-Dfile.encoding="UTF-8" -Duser.language="Zh" -Duser.region="CN" -Duser.timezone="GMT+08" -Xms1024m -Xmx2048m "$MAIN_CLASS
|
||||
|
||||
mkdir -p $baseDir/logs
|
||||
if [[ "$is_test" == "true" ]]; then
|
||||
java -Dspring.profiles.active="dev" $command >/dev/null 2>$baseDir/logs/error.log &
|
||||
else
|
||||
java $command $baseDir >/dev/null 2>$baseDir/logs/error.log &
|
||||
fi
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
binDir=$(cd "$(dirname "$0")"; pwd)
|
||||
baseDir=$(cd "$binDir/.." && pwd -P)
|
||||
confDir=$baseDir/conf
|
||||
source ${baseDir}/bin/env.sh
|
||||
|
||||
command=$1
|
||||
|
||||
function start()
|
||||
{
|
||||
pid=$(ps aux | grep $MAIN_CLASS | grep -v grep |grep $baseDir | awk '{print "'$APP_NAME'"}')
|
||||
if [[ "$pid" == "" ]]; then
|
||||
logs=$baseDir/logs/service.sh.log
|
||||
env DEPLOY=true $baseDir/bin/run.sh $MAIN_CLASS && echo "Process started, see logs/error with logs/error command"
|
||||
return 0
|
||||
else
|
||||
echo "Process (PID = $pid) is running."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function stop()
|
||||
{
|
||||
pid=$(ps aux | grep $MAIN_CLASS | grep -v grep|grep $baseDir| awk '{print $2}')
|
||||
if [[ "$pid" == "" ]]; then
|
||||
echo "Process is not running !"
|
||||
return 1
|
||||
else
|
||||
kill -9 $pid
|
||||
echo "Process (PID = $pid) is killed !"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
case "$command" in
|
||||
start)
|
||||
echo -e "Starting $APP_NAME"
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
echo -e "Stopping $APP_NAME"
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
echo -e "Resetting $APP_NAME"
|
||||
stop
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo "Use command {start|stop|status|restart} to run."
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user