-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added config flow, code optimizations
- Loading branch information
1 parent
8c6ce41
commit 0dffb57
Showing
6 changed files
with
91 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from homeassistant import config_entries | ||
from .const import DOMAIN, CONF_API_KEY | ||
import voluptuous as vol | ||
|
||
|
||
class gpt4visionConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): | ||
VERSION = 1 | ||
|
||
async def async_step_user(self, user_input=None): | ||
data_schema = vol.Schema({ | ||
vol.Required(CONF_API_KEY): str | ||
}) | ||
|
||
if user_input is not None: | ||
# Save the API key | ||
return self.async_create_entry(title="GPT4Vision Configuration", data=user_input) | ||
|
||
return self.async_show_form( | ||
step_id="user", | ||
data_schema=data_schema, | ||
description_placeholders=user_input | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
""" Constants for gpt4vision component""" | ||
|
||
DOMAIN = "gpt4vision" | ||
CONF_API_KEY = 'api_key' | ||
CONF_MAXTOKENS = 'max_tokens' | ||
CONF_TARGET_WIDTH = 'target_width' | ||
CONF_MODEL = 'model' | ||
CONF_MESSAGE = 'message' | ||
CONF_IMAGE_FILE = 'image_file' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
{ | ||
"domain": "gpt4vision", | ||
"name": "GPT-4 vision", | ||
"config_flow": true, | ||
"codeowners": ["@valentinfrlch"], | ||
"issue_tracker": "https://github.com/valentinfrlch/ha-gpt4vision/issues", | ||
"documentation": "https://github.com/valentinfrlch/ha-gpt4vision", | ||
"iot_class": "cloud_polling", | ||
"version": "0.1.4" | ||
"version": "0.2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"config": { | ||
"step": { | ||
"user": { | ||
"title": "Add API key", | ||
"description": "Provide your API key. See docs for more information.", | ||
"data": { | ||
"api_key": "Your API key" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"config": { | ||
"step": { | ||
"user": { | ||
"title": "Add API key", | ||
"description": "Provide your API key. See docs for more information.", | ||
"data": { | ||
"api_key": "Your API key" | ||
} | ||
} | ||
} | ||
} | ||
} |