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,56 @@ 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% "
56+ )
57+
58+ if not exist " %MODEL_EMBEDDING_PATH% " (
59+ curl.exe --connect-timeout 300 %DOWNLOAD_EMBEDDING_URL% --output " %MODEL_EMBEDDING_PATH% "
5160)
5261
5362rem Define JSON strings for curl data
54- call set " MODEL_PATH_STRING = %% MODEL_PATH:\=\\%% "
55- set " curl_data1 = {\" llama_model_path\" :\" %MODEL_PATH_STRING% \" }"
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% \" }"
5666set " 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}"
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\" }"
5770
58- rem Print the values of curl_data1 and curl_data2 for debugging
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+ rem give it some time to receive full response
86+ timeout /t 5
87+
88+ 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
89+
90+ 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
91+
92+ curl.exe --connect-timeout 60 -o " %TEMP% \response5.log" -s -w " %% {http_code}" --location " http://127.0.0.1:%PORT% /v1/embeddings" ^
93+ --header " Content-Type: application/json" ^
94+ --data " %curl_data5% " > %TEMP% \response5.log 2 >& 1
95+
7196set " error_occurred = 0"
7297
7398rem Read the status codes from the log files
7499for /f %%a in (%TEMP% \response1.log) do set " response1 = %%a "
75100for /f %%a in (%TEMP% \response2.log) do set " response2 = %%a "
101+ for /f %%a in (%TEMP% \response3.log) do set " response3 = %%a "
102+ for /f %%a in (%TEMP% \response4.log) do set " response4 = %%a "
103+ for /f %%a in (%TEMP% \response5.log) do set " response5 = %%a "
76104
77105if " %response1% " neq " 200" (
78106 echo The first curl command failed with status code: %response1%
@@ -86,6 +114,24 @@ if "%response2%" neq "200" (
86114 set " error_occurred = 1"
87115)
88116
117+ if " %response3% " neq " 200" (
118+ echo The third curl command failed with status code: %response3%
119+ type %TEMP% \response3.log
120+ set " error_occurred = 1"
121+ )
122+
123+ if " %response4% " neq " 200" (
124+ echo The fourth curl command failed with status code: %response4%
125+ type %TEMP% \response4.log
126+ set " error_occurred = 1"
127+ )
128+
129+ if " %response5% " neq " 200" (
130+ echo The fifth curl command failed with status code: %response5%
131+ type %TEMP% \response5.log
132+ set " error_occurred = 1"
133+ )
134+
89135if " %error_occurred% " == " 1" (
90136 echo Nitro test run failed!!!!!!!!!!!!!!!!!!!!!!
91137 echo Nitro Error Logs:
@@ -96,13 +142,25 @@ if "%error_occurred%"=="1" (
96142
97143
98144echo ----------------------
99- echo Log load model:
145+ echo Log load llm model:
100146type %TEMP% \response1.log
101147
102148echo ----------------------
103- echo " Log run test:"
149+ echo Log run test:
104150type %TEMP% \response2.log
105151
152+ echo ----------------------
153+ echo Log unload model:
154+ type %TEMP% \response3.log
155+
156+ echo ----------------------
157+ echo Log load embedding model:
158+ type %TEMP% \response3.log
159+
160+ echo ----------------------
161+ echo Log run embedding test:
162+ type %TEMP% \response5.log
163+
106164echo Nitro test run successfully!
107165
108166rem Kill the server process
0 commit comments