11@ echo off
22
33set " TEMP = C:\Users\%UserName% \AppData\Local\Temp"
4- set " MODEL_PATH = %TEMP% \testllm"
4+ set " MODEL_LLM_PATH = %TEMP% \testllm"
5+ set " MODEL_EMBEDDING_PATH = %TEMP% \test-embedding"
56
67rem Check for required arguments
7- if " %~2 " == " " (
8- echo Usage: %~0 ^ < path_to_binary^ > ^ < url_to_download ^ >
8+ if " %~3 " == " " (
9+ echo Usage: %~0 ^ < path_to_binary^ > ^ < url_to_download_llm ^ > ^ < url_to_download_embedding ^ >
910 exit /b 1
1011)
1112
1213set " BINARY_PATH = %~1 "
13- set " DOWNLOAD_URL = %~2 "
14+ set " DOWNLOAD_LLM_URL = %~2 "
15+ set " DOWNLOAD_EMBEDDING_URL = %~3 "
1416
1517for %%i in (" %BINARY_PATH% " ) do set " BINARY_NAME = %%~nxi "
1618
1719echo BINARY_NAME=%BINARY_NAME%
1820
1921del %TEMP% \response1.log 2 > nul
2022del %TEMP% \response2.log 2 > nul
23+ del %TEMP% \response3.log 2 > nul
24+ del %TEMP% \response4.log 2 > nul
25+ del %TEMP% \response5.log 2 > nul
2126del %TEMP% \nitro.log 2 > nul
2227
2328set /a min = 9999
@@ -46,33 +51,53 @@ if not defined pid (
4651rem Wait for a few seconds to let the server start
4752
4853rem Check if %TEMP%\testmodel exists, if not, download it
49- if not exist " %MODEL_PATH % " (
50- curl.exe --connect-timeout 300 %DOWNLOAD_URL % --output " %MODEL_PATH % "
54+ if not exist " %MODEL_LLM_PATH % " (
55+ curl.exe --connect-timeout 300 %DOWNLOAD_LLM_URL % --output " %MODEL_LLM_PATH % "
5156)
5257
53- rem Define JSON strings for curl data
54- call set " MODEL_PATH_STRING = %% MODEL_PATH:\=\\%% "
55- set " curl_data1 = {\" llama_model_path\" :\" %MODEL_PATH_STRING% \" }"
56- set " curl_data2 = {\" messages\" :[{\" content\" :\" Hello there\" ,\" role\" :\" assistant\" },{\" content\" :\" Write a long and sad story for me\" ,\" role\" :\" user\" }],\" stream\" :true,\" model\" :\" gpt-3.5-turbo\" ,\" max_tokens\" :50,\" stop\" :[\" hello\" ],\" frequency_penalty\" :0,\" presence_penalty\" :0,\" temperature\" :0.1}"
58+ if not exist " %MODEL_EMBEDDING_PATH% " (
59+ curl.exe --connect-timeout 300 %DOWNLOAD_EMBEDDING_URL% --output " %MODEL_EMBEDDING_PATH% "
60+ )
5761
58- rem Print the values of curl_data1 and curl_data2 for debugging
62+ rem Define JSON strings for curl data
63+ call set " MODEL_LLM_PATH_STRING = %% MODEL_LLM_PATH:\=\\%% "
64+ call set " MODEL_EMBEDDING_PATH_STRING = %% MODEL_EMBEDDING_PATH:\=\\%% "
65+ set " curl_data1 = {\" llama_model_path\" :\" %MODEL_LLM_PATH_STRING% \" }"
66+ set " curl_data2 = {\" messages\" :[{\" content\" :\" Hello there\" ,\" role\" :\" assistant\" },{\" content\" :\" Write a long and sad story for me\" ,\" role\" :\" user\" }],\" stream\" :false,\" model\" :\" gpt-3.5-turbo\" ,\" max_tokens\" :50,\" stop\" :[\" hello\" ],\" frequency_penalty\" :0,\" presence_penalty\" :0,\" temperature\" :0.1}"
67+ set " curl_data3 = {\" llama_model_path\" :\" %MODEL_LLM_PATH_STRING% \" }"
68+ set " curl_data4 = {\" llama_model_path\" :\" %MODEL_EMBEDDING_PATH_STRING% \" , \" embedding\" : true, \" model_type\" : \" embedding\" }"
69+ set " curl_data5 = {\" input\" : \" Hello\" , \" model\" : \" test-embedding\" , \" encoding_format\" : \" float\" }"
70+
71+ rem Print the values of curl_data for debugging
5972echo curl_data1=%curl_data1%
6073echo curl_data2=%curl_data2%
74+ echo curl_data3=%curl_data3%
75+ echo curl_data4=%curl_data4%
76+ echo curl_data5=%curl_data5%
6177
6278rem Run the curl commands and capture the status code
6379curl.exe --connect-timeout 60 -o " %TEMP% \response1.log" -s -w " %% {http_code}" --location " http://127.0.0.1:%PORT% /inferences/llamacpp/loadModel" --header " Content-Type: application/json" --data " %curl_data1% " > %TEMP% \response1.log 2 >& 1
6480
6581curl.exe --connect-timeout 60 -o " %TEMP% \response2.log" -s -w " %% {http_code}" --location " http://127.0.0.1:%PORT% /inferences/llamacpp/chat_completion" ^
6682--header " Content-Type: application/json" ^
67- --header " Accept: text/event-stream" ^
68- --header " Access-Control-Allow-Origin: *" ^
6983--data " %curl_data2% " > %TEMP% \response2.log 2 >& 1
7084
85+ curl.exe --connect-timeout 60 -o " %TEMP% \response3.log" --request GET -s -w " %% {http_code}" --location " http://127.0.0.1:%PORT% /inferences/llamacpp/unloadModel" --header " Content-Type: application/json" --data " %curl_data3% " > %TEMP% \response3.log 2 >& 1
86+
87+ curl.exe --connect-timeout 60 -o " %TEMP% \response4.log" --request POST -s -w " %% {http_code}" --location " http://127.0.0.1:%PORT% /inferences/llamacpp/loadModel" --header " Content-Type: application/json" --data " %curl_data4% " > %TEMP% \response4.log 2 >& 1
88+
89+ curl.exe --connect-timeout 60 -o " %TEMP% \response5.log" -s -w " %% {http_code}" --location " http://127.0.0.1:%PORT% /v1/embeddings" ^
90+ --header " Content-Type: application/json" ^
91+ --data " %curl_data5% " > %TEMP% \response5.log 2 >& 1
92+
7193set " error_occurred = 0"
7294
7395rem Read the status codes from the log files
7496for /f %%a in (%TEMP% \response1.log) do set " response1 = %%a "
7597for /f %%a in (%TEMP% \response2.log) do set " response2 = %%a "
98+ for /f %%a in (%TEMP% \response3.log) do set " response3 = %%a "
99+ for /f %%a in (%TEMP% \response4.log) do set " response4 = %%a "
100+ for /f %%a in (%TEMP% \response5.log) do set " response5 = %%a "
76101
77102if " %response1% " neq " 200" (
78103 echo The first curl command failed with status code: %response1%
@@ -86,6 +111,24 @@ if "%response2%" neq "200" (
86111 set " error_occurred = 1"
87112)
88113
114+ if " %response3% " neq " 200" (
115+ echo The third curl command failed with status code: %response3%
116+ type %TEMP% \response3.log
117+ set " error_occurred = 1"
118+ )
119+
120+ if " %response4% " neq " 200" (
121+ echo The fourth curl command failed with status code: %response4%
122+ type %TEMP% \response4.log
123+ set " error_occurred = 1"
124+ )
125+
126+ if " %response5% " neq " 200" (
127+ echo The fifth curl command failed with status code: %response5%
128+ type %TEMP% \response5.log
129+ set " error_occurred = 1"
130+ )
131+
89132if " %error_occurred% " == " 1" (
90133 echo Nitro test run failed!!!!!!!!!!!!!!!!!!!!!!
91134 echo Nitro Error Logs:
@@ -96,13 +139,25 @@ if "%error_occurred%"=="1" (
96139
97140
98141echo ----------------------
99- echo Log load model:
142+ echo Log load llm model:
100143type %TEMP% \response1.log
101144
102145echo ----------------------
103- echo " Log run test:"
146+ echo Log run test:
104147type %TEMP% \response2.log
105148
149+ echo ----------------------
150+ echo Log unload model:
151+ type %TEMP% \response3.log
152+
153+ echo ----------------------
154+ echo Log load embedding model:
155+ type %TEMP% \response3.log
156+
157+ echo ----------------------
158+ echo Log run embedding test:
159+ type %TEMP% \response5.log
160+
106161echo Nitro test run successfully!
107162
108163rem Kill the server process
0 commit comments