11@ echo off
22
33set " TEMP = C:\Users\%UserName% \AppData\Local\Temp"
4- set " MODEL_LLM_PATH = %TEMP% \testllm"
5- set " MODEL_EMBEDDING_PATH = %TEMP% \test-embedding"
4+ set " MODEL_PATH = %TEMP% \testllm"
65
76rem Check for required arguments
8- if " %~3 " == " " (
9- echo Usage: %~0 ^ < path_to_binary^ > ^ < url_to_download_llm ^ > ^ < url_to_download_embedding ^ >
7+ if " %~2 " == " " (
8+ echo Usage: %~0 ^ < path_to_binary^ > ^ < url_to_download ^ >
109 exit /b 1
1110)
1211
1312set " BINARY_PATH = %~1 "
14- set " DOWNLOAD_LLM_URL = %~2 "
15- set " DOWNLOAD_EMBEDDING_URL = %~3 "
13+ set " DOWNLOAD_URL = %~2 "
1614
1715for %%i in (" %BINARY_PATH% " ) do set " BINARY_NAME = %%~nxi "
1816
1917echo BINARY_NAME=%BINARY_NAME%
2018
2119del %TEMP% \response1.log 2 > nul
2220del %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
2621del %TEMP% \nitro.log 2 > nul
2722
2823set /a min = 9999
@@ -51,53 +46,33 @@ if not defined pid (
5146rem Wait for a few seconds to let the server start
5247
5348rem Check if %TEMP%\testmodel exists, if not, download it
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% "
49+ if not exist " %MODEL_PATH% " (
50+ curl.exe --connect-timeout 300 %DOWNLOAD_URL% --output " %MODEL_PATH% "
6051)
6152
6253rem 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
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}"
57+
58+ rem Print the values of curl_data1 and curl_data2 for debugging
7259echo curl_data1=%curl_data1%
7360echo curl_data2=%curl_data2%
74- echo curl_data3=%curl_data3%
75- echo curl_data4=%curl_data4%
76- echo curl_data5=%curl_data5%
7761
7862rem Run the curl commands and capture the status code
7963curl.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
8064
8165curl.exe --connect-timeout 60 -o " %TEMP% \response2.log" -s -w " %% {http_code}" --location " http://127.0.0.1:%PORT% /inferences/llamacpp/chat_completion" ^
8266--header " Content-Type: application/json" ^
67+ --header " Accept: text/event-stream" ^
68+ --header " Access-Control-Allow-Origin: *" ^
8369--data " %curl_data2% " > %TEMP% \response2.log 2 >& 1
8470
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-
9371set " error_occurred = 0"
9472
9573rem Read the status codes from the log files
9674for /f %%a in (%TEMP% \response1.log) do set " response1 = %%a "
9775for /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 "
10176
10277if " %response1% " neq " 200" (
10378 echo The first curl command failed with status code: %response1%
@@ -111,24 +86,6 @@ if "%response2%" neq "200" (
11186 set " error_occurred = 1"
11287)
11388
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-
13289if " %error_occurred% " == " 1" (
13390 echo Nitro test run failed!!!!!!!!!!!!!!!!!!!!!!
13491 echo Nitro Error Logs:
@@ -139,25 +96,13 @@ if "%error_occurred%"=="1" (
13996
14097
14198echo ----------------------
142- echo Log load llm model:
99+ echo Log load model:
143100type %TEMP% \response1.log
144101
145102echo ----------------------
146- echo Log run test:
103+ echo " Log run test:"
147104type %TEMP% \response2.log
148105
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-
161106echo Nitro test run successfully!
162107
163108rem Kill the server process
0 commit comments