OpenAssist Beta - Home Assistant OpenAI GPT4 with Pinecone Index
Video Walkthrough
Overview
Hey there! Just wanted to let you know that this project is still in the beta stage. Sure, it’s functional, but it’s got a couple of quirks (like not always finding the right entities after a query).
This is a one-man show and I’m knee-deep in the development process. I’m open to any ideas from the community. Your suggestions could really help in shaping this into something spectacular. So, dive in!
This Home Assistant custom component creates a Pinecone index containing all your Home Assistant entity details. This allows you to make queries or ask questions using the input_boolean.openassist_prompt
, such as “turn my kitchen light off” or “what’s the current state of my kitchen light”.
This query is sent to the Pinecone index to find the closest matching entity, which is then sent to the ChatGPT4 model, returning the necessary data to perform the corresponding service call action.
Integration Install
- (Manual) Copy the OpenMindsAI folder to your Home Assistant’s custom_components directory. If you don’t have a custom_components directory, create one in the same directory as your configuration.yaml file.
(HACS) Add this repository as a HACS Integration: GitHub - Hassassistant/OpenAssist
-
Restart Home Assistant.
-
Add the following lines to your Home Assistant configuration.yaml file:
(See below for prerequisites)
input_text:
openassist_prompt:
initial: ""
max: 255
pinecone_index:
initial: ""
max: 255
openassist:
openai_key: "sk-...s1jz" #YOUR_OPENAI_KEY
pinecone_key: "b9a09c6a-...db2" #YOUR_PINECONE_ENVIRONMENT ID
pinecone_env: "us-west1-gcp-free" #YOUR_PINECONE_ENVIRONMENT ID
included_domains: "light, weather" #WHICH DOMAINS TO INCLUDE IN PINECONE DB
sensor:
- platform: openassist
your_name: "YOUR_NAME" #Optional if you want ChatGPT to know your name.
mindsdb_model: "gpt4hass" #MINDSDB MODEL NAME.
mindsdb_email: "[email protected]"
mindsdb_password: "Your_MindsDB_Password"
notify_device: "alexa_media_office_echo" #Optional, this sends each ChatGPT response to your notify entity.
#Can be any of your Notify entities. (Phone, Amazon Echo etc)
# If you need to debug any issues.
logger:
default: info
logs:
custom_components.openassist: debug
- Restart Home Assistant.
Example Lovelace Card
?raw=true)
square: false
columns: 1
type: grid
cards:
- type: entities
entities:
- entity: input_text.pinecone_index
name: Index Creation (Please type your ENV ID and hit enter)
- type: markdown
content: '{{ state_attr(''sensor.openassist_response'', ''index_status'') }}'
title: Pinecone Index Status
- type: entities
entities:
- entity: input_text.openassist_prompt
name: OpenAssist
- type: markdown
content: '{{ state_attr(''sensor.openassist_response'', ''message'') }}'
title: OpenAssist Response
How to use
- Type in your Pinecone Environment ID in the Pinecone Index input_boolean.
- Hit enter.
- Your Pinecone index will be created, this will then upload all your Home Assistant entity data to the index.
Please allow 10 - 15 minutes for the proccess to complete, dependant on how many entites you have.
Be aware: There is a known issue in Pinecone free tier, creation of new indexes getting stuck in a loop. This is out of my control, on one occasion I abandoned the index creation, and started this whole proccess again with a new Pinecone account.
- Notifications on the Index creation will be send to the OpenAssist Response entity.
- Send a question or query.
Example 1
Example 2
Example 3
Example 4
Prerequisites
You need to have the following accounts and their corresponding keys:
- Pinecone: You need a Pinecone account with an API key, along with the Environment ID (example: us-west1-gcp-free).
- OpenAI: You need an OpenAI API key, used for embedding.
- MindsDB: You’ll need a MindsDB account, and the name of your MindsDB model.
Creating the AI model in MindsDB
-
Create a free account on MindsDB and login. You can do so HERE.
-
Navigate to the MindsDB editor. You can find it HERE.
-
Create your AI model. In this example, we’re creating an OpenAI GPT4 model named
gpt4hass
.
You can replacegpt4hass
with your preferred model name. Execute the following SQL query to create your model:
CREATE MODEL mindsdb.gpt4hass
PREDICT response
USING
engine = 'openai',
max_tokens = 2000,
model_name = 'gpt-4',
prompt_template = '{{text}}';
Click “Run” to execute the query and create your model.
Pinecone API Key and Environment ID
- Create a free account on Pinecone and login. You can do so HERE.
- Wait for “Project Initializing” to finish.
- Navigate to the Pinecone API Key page and take note of the API Key (Value) and Environment ID.