Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit e7ae2e5

Browse files
authored
feat: cortex-cpp rename components (#545)
1 parent 216097f commit e7ae2e5

File tree

24 files changed

+206
-257
lines changed

24 files changed

+206
-257
lines changed

.github/scripts/e2e-test-llama-linux-and-mac.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/bin/bash
22

33
## Example run command
4-
# ./linux-and-mac.sh './jan/plugins/@janhq/inference-plugin/dist/nitro/nitro_mac_arm64' https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v0.3-GGUF/resolve/main/tinyllama-1.1b-chat-v0.3.Q2_K.gguf
4+
# ./linux-and-mac.sh './jan/plugins/@janhq/inference-plugin/dist/cortex-cpp/nitro_mac_arm64' https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v0.3-GGUF/resolve/main/tinyllama-1.1b-chat-v0.3.Q2_K.gguf
55

66
# Check for required arguments
77
if [[ $# -ne 3 ]]; then
88
echo "Usage: $0 <path_to_binary> <url_to_download_llm> <url_to_download_embedding>"
99
exit 1
1010
fi
1111

12-
rm /tmp/load-llm-model-res.log /tmp/completion-res.log /tmp/unload-model-res.log /tmp/load-embedding-model-res.log /tmp/embedding-res.log /tmp/nitro.log
12+
rm /tmp/load-llm-model-res.log /tmp/completion-res.log /tmp/unload-model-res.log /tmp/load-embedding-model-res.log /tmp/embedding-res.log /tmp/cortex-cpp.log
1313

1414
BINARY_PATH=$1
1515
DOWNLOAD_LLM_URL=$2
@@ -22,14 +22,14 @@ range=$((max - min + 1))
2222
PORT=$((RANDOM % range + min))
2323

2424
# Start the binary file
25-
"$BINARY_PATH" 1 127.0.0.1 $PORT >/tmp/nitro.log &
25+
"$BINARY_PATH" 1 127.0.0.1 $PORT >/tmp/cortex-cpp.log &
2626

2727
# Get the process id of the binary file
2828
pid=$!
2929

3030
if ! ps -p $pid >/dev/null; then
31-
echo "nitro failed to start. Logs:"
32-
cat /tmp/nitro.log
31+
echo "cortex-cpp failed to start. Logs:"
32+
cat /tmp/cortex-cpp.log
3333
exit 1
3434
fi
3535

@@ -47,7 +47,7 @@ if [[ ! -f "/tmp/test-embedding" ]]; then
4747
fi
4848

4949
# Run the curl commands
50-
response1=$(curl --connect-timeout 60 -o /tmp/load-llm-model-res.log -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/inferences/llamacpp/loadModel" \
50+
response1=$(curl --connect-timeout 60 -o /tmp/load-llm-model-res.log -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/inferences/server/loadModel" \
5151
--header 'Content-Type: application/json' \
5252
--data '{
5353
"llama_model_path": "/tmp/testllm",
@@ -57,8 +57,8 @@ response1=$(curl --connect-timeout 60 -o /tmp/load-llm-model-res.log -s -w "%{ht
5757
}')
5858

5959
if ! ps -p $pid >/dev/null; then
60-
echo "nitro failed to load model. Logs:"
61-
cat /tmp/nitro.log
60+
echo "cortex-cpp failed to load model. Logs:"
61+
cat /tmp/cortex-cpp.log
6262
exit 1
6363
fi
6464

@@ -83,14 +83,14 @@ response2=$(
8383
)
8484

8585
# unload model
86-
response3=$(curl --connect-timeout 60 -o /tmp/unload-model-res.log --request GET -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/inferences/llamacpp/unloadModel" \
86+
response3=$(curl --connect-timeout 60 -o /tmp/unload-model-res.log --request GET -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/inferences/server/unloadModel" \
8787
--header 'Content-Type: application/json' \
8888
--data '{
8989
"llama_model_path": "/tmp/testllm"
9090
}')
9191

9292
# load embedding model
93-
response4=$(curl --connect-timeout 60 -o /tmp/load-embedding-model-res.log -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/inferences/llamacpp/loadModel" \
93+
response4=$(curl --connect-timeout 60 -o /tmp/load-embedding-model-res.log -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/inferences/server/loadModel" \
9494
--header 'Content-Type: application/json' \
9595
--data '{
9696
"llama_model_path": "/tmp/test-embedding",
@@ -145,9 +145,9 @@ if [[ "$response5" -ne 200 ]]; then
145145
fi
146146

147147
if [[ "$error_occurred" -eq 1 ]]; then
148-
echo "Nitro test run failed!!!!!!!!!!!!!!!!!!!!!!"
149-
echo "Nitro Error Logs:"
150-
cat /tmp/nitro.log
148+
echo "cortex-cpp test run failed!!!!!!!!!!!!!!!!!!!!!!"
149+
echo "cortex-cpp Error Logs:"
150+
cat /tmp/cortex-cpp.log
151151
kill $pid
152152
exit 1
153153
fi
@@ -172,7 +172,7 @@ echo "----------------------"
172172
echo "Log run test:"
173173
cat /tmp/embedding-res.log
174174

175-
echo "Nitro test run successfully!"
175+
echo "cortex-cpp test run successfully!"
176176

177177
# Kill the server process
178178
kill $pid

.github/scripts/e2e-test-llama-windows.bat

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,28 @@ del %TEMP%\response2.log 2>nul
2323
del %TEMP%\response3.log 2>nul
2424
del %TEMP%\response4.log 2>nul
2525
del %TEMP%\response5.log 2>nul
26-
del %TEMP%\nitro.log 2>nul
26+
del %TEMP%\cortex-cpp.log 2>nul
2727

2828
set /a min=9999
2929
set /a max=11000
3030
set /a range=max-min+1
3131
set /a PORT=%min% + %RANDOM% %% %range%
3232

3333
rem Start the binary file
34-
start /B "" "%BINARY_PATH%" 1 "127.0.0.1" %PORT% > %TEMP%\nitro.log 2>&1
34+
start /B "" "%BINARY_PATH%" 1 "127.0.0.1" %PORT% > %TEMP%\cortex-cpp.log 2>&1
3535

3636
ping -n 6 127.0.0.1 %PORT% > nul
3737

38-
rem Capture the PID of the started process with "nitro" in its name
38+
rem Capture the PID of the started process with "cortex-cpp" in its name
3939
for /f "tokens=2" %%a in ('tasklist /fi "imagename eq %BINARY_NAME%" /fo list ^| findstr /B "PID:"') do (
4040
set "pid=%%a"
4141
)
4242

4343
echo pid=%pid%
4444

4545
if not defined pid (
46-
echo nitro failed to start. Logs:
47-
type %TEMP%\nitro.log
46+
echo cortex-cpp failed to start. Logs:
47+
type %TEMP%\cortex-cpp.log
4848
exit /b 1
4949
)
5050

@@ -76,15 +76,15 @@ echo curl_data4=%curl_data4%
7676
echo curl_data5=%curl_data5%
7777

7878
rem Run the curl commands and capture the status code
79-
curl.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
79+
curl.exe --connect-timeout 60 -o "%TEMP%\response1.log" -s -w "%%{http_code}" --location "http://127.0.0.1:%PORT%/inferences/server/loadModel" --header "Content-Type: application/json" --data "%curl_data1%" > %TEMP%\response1.log 2>&1
8080

81-
curl.exe --connect-timeout 60 -o "%TEMP%\response2.log" -s -w "%%{http_code}" --location "http://127.0.0.1:%PORT%/inferences/llamacpp/chat_completion" ^
81+
curl.exe --connect-timeout 60 -o "%TEMP%\response2.log" -s -w "%%{http_code}" --location "http://127.0.0.1:%PORT%/inferences/server/chat_completion" ^
8282
--header "Content-Type: application/json" ^
8383
--data "%curl_data2%" > %TEMP%\response2.log 2>&1
8484

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
85+
curl.exe --connect-timeout 60 -o "%TEMP%\response3.log" --request GET -s -w "%%{http_code}" --location "http://127.0.0.1:%PORT%/inferences/server/unloadModel" --header "Content-Type: application/json" --data "%curl_data3%" > %TEMP%\response3.log 2>&1
8686

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
87+
curl.exe --connect-timeout 60 -o "%TEMP%\response4.log" --request POST -s -w "%%{http_code}" --location "http://127.0.0.1:%PORT%/inferences/server/loadModel" --header "Content-Type: application/json" --data "%curl_data4%" > %TEMP%\response4.log 2>&1
8888

8989
curl.exe --connect-timeout 60 -o "%TEMP%\response5.log" -s -w "%%{http_code}" --location "http://127.0.0.1:%PORT%/v1/embeddings" ^
9090
--header "Content-Type: application/json" ^
@@ -130,9 +130,9 @@ if "%response5%" neq "200" (
130130
)
131131

132132
if "%error_occurred%"=="1" (
133-
echo Nitro test run failed!!!!!!!!!!!!!!!!!!!!!!
134-
echo Nitro Error Logs:
135-
type %TEMP%\nitro.log
133+
echo cortex-cpp test run failed!!!!!!!!!!!!!!!!!!!!!!
134+
echo cortex-cpp Error Logs:
135+
type %TEMP%\cortex-cpp.log
136136
taskkill /f /pid %pid%
137137
exit /b 1
138138
)
@@ -158,8 +158,8 @@ echo ----------------------
158158
echo Log run embedding test:
159159
type %TEMP%\response5.log
160160

161-
echo Nitro test run successfully!
161+
echo cortex-cpp test run successfully!
162162

163163
rem Kill the server process
164164
@REM taskkill /f /pid %pid%
165-
taskkill /f /im nitro.exe 2>nul || exit /B 0
165+
taskkill /f /im cortex-cpp.exe 2>nul || exit /B 0

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ jobs:
185185
- name: Upload Artifact
186186
uses: actions/upload-artifact@v2
187187
with:
188-
name: cortex-llamacpp-engine-${{ matrix.os }}-${{ matrix.name }}
189-
path: ./cortex-cpp/cortex
188+
name: cortex-cpp-${{ matrix.os }}-${{ matrix.name }}
189+
path: ./cortex-cpp/cortex-cpp
190190

191191
- uses: actions/upload-release-asset@v1.0.1
192192
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
193193
env:
194194
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
195195
with:
196196
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
197-
asset_path: ./cortex-cpp/cortex.tar.gz
198-
asset_name: cortex-llamacpp-engine-${{ needs.create-draft-release.outputs.version }}-${{ matrix.os }}-${{ matrix.name }}.tar.gz
197+
asset_path: ./cortex-cpp/cortex-cpp.tar.gz
198+
asset_name: cortex-cpp-${{ needs.create-draft-release.outputs.version }}-${{ matrix.os }}-${{ matrix.name }}.tar.gz
199199
asset_content_type: application/gzip

.github/workflows/quality-gate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,5 @@ jobs:
159159
- name: Upload Artifact
160160
uses: actions/upload-artifact@v2
161161
with:
162-
name: cortex-llamacpp-engine-${{ matrix.os }}-${{ matrix.name }}
163-
path: ./cortex-cpp/cortex
162+
name: cortex-cpp-${{ matrix.os }}-${{ matrix.name }}
163+
path: ./cortex-cpp/cortex-cpp

.github/workflows/update-release-url.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

cortex-cpp/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ CMakeCache.txt
8585
CMakeFiles
8686
CMakeScripts
8787
Testing
88-
!nitro-node/Makefile
8988
cmake_install.cmake
9089
install_manifest.txt
9190
compile_commands.json
@@ -561,7 +560,7 @@ FodyWeavers.xsd
561560

562561
# End of https://www.toptal.com/developers/gitignore/api/intellij+all,visualstudio,visualstudiocode,cmake,c,c++
563562
build
564-
build_deps
563+
build-deps
565564
.DS_Store
566565

567566
uploads/**

cortex-cpp/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.5)
2-
project(nitro C CXX)
2+
project(cortex-cpp C CXX)
33

44
include(engines/cortex.llamacpp/engine.cmake)
55
include(CheckIncludeFileCXX)
@@ -21,7 +21,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
2121
set(CMAKE_CXX_EXTENSIONS OFF)
2222
set(OPENSSL_USE_STATIC_LIBS TRUE)
2323
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
24-
set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build_deps/_install)
24+
set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build-deps/_install)
2525
# This is the critical line for installing another package
2626

2727
if(LLAMA_CUDA)
@@ -35,12 +35,12 @@ if(LLAMA_CUDA)
3535
endif()
3636

3737
if(DEBUG)
38-
message(STATUS "NITRO DEBUG IS ON")
38+
message(STATUS "CORTEX-CPP DEBUG IS ON")
3939
add_compile_definitions(ALLOW_ALL_CORS)
4040
endif()
4141

42-
if(NOT DEFINED NITRO_VERSION)
43-
set(NITRO_VERSION "default_version")
42+
if(NOT DEFINED CORTEX_CPP_VERSION)
43+
set(CORTEX_CPP_VERSION "default_version")
4444
endif()
4545

4646
if(APPLE)
@@ -54,16 +54,16 @@ if(APPLE)
5454
endif()
5555
endif()
5656

57-
add_compile_definitions(NITRO_VERSION="${NITRO_VERSION}")
57+
add_compile_definitions(CORTEX_CPP_VERSION="${CORTEX_CPP_VERSION}")
5858

5959
add_subdirectory(test)
6060

6161
add_executable(${PROJECT_NAME} main.cc)
6262

6363
# ##############################################################################
6464
# If you include the drogon source code locally in your project, use this method
65-
# to add drogon add_subdirectory(nitro_deps)
66-
# target_link_libraries(${PROJECT_NAME} PRIVATE nitro_deps)
65+
# to add drogon add_subdirectory(cortex-cpp-deps)
66+
# target_link_libraries(${PROJECT_NAME} PRIVATE cortex-cpp-deps)
6767
#
6868
# and comment out the following lines
6969

cortex-cpp/Makefile

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ all:
1414
# Build the Cortex engine
1515
build:
1616
ifeq ($(OS),Windows_NT)
17-
@powershell -Command "cmake -S ./nitro_deps -B ./build_deps/nitro_deps;"
18-
@powershell -Command "cmake --build ./build_deps/nitro_deps --config Release -j4;"
17+
@powershell -Command "cmake -S ./cortex-cpp-deps -B ./build-deps/cortex-cpp-deps;"
18+
@powershell -Command "cmake --build ./build-deps/cortex-cpp-deps --config Release -j4;"
1919
@powershell -Command "mkdir -p build; cd build; cmake .. $(CMAKE_EXTRA_FLAGS); cmake --build . --config Release -j4;"
2020
else ifeq ($(shell uname -s),Linux)
2121
@./install_deps.sh;
@@ -31,23 +31,23 @@ endif
3131

3232
package:
3333
ifeq ($(OS),Windows_NT)
34-
@powershell -Command "mkdir -p cortex\engines\cortex.llamacpp\; cp build\engines\cortex.llamacpp\engine.dll cortex\engines\cortex.llamacpp\;"
35-
@powershell -Command "cp build\Release\nitro.exe .\cortex\;"
36-
@powershell -Command "cp build_deps\_install\bin\zlib.dll .\cortex\;"
37-
@powershell -Command "cp ..\.github\patches\windows\msvcp140.dll .\cortex\;"
38-
@powershell -Command "cp ..\.github\patches\windows\vcruntime140_1.dll .\cortex\;"
39-
@powershell -Command "cp ..\.github\patches\windows\vcruntime140.dll .\cortex\;"
40-
@powershell -Command "7z a -ttar temp.tar cortex\\*; 7z a -tgzip cortex.tar.gz temp.tar;"
34+
@powershell -Command "mkdir -p cortex-cpp\engines\cortex.llamacpp\; cp build\engines\cortex.llamacpp\engine.dll cortex-cpp\engines\cortex.llamacpp\;"
35+
@powershell -Command "cp build\Release\cortex-cpp.exe .\cortex-cpp\;"
36+
@powershell -Command "cp build-deps\_install\bin\zlib.dll .\cortex-cpp\;"
37+
@powershell -Command "cp ..\.github\patches\windows\msvcp140.dll .\cortex-cpp\;"
38+
@powershell -Command "cp ..\.github\patches\windows\vcruntime140_1.dll .\cortex-cpp\;"
39+
@powershell -Command "cp ..\.github\patches\windows\vcruntime140.dll .\cortex-cpp\;"
40+
@powershell -Command "7z a -ttar temp.tar cortex-cpp\\*; 7z a -tgzip cortex-cpp.tar.gz temp.tar;"
4141
else ifeq ($(shell uname -s),Linux)
42-
@mkdir -p cortex/engines/cortex.llamacpp; \
43-
cp build/engines/cortex.llamacpp/libengine.so cortex/engines/cortex.llamacpp/; \
44-
cp build/nitro cortex/; \
45-
tar -czvf cortex.tar.gz cortex;
42+
@mkdir -p cortex-cpp/engines/cortex.llamacpp; \
43+
cp build/engines/cortex.llamacpp/libengine.so cortex-cpp/engines/cortex.llamacpp/; \
44+
cp build/cortex-cpp cortex-cpp/; \
45+
tar -czvf cortex-cpp.tar.gz cortex-cpp;
4646
else
47-
@mkdir -p cortex/engines/cortex.llamacpp; \
48-
cp build/engines/cortex.llamacpp/libengine.dylib cortex/engines/cortex.llamacpp/; \
49-
cp build/nitro cortex/; \
50-
tar -czvf cortex.llamacpp.tar.gz cortex;
47+
@mkdir -p cortex-cpp/engines/cortex.llamacpp; \
48+
cp build/engines/cortex.llamacpp/libengine.dylib cortex-cpp/engines/cortex.llamacpp/; \
49+
cp build/cortex-cpp cortex-cpp/; \
50+
tar -czvf cortex-cpp.tar.gz cortex-cpp;
5151
endif
5252

5353
run-e2e-test:
@@ -56,13 +56,13 @@ ifeq ($(RUN_TESTS),false)
5656
@exit 0
5757
endif
5858
ifeq ($(OS),Windows_NT)
59-
@powershell -Command "cd cortex; ..\..\.github\scripts\e2e-test-llama-windows.bat nitro.exe $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL);"
59+
@powershell -Command "cd cortex-cpp; ..\..\.github\scripts\e2e-test-llama-windows.bat cortex-cpp.exe $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL);"
6060
else ifeq ($(shell uname -s),Linux)
61-
@cd cortex; \
62-
chmod +x ../../.github/scripts/e2e-test-llama-linux-and-mac.sh && ../../.github/scripts/e2e-test-llama-linux-and-mac.sh ./nitro $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL); \
61+
@cd cortex-cpp; \
62+
chmod +x ../../.github/scripts/e2e-test-llama-linux-and-mac.sh && ../../.github/scripts/e2e-test-llama-linux-and-mac.sh ./cortex-cpp $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL); \
6363
rm -rf uploads/;
6464
else
65-
@cd cortex; \
66-
chmod +x ../../.github/scripts/e2e-test-llama-linux-and-mac.sh && ../../.github/scripts/e2e-test-llama-linux-and-mac.sh ./nitro $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL); \
65+
@cd cortex-cpp; \
66+
chmod +x ../../.github/scripts/e2e-test-llama-linux-and-mac.sh && ../../.github/scripts/e2e-test-llama-linux-and-mac.sh ./cortex-cpp $(LLM_MODEL_URL) $(EMBEDDING_MODEL_URL); \
6767
rm -rf uploads/;
6868
endif

0 commit comments

Comments
 (0)