This is an example of a fusion between xChips and the OpenAI API. It uses the Flask web framework and getting the data from the xChips via the MQTT server. Check out the quickstart tutorial for original pet name creator example.
-
If you don’t have Python installed, install it from here.
-
Clone this repository.
-
Navigate into the project directory:
$ cd openai-quickstart-python
-
Create a new virtual environment:
$ python -m venv venv $ . venv/bin/activate
-
Install the requirements:
$ pip install -r requirements.txt
-
Make a copy of the example environment variables file:
$ cp .env.example .env
-
Add your API key to the newly created
.env
file. -
Check your OpenAI API account. OpenAI API is not free!
-
Add your MQTT Topic to the
.env
file, typicallyx/data/sdg/<chipid>
. -
Run the app:
$ flask run
- Example of data feed into the OpenAI API from the xChips:
Temperature: 15.16
Humidity: 82.82
Dew Point: 12.26
Heat Index: 14.89
Wet-Bulb Temperature: 13.2
Cloud Base: 353.54
Cloud Temperature: 11.68
Ambient Light: 26
UV Index: 0.02
- Examples of questions, but don't hold back:
What is the temperature?
What is the air quality like?
Can you calculate a comfort level?
Is it dry?
Is there any clouds?
You should now be able to access the app at http://127.0.0.1:5000! For the full context behind this example app, check out the tutorial.