Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
add hass addon
Browse files Browse the repository at this point in the history
  • Loading branch information
0x77dev committed Apr 20, 2024
1 parent 61b81d5 commit 0e61ac6
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 4 deletions.
1 change: 1 addition & 0 deletions .dockerignore
11 changes: 11 additions & 0 deletions .github/workflows/hass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Ship Home Assistant Add-on

on:
push:
branches:
- main

jobs:
workflows:
uses: hassio-addons/workflows/.github/workflows/base-deploy.yaml@main
6 changes: 4 additions & 2 deletions custom_components/ava/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import yaml

from homeassistant import config_entries
from homeassistant.const import CONF_API_KEY, CONF_NAME
from homeassistant.const import CONF_API_KEY, CONF_NAME, DEFAULT_CONF_API_KEY
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.selector import (
Expand All @@ -37,7 +37,7 @@
STEP_USER_DATA_SCHEMA = vol.Schema(
{
vol.Optional(CONF_NAME): str,
vol.Required(CONF_API_KEY): str,
vol.Optional(CONF_API_KEY, default=DEFAULT_CONF_API_KEY): str,
vol.Optional(CONF_BASE_URL, default=DEFAULT_CONF_BASE_URL): str,
vol.Optional(
CONF_SKIP_AUTHENTICATION, default=DEFAULT_SKIP_AUTHENTICATION
Expand All @@ -59,6 +59,8 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> None:
Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user.
"""
api_key = data[CONF_API_KEY]
if not api_key:
return
base_url = data.get(CONF_BASE_URL)
skip_authentication = data.get(CONF_SKIP_AUTHENTICATION)

Expand Down
1 change: 1 addition & 0 deletions custom_components/ava/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
DEFAULT_CONF_BASE_URL = "http://oai-ava/v1"
CONF_SKIP_AUTHENTICATION = "skip_authentication"
DEFAULT_SKIP_AUTHENTICATION = True
DEFAULT_CONF_API_KEY = "sk--none"

EVENT_AUTOMATION_REGISTERED = "automation_registered_via_ava"
EVENT_CONVERSATION_FINISHED = "ava.conversation.finished"
Expand Down
4 changes: 2 additions & 2 deletions packages/lang/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"@langchain/core": "^0.1.58",
"@langchain/openai": "^0.0.28",
"easydl": "^1.1.1",
"hnswlib-node": "^3.0.0",
"hnswlib-node": "^3",
"langchain": "^0.1.34",
"node-llama-cpp": "^2.8.9",
"xml-js": "^1.6.11",
"znv": "^0.4.0",
"zod": "^3.22.5"
}
}
}
3 changes: 3 additions & 0 deletions repository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: Ava
url: https://github.com/0x77dev/ava
maintainer: Mykhailo Marynenko <mykhailo+oss@0x77dev>
55 changes: 55 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
ARG BUILD_FROM=oven/bun:1-debian
FROM ${BUILD_FROM}

FROM base as workspace
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY . .

FROM workspace as build
COPY --from=node:lts-bullseye /usr/local/bin/node /usr/local/bin/node
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
build-essential python3 llvm clang
RUN bun install --frozen-lockfile

FROM workspace
COPY --from=build /usr/src/ava/node_modules /usr/src/ava/node_modules
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
jq curl

ARG BASHIO_VERSION="v0.16.2"

RUN curl -J -L -o /tmp/bashio.tar.gz \
"https://github.com/hassio-addons/bashio/archive/${BASHIO_VERSION}.tar.gz" \
&& mkdir /tmp/bashio \
&& tar zxvf \
/tmp/bashio.tar.gz \
--strip 1 -C /tmp/bashio \
&& mv /tmp/bashio/lib /usr/lib/bashio \
&& ln -s /usr/lib/bashio/bashio /usr/bin/bashio

EXPOSE 2881

LABEL \
io.hass.name="Ada Server for ${BUILD_ARCH}" \
io.hass.description="Ada Server Add-on: ${BUILD_ARCH} bun debian v1 image" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="base" \
io.hass.version=${BUILD_VERSION} \
io.hass.base.version=${BUILD_VERSION} \
io.hass.base.name="debian" \
io.hass.base.image="ghcr.io/0x77dev/ava/server" \
maintainer="Mykhailo Marynenko <mykhailo@0x77.dev>" \
org.opencontainers.image.title="Ada Server for ${BUILD_ARCH" \
org.opencontainers.image.description="Ada Server Add-on: ${BUILD_ARCH} bun debian v1 image" \
org.opencontainers.image.vendor="Ava Add-ons" \
org.opencontainers.image.authors="Mykhailo Marynenko <mykhailo@0x77.dev>" \
org.opencontainers.image.licenses="GPL-3.0" \
org.opencontainers.image.url="https://github.com/${BUILD_REPOSITORY}" \
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}

CMD ["/usr/src/ava/server/hass-entrypoint.sh"]
6 changes: 6 additions & 0 deletions server/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
build_from:
aarch64: oven/bun:1-debian
amd64: oven/bun:1-debian
codenotary:
signer: mykhailo@0x77.dev
14 changes: 14 additions & 0 deletions server/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Ava Server"
description: "Self-hosted personal assistant in minutes with built-in Home Assistant integration and great extensibility and customizability."
version: "0.0.0"
slug: "ava_server"
init: false
arch:
- aarch64
- amd64
ports:
2881/tcp: 2881
image: ghcr.io/0x77dev/ava/server
homeassistant_api: true
ingress: true
ingress_port: 2881
5 changes: 5 additions & 0 deletions server/hass-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bashio

LLM="$(bashio::config 'llm' | jq -r .llm)"
EMBEDDINGS="$(bashio::config 'embeddings' | jq -r .llm)"
HOMEASSISTANT='{"url": "ws://supervisor/core/websocket", "token": "${SUPERVISOR_TOKEN}"}'

0 comments on commit 0e61ac6

Please sign in to comment.