Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
78966f4
chore: init gitsubmodule whisper.cpp
hiro-v Dec 16, 2023
e4713f9
chore: Add whisper.cpp to cmake file
hiro-v Dec 16, 2023
72e6ff7
chore: Add setUpload path
hiro-v Dec 16, 2023
3dd606c
feat: Add transcription function
hiro-v Dec 16, 2023
aea0757
feat: Add transcription function declaration
hiro-v Dec 16, 2023
863ebce
chore: Add uploads folder to gitignore
hiro-v Dec 16, 2023
0990139
chore: delete config.json
hiro-v Dec 16, 2023
b53f4a7
feat: Add OAI compatible APIs for /audio/transcriptions and /audio/tr…
hiro-v Dec 16, 2023
018450d
chore: Fix warning message in compiler
hiro-v Dec 17, 2023
1288b58
chore: Add whisper.cpp to target
hiro-v Dec 17, 2023
bf1fdb8
fix: Add whisper.h
hiro-v Dec 17, 2023
77972e7
chore: Migrate whisper.cpp definition to another controller file
hiro-v Dec 17, 2023
3ec6224
chore: remove ggml.h in llamaCPP.cc
hiro-v Dec 17, 2023
79e0081
WIP
hiro-v Jan 24, 2024
8a0a291
Movable mutex
hiro-v Jan 25, 2024
34d36a1
json happy case working
hiro-v Jan 25, 2024
56a509b
All output format working
hiro-v Jan 26, 2024
cf4c034
Rename model_status to list_model
hiro-v Jan 26, 2024
be62c2b
Merge branch 'main' into feat/nitro_whisperccp
hiro-v Jan 26, 2024
43ffb9d
chore: space inline
hiro-v Jan 26, 2024
167cddc
Init temp audio doc
hiro-v Jan 26, 2024
d39a939
fix: Update mac silicon build note
hiro-v Jan 27, 2024
2f94bb2
fix: add note for using mac silicon coreml
hiro-v Jan 27, 2024
8340e57
fix(whispercpp): Update std::min and std::max on windows build
hiro-v Jan 27, 2024
496bb00
fix: Update windows with cuda build note
hiro-v Jan 27, 2024
b71a2ef
feat: Add whisper.cpp build for nitro audio support
hiro-v Jan 27, 2024
8197865
fix: Migrate old e2e test script to new file name for llama
hiro-v Jan 27, 2024
3323a08
feat: Add e2e script to test whisper.cpp
hiro-v Jan 27, 2024
f18a2a8
fix(ci): Add e2e to CI
hiro-v Jan 27, 2024
74e9a11
Add model warm up
hiro-v Jan 27, 2024
c5a45d5
fix(ci): Fix bug in path
hiro-v Jan 27, 2024
d2a776a
chore(ci): Temp disable CI for e2e testing on windows
hiro-v Jan 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ range=$((max - min + 1))
PORT=$((RANDOM % range + min))

# Start the binary file
"$BINARY_PATH" 1 127.0.0.1 $PORT > /tmp/nitro.log 2>&1 &
"$BINARY_PATH" 1 127.0.0.1 $PORT >/tmp/nitro.log 2>&1 &

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

if ! ps -p $pid > /dev/null; then
if ! ps -p $pid >/dev/null; then
echo "nitro failed to start. Logs:"
cat /tmp/nitro.log
exit 1
Expand All @@ -35,26 +35,27 @@ fi
# Wait for a few seconds to let the server start
sleep 5

# Check if /tmp/testmodel exists, if not, download it
if [[ ! -f "/tmp/testmodel" ]]; then
wget $DOWNLOAD_URL -O /tmp/testmodel
# Check if /tmp/testllm exists, if not, download it
if [[ ! -f "/tmp/testllm" ]]; then
wget $DOWNLOAD_URL -O /tmp/testllm
fi

# Run the curl commands
response1=$(curl -o /tmp/response1.log -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/inferences/llamacpp/loadModel" \
--header 'Content-Type: application/json' \
--data '{
"llama_model_path": "/tmp/testmodel",
--header 'Content-Type: application/json' \
--data '{
"llama_model_path": "/tmp/testllm",
"ctx_len": 50,
"ngl": 32,
"embedding": false
}' 2>&1)

response2=$(curl -o /tmp/response2.log -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/inferences/llamacpp/chat_completion" \
--header 'Content-Type: application/json' \
--header 'Accept: text/event-stream' \
--header 'Access-Control-Allow-Origin: *' \
--data '{
response2=$(
curl -o /tmp/response2.log -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/v1/chat/completions" \
--header 'Content-Type: application/json' \
--header 'Accept: text/event-stream' \
--header 'Access-Control-Allow-Origin: *' \
--data '{
"messages": [
{"content": "Hello there", "role": "assistant"},
{"content": "Write a long and sad story for me", "role": "user"}
Expand Down Expand Up @@ -98,7 +99,6 @@ echo "----------------------"
echo "Log run test:"
cat /tmp/response2.log


echo "Nitro test run successfully!"

# Kill the server process
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off

set "TEMP=C:\Users\%UserName%\AppData\Local\Temp"
set "MODEL_PATH=%TEMP%\testmodel"
set "MODEL_PATH=%TEMP%\testllm"

rem Check for required arguments
if "%~2"=="" (
Expand Down
93 changes: 93 additions & 0 deletions .github/scripts/e2e-test-whisper-linux-and-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash

## Example run command
# ./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

# Check for required arguments
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <path_to_binary> <url_to_download>"
exit 1
fi

rm /tmp/response1.log /tmp/response2.log /tmp/nitro.log

BINARY_PATH=$1
DOWNLOAD_URL=$2

# Random port to ensure it's not used
min=10000
max=11000
range=$((max - min + 1))
PORT=$((RANDOM % range + min))

# Start the binary file
"$BINARY_PATH" 1 127.0.0.1 $PORT >/tmp/nitro.log 2>&1 &

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

if ! ps -p $pid >/dev/null; then
echo "nitro failed to start. Logs:"
cat /tmp/nitro.log
exit 1
fi

# Wait for a few seconds to let the server start
sleep 5

# Check if /tmp/testwhisper exists, if not, download it
if [[ ! -f "/tmp/testwhisper" ]]; then
wget $DOWNLOAD_URL -O /tmp/testwhisper
fi

# Run the curl commands
response1=$(curl -o /tmp/response1.log -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/v1/audio/load_model" \
--header 'Content-Type: application/json' \
--data '{
"model_path": "/tmp/testwhisper",
"model_id": "whisper.cpp"
}' 2>&1)

response2=$(
curl -o /tmp/response2.log -s -w "%{http_code}" --location "http://127.0.0.1:$PORT/v1/audio/transcriptions" \
--header 'Access-Control-Allow-Origin: *' \
--form 'file=@"../whisper.cpp/samples/jfk.wav"' \
--form 'model_id="whisper.cpp"' \
--form 'temperature="0.0"' \
--form 'prompt="The transcript is about OpenAI which makes technology like DALL·E, GPT-3, and ChatGPT with the hope of one day building an AGI system that benefits all of humanity. The president is trying to raly people to support the cause."' \
2>&1
)

error_occurred=0
if [[ "$response1" -ne 200 ]]; then
echo "The first curl command failed with status code: $response1"
cat /tmp/response1.log
error_occurred=1
fi

if [[ "$response2" -ne 200 ]]; then
echo "The second curl command failed with status code: $response2"
cat /tmp/response2.log
error_occurred=1
fi

if [[ "$error_occurred" -eq 1 ]]; then
echo "Nitro test run failed!!!!!!!!!!!!!!!!!!!!!!"
echo "Nitro Error Logs:"
cat /tmp/nitro.log
kill $pid
exit 1
fi

echo "----------------------"
echo "Log load model:"
cat /tmp/response1.log

echo "----------------------"
echo "Log run test:"
cat /tmp/response2.log

echo "Nitro test run successfully!"

# Kill the server process
kill $pid
109 changes: 109 additions & 0 deletions .github/scripts/e2e-test-whisper-windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
@echo off

set "TEMP=C:\Users\%UserName%\AppData\Local\Temp"
set "MODEL_PATH=%TEMP%\testwhisper"

rem Check for required arguments
if "%~2"=="" (
echo Usage: %~0 ^<path_to_binary^> ^<url_to_download^>
exit /b 1
)

set "BINARY_PATH=%~1"
set "DOWNLOAD_URL=%~2"

for %%i in ("%BINARY_PATH%") do set "BINARY_NAME=%%~nxi"

echo BINARY_NAME=%BINARY_NAME%

del %TEMP%\response1.log 2>nul
del %TEMP%\response2.log 2>nul
del %TEMP%\nitro.log 2>nul

set /a min=9999
set /a max=11000
set /a range=max-min+1
set /a PORT=%min% + %RANDOM% %% %range%

rem Start the binary file
start /B "" "%BINARY_PATH%" 1 "127.0.0.1" %PORT% > %TEMP%\nitro.log 2>&1

ping -n 6 127.0.0.1 %PORT% > nul

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

echo pid=%pid%

if not defined pid (
echo nitro failed to start. Logs:
type %TEMP%\nitro.log
exit /b 1
)

rem Wait for a few seconds to let the server start

rem Check if %TEMP%\testmodel exists, if not, download it
if not exist "%MODEL_PATH%" (
bitsadmin.exe /transfer "DownloadTestModel" %DOWNLOAD_URL% "%MODEL_PATH%"
)

rem Define JSON strings for curl data
call set "MODEL_PATH_STRING=%%MODEL_PATH:\=\\%%"
set "curl_data1={\"model_path\":\"%MODEL_PATH_STRING%\",\"model_id\":\"whisper.cpp\"}"

rem Print the values of curl_data1 for debugging
echo curl_data1=%curl_data1%

rem Run the curl commands and capture the status code
curl.exe -o %TEMP%\response1.log -s -w "%%{http_code}" --location "http://127.0.0.1:%PORT%/v1/audio/load_model" --header "Content-Type: application/json" --data "%curl_data1%" > %TEMP%\response1_code.log 2>&1

curl.exe -o %TEMP%\response2.log -s -w "%%{http_code}" --location "http://127.0.0.1:%PORT%/v1/audio/transcriptions" ^
--header "Access-Control-Allow-Origin: *" ^
--form 'model_id="whisper.cpp"' ^
--form 'file=@"..\whisper.cpp\samples\jfk.wav"' ^
--form 'temperature="0.0"' ^
--form 'prompt="The transcript is about OpenAI which makes technology like DALL·E, GPT-3, and ChatGPT with the hope of one day building an AGI system that benefits all of humanity. The president is trying to raly people to support the cause."' ^
> %TEMP%\response2_code.log 2>&1

set "error_occurred=0"

rem Read the status codes from the log files
for /f %%a in (%TEMP%\response1_code.log) do set "response1=%%a"
for /f %%a in (%TEMP%\response2_code.log) do set "response2=%%a"

if "%response1%" neq "200" (
echo The first curl command failed with status code: %response1%
type %TEMP%\response1.log
set "error_occurred=1"
)

if "%response2%" neq "200" (
echo The second curl command failed with status code: %response2%
type %TEMP%\response2.log
set "error_occurred=1"
)

if "%error_occurred%"=="1" (
echo Nitro test run failed!!!!!!!!!!!!!!!!!!!!!!
echo Nitro Error Logs:
type %TEMP%\nitro.log
taskkill /f /pid %pid%
exit /b 1
)


echo ----------------------
echo Log load model:
type %TEMP%\response1.log

echo ----------------------
echo "Log run test:"
type %TEMP%\response2.log

echo Nitro test run successfully!

rem Kill the server process
taskkill /f /pid %pid%
Loading