Closed1
ModuleLLM-OpenAI-Pluginを試す

ModuleLLM-OpenAI-Pluginを試す
Firmware
** LLM630 Compute KIT
** M5_LLM_ubuntu22.04_20250328_AX630C_LITE.axp
( M5_LLM_ubuntu22.04_20250328_AX630C_LITE.axpより古いバージョンではemmcエラーが発生する。)
root@m5stack-kit:$ sudo apt-get update
root@m5stack-kit:$ sudo apt-get upgrade $(apt-cache search "^llm-" | grep -v "^llm-model-" | awk '{print $1}')
root@m5stack-kit:~# apt install llm-model-qwen2.5-0.5b-p256-ax630c
root@m5stack-kit:~# apt list --installed llm-*
Listing... Done
llm-asr/stable,now 1.5 arm64 [installed]
llm-audio/stable,now 1.5 arm64 [installed]
llm-camera/stable,now 1.6 arm64 [installed]
llm-depth-anything/stable,now 1.5 arm64 [installed]
llm-kws/stable,now 1.5 arm64 [installed]
llm-llm/stable,now 1.6 arm64 [installed]
llm-melotts/stable,now 1.5 arm64 [installed]
llm-model-audio-en-us/stable,now 0.2 arm64 [installed]
llm-model-audio-zh-cn/stable,now 0.2 arm64 [installed]
llm-model-depth-anything-ax630c/stable,now 0.3 arm64 [installed]
llm-model-internvl2.5-1b-ax630c/stable,now 0.4 arm64 [installed]
llm-model-melotts-zh-cn/stable,now 0.4 arm64 [installed]
llm-model-qwen2.5-0.5b-p256-ax630c/stable,now 0.4 arm64 [installed]
llm-model-qwen2.5-0.5b-prefill-20e/stable,now 0.2 arm64 [installed]
llm-model-sherpa-ncnn-streaming-zipformer-20m-2023-02-17/stable,now 0.2 arm64 [installed]
llm-model-sherpa-ncnn-streaming-zipformer-zh-14m-2023-02-23/stable,now 0.2 arm64 [installed]
llm-model-sherpa-onnx-kws-zipformer-gigaspeech-3.3m-2024-01-01/stable,now 0.3 arm64 [installed]
llm-model-sherpa-onnx-kws-zipformer-wenetspeech-3.3m-2024-01-01/stable,now 0.3 arm64 [installed]
llm-model-silero-vad/stable,now 0.3 arm64 [installed]
llm-model-single-speaker-english-fast/stable,now 0.2 arm64 [installed]
llm-model-single-speaker-fast/stable,now 0.2 arm64 [installed]
llm-model-whisper-tiny/stable,now 0.3 arm64 [installed]
llm-model-yolo11n-hand-pose/stable,now 0.3 arm64 [installed]
llm-model-yolo11n-pose/stable,now 0.3 arm64 [installed]
llm-model-yolo11n-seg/stable,now 0.2 arm64 [installed,upgradable to: 0.3]
llm-model-yolo11n/stable,now 0.2 arm64 [installed]
llm-openai-api/stable,now 1.5 arm64 [installed]
llm-skel/stable,now 1.5 arm64 [installed]
llm-sys/stable,now 1.5 arm64 [installed]
llm-tts/stable,now 1.5 arm64 [installed]
llm-vad/stable,now 1.5 arm64 [installed]
llm-vlm/stable,now 1.5 arm64 [installed]
llm-whisper/stable,now 1.5 arm64 [installed]
llm-yolo/stable,now 1.6 arm64 [installed]
root@m5stack-kit:~# apt install git
root@m5stack-kit:~# git clone https://github.com/m5stack/ModuleLLM-OpenAI-Plugin
root@m5stack-kit:~# cd ModuleLLM-OpenAI-Plugin
root@m5stack-kit:~# pip install -r requirements.txt
ファイル名のtypo
root@m5stack-kit:~# python main.py
-bash: python: command not found
root@m5stack-kit:~# python3 main.py
python3: can't open file '/root/ModuleLLM-OpenAI-Plugin/main.py': [Errno 2] No such file or directory
root@m5stack-kit:~# python3 api_server.py
ModuleNotFoundError: No module named 'tiktoken'
root@m5stack-kit:~# pip install tiktoken
portが使用中
おそらく、llm-openai-apiがインストール済みだと port:8000が干渉している。
root@m5stack-kit:~# python3 api_server.py
/usr/local/lib/python3.10/dist-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
2025-04-16 09:22:54,558 - asyncio - DEBUG - Using selector: EpollSelector
2025-04-16 09:22:54,644 - sys_client - DEBUG - Sending request: [ID:f9c8ebde-c061-4f6c-9649-f4654d01e2c8] Action:lsmode WorkID:sys
Data: {}...
2025-04-16 09:22:55,284 - asyncio - DEBUG - Using selector: EpollSelector
INFO: Started server process [2679]
INFO: Waiting for application startup.
INFO: Application startup complete.
ERROR: [Errno 98] error while attempting to bind on address ('0.0.0.0', 8000): address already in use
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
root@m5stack-kit:~/ModuleLLM-OpenAI-Plugin# python3 api_server.py
/usr/local/lib/python3.10/dist-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
2025-04-16 09:39:24,607 - asyncio - DEBUG - Using selector: EpollSelector
2025-04-16 09:39:24,694 - sys_client - DEBUG - Sending request: [ID:b2f94f7a-eb79-46d8-873a-a1b18ddb89f7] Action:lsmode WorkID:sys
Data: {}...
2025-04-16 09:39:25,332 - asyncio - DEBUG - Using selector: EpollSelector
INFO: Started server process [2623]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit)
2025-04-16 09:40:43,535 - api.llm - DEBUG - Processed query | System prompt: 0 chars | Images: 0 | Dialogue lines: 1
2025-04-16 09:40:43,538 - sys_client - DEBUG - Sending request: [ID:0217e688-00e3-4aa5-b1c1-12971c346f74] Action:cmminfo WorkID:sys
Data: {}...
2025-04-16 09:40:43,544 - memory_check - DEBUG - Memory check - Required: 560460, Available: 2620992
2025-04-16 09:40:43,544 - api.llm - DEBUG - Creating new LLM client
2025-04-16 09:40:43,546 - llm_client - DEBUG - Sending request: [ID:4445b16c-8396-4e60-976c-ed39e9857dc8] Action:setup WorkID:llm
Data: {'model': 'qwen2.5-0.5B-p256-ax630c', 'response_format': 'llm.utf-8.stream', 'input': 'llm.utf-8', '...
2025-04-16 09:41:01,295 - api.llm - DEBUG - Starting inference | ClientID:281473819058352 Query length:21
2025-04-16 09:41:01,297 - llm_client - DEBUG - Sending request: [ID:0ac5bd9e-d156-42c2-a3c5-55b47bd25ba8] Action:inference WorkID:llm.1000
Data: user: Hi!are you name...
2025-04-16 09:41:05,098 - api.llm - DEBUG - Returned client to pool | ID:281473819058352
2025-04-16 09:41:05,098 - api.llm - DEBUG - Inference stopped | ClientID:281473819058352
INFO: 127.0.0.1:38296 - "POST /v1/chat/completions HTTP/1.1" 200 OK
root@m5stack-kit:~# curl -X POST "http://localhost:8001/v1/chat/completions" -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_KEY" -d '{ "model": "qwen2.5-0.5B-p256-ax630c", "messages": [{"role": "user", "content": "Hi!are you name"}], "temperature": 0.7}'
{"id":"chatcmpl-147de6d6-e792-4824-8185-dc89c70bdde6","object":"chat.completion","created":1744767665,"model":"qwen2.5-0.5B-p256-ax630c","choices":[{"message":{"role":"assistant","content":"Yes, I am a language model created by Anthropic to be helpful, harmless, and honest. How can I assist you today?"}}]}
python3 api_server.py
/usr/local/lib/python3.10/dist-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
2025-04-16 09:48:16,455 - asyncio - DEBUG - Using selector: EpollSelector
2025-04-16 09:48:16,541 - sys_client - DEBUG - Sending request: [ID:0dcf8052-e648-4787-b135-8edf6708c7e0] Action:lsmode WorkID:sys
Data: {}...
2025-04-16 09:48:17,174 - asyncio - DEBUG - Using selector: EpollSelector
INFO: Started server process [3345]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit)
2025-04-16 09:48:17,973 - api - ERROR - Speech generation error: 400: Unsupported model: melotts
INFO: 127.0.0.1:38342 - "POST /v1/audio/speech HTTP/1.1" 500 Internal Server Error
melotts->melotts_zh-cn
root@m5stack-kit:~# curl -X POST "http://localhost:8001/v1/audio/speech" -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_KEY" -d '{
"model": "melotts",
"input": "Hello world!",
"voice": "alloy"
}'
{"detail":"400: Unsupported model: melotts"}
root@m5stack-kit:/opt/m5stack/data# curl -X POST "http://localhost:8001/v1/audio/speech" -H "Content-Type1 application/json" -H "Authorization: Bearer YOUR_KEY" -d '{
"model": "melotts_zh-cn",
"input": "Hello world!",
"voice": "alloy"
}'
root@m5stack-kit:~# curl -X POST "http://localhost:8001/v1/audio/speech" -H "Content-Type: application
/json" -H "Authorization: Bearer YOUR_KEY" -d '{
"model": "melotts_zh-cn",
"input": "Hello world!",
"voice": "alloy"
}'
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
curl -X POST "http://localhost:8001/v1/audio/speech" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_KEY" \
-d '{
"model": "melotts_zh-cn",
"input": "Hello world!",
"voice": "alloy"
}' \
--output output.mp3
このスクラップは5ヶ月前にクローズされました