Skip to content

Commit d5e63e2

Browse files
authored
feat: app brick services support (#162)
1 parent a9de8b8 commit d5e63e2

20 files changed

Lines changed: 180 additions & 145 deletions

77

Whitespace-only changes.

containers/aihub-models-runner/Dockerfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ ARG DEBIAN_FRONTEND=noninteractive
66

77
FROM ubuntu:24.04
88

9-
ENV PYTHONUNBUFFERED=1
10-
COPY requirements-base.txt .
11-
12-
# Install system dependencies and Python dependencies, then clean up apt caches and temporary files to reduce image size
9+
# Install system dependencies
1310
RUN apt-get update \
1411
&& apt-get install -y --no-install-recommends --no-install-suggests software-properties-common \
1512
&& apt-add-repository -y ppa:ubuntu-qcom-iot/qcom-ppa \
@@ -21,13 +18,20 @@ RUN apt-get update \
2118
python3-venv \
2219
python-is-python3 \
2320
libqnn1 \
24-
qcom-fastrpc1 \
25-
&& apt-get remove -y python3-blinker \
21+
qcom-fastrpc1
22+
23+
# Install Python dependencies and precompile to speed up startup time
24+
ENV PYTHONUNBUFFERED=1
25+
COPY requirements-base.txt .
26+
RUN apt-get remove -y python3-blinker \
2627
&& python -m pip install --no-cache-dir --break-system-packages -r requirements-base.txt \
2728
&& python -m compileall /usr/local/bin \
2829
&& python -m compileall /usr/local/lib \
29-
&& rm requirements-base.txt \
30-
&& apt-get remove -y software-properties-common \
30+
&& rm requirements-base.txt
31+
32+
# Clean up
33+
RUN apt-get remove -y \
34+
software-properties-common \
3135
&& apt-get autoremove -y \
3236
&& apt-get dist-clean \
3337
&& rm -rf /var/lib/apt/lists/*
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# This file contains base dependencies required by the framework
22
websockets
33
flask
4-
waitress
5-
opencv-python-headless
6-
ai-edge-litert==1.3.0
4+
waitress
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
opencv-python-headless
2+
ai-edge-litert==1.3.0

src/arduino/app_bricks/asr/brick_config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ id: arduino:asr
22
name: Automatic Speech Recognition (ASR)
33
description: Automatic Speech Recognition brick for offline speech-to-text processing
44
category: audio
5-
disabled: true
65
requires_model: true
7-
requires_container: true
6+
requires_services: ["arduino:genie_audio"]
87
model: whisper-small
98
supported_boards: ["ventunoq"]
109
model_configuration_variables:

src/arduino/app_bricks/llm/brick_compose.yaml

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

src/arduino/app_bricks/llm/brick_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id: arduino:llm
22
name: Large Language Model (LLM)
33
description: "Large Language Model (LLM) Brick enables seamless integration with locally hosted LLMs for advanced AI capabilities in your Arduino projects."
4-
requires_container: true
4+
requires_services: ["arduino:genie"]
55
requires_model: true
66
model: genie:qwen3-4b
77
supported_boards: ["ventunoq"]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# SPDX-FileCopyrightText: Copyright (C) ARDUINO SRL (http://www.arduino.cc)
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
# EXAMPLE_NAME = "Chat with tools and streaming"
6+
# EXAMPLE_REQUIRES = "Models must be downloaded and available locally."
7+
8+
from arduino.app_bricks.llm import LargeLanguageModel, tool
9+
from arduino.app_utils import App
10+
11+
12+
# Tool definition - simulates a simple weather API - please replace with actual API calls in a real application
13+
@tool
14+
def get_current_weather(location: str) -> str:
15+
"""
16+
Get the current weather in a given location.
17+
The output is a string with a summary of the weather.
18+
19+
Args:
20+
location (str): The location to get the weather for.
21+
22+
Returns:
23+
str: A summary of the current weather in the specified location.
24+
25+
"""
26+
if "boston" in location.lower():
27+
return "The current weather in Boston is 15°C and partly cloudy."
28+
elif "paris" in location.lower():
29+
return "The current weather in Paris is 8°C and rainy."
30+
elif "turin" in location.lower():
31+
return "The current weather in Turin is 8°C and rainy."
32+
else:
33+
return f"Sorry, I do not have real-time weather data for {location}. Assuming it's a sunny day!"
34+
35+
36+
llm = LargeLanguageModel(max_tokens=512, tools=[get_current_weather])
37+
38+
39+
def ask_prompt():
40+
prompt = input("Enter your prompt (or type 'exit' to quit): ")
41+
if prompt.lower() == "exit":
42+
raise StopIteration()
43+
for chunk in llm.chat_stream(prompt):
44+
print(chunk, end="", flush=True)
45+
print()
46+
47+
48+
App.run(ask_prompt)

src/arduino/app_bricks/tts/brick_compose.yaml

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

src/arduino/app_bricks/tts/brick_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Text-to-Speech (TTS)
33
description: Text-to-Speech brick for offline speech synthesis
44
category: audio
55
requires_model: true
6-
requires_container: true
76
supported_boards: ["ventunoq"]
87
disabled: true
98
model: melo-tts-en

0 commit comments

Comments
 (0)