Skip to content

Commit

Permalink
Add openwebui step
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinfrlch authored Feb 7, 2025
1 parent 4847a1e commit ff2f824
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions custom_components/llmvision/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ async def async_step_user(self, user_input=None):
data_schema = vol.Schema({
vol.Required("provider", default="Event Calendar"): selector({
"select": {
"options": ["Anthropic", "AWS Bedrock", "Google", "Groq", "LocalAI", "Ollama", "OpenAI", "OpenWebUI", "Custom OpenAI", "Event Calendar"], # Azure removed until fixed
# Azure removed until fixed
"options": ["Anthropic", "AWS Bedrock", "Google", "Groq", "LocalAI", "Ollama", "OpenAI", "OpenWebUI", "Custom OpenAI", "Event Calendar"],
"mode": "dropdown",
"sort": False,
"custom_value": False
Expand Down Expand Up @@ -109,7 +110,7 @@ async def async_step_localai(self, user_input=None):
if self.source == config_entries.SOURCE_RECONFIGURE:
# load existing configuration and add it to the dialog
self.init_info = self._get_reconfigure_entry().data
data_schema=self.add_suggested_values_to_schema(
data_schema = self.add_suggested_values_to_schema(
data_schema, self.init_info
)

Expand Down Expand Up @@ -156,7 +157,7 @@ async def async_step_ollama(self, user_input=None):
if self.source == config_entries.SOURCE_RECONFIGURE:
# load existing configuration and add it to the dialog
self.init_info = self._get_reconfigure_entry().data
data_schema=self.add_suggested_values_to_schema(
data_schema = self.add_suggested_values_to_schema(
data_schema, self.init_info
)

Expand Down Expand Up @@ -192,7 +193,7 @@ async def async_step_ollama(self, user_input=None):
step_id="ollama",
data_schema=data_schema,
)

async def async_step_openwebui(self, user_input=None):
data_schema = vol.Schema({
vol.Required(CONF_OPENWEBUI_API_KEY): str,
Expand All @@ -213,11 +214,14 @@ async def async_step_openwebui(self, user_input=None):
# save provider to user_input
user_input["provider"] = self.init_info["provider"]
try:
openwebui = OpenWebUI(self.hass, user_input[CONF_OPENWEBUI_API_KEY], user_input[CONF_OPENWEBUI_DEFAULT_MODEL] endpoint={
'ip_address': user_input[CONF_OPENWEBUI_IP_ADDRESS],
'port': user_input[CONF_OPENWEBUI_PORT],
'https': user_input[CONF_OPENWEBUI_HTTPS]
})
openwebui = OpenWebUI(hass=self.hass,
api_key=user_input[CONF_OPENWEBUI_API_KEY],
model=user_input[CONF_OPENWEBUI_DEFAULT_MODEL],
endpoint={
'ip_address': user_input[CONF_OPENWEBUI_IP_ADDRESS],
'port': user_input[CONF_OPENWEBUI_PORT],
'https': user_input[CONF_OPENWEBUI_HTTPS]
})
await openwebui.validate()
# add the mode to user_input
if self.source == config_entries.SOURCE_RECONFIGURE:
Expand Down Expand Up @@ -250,7 +254,7 @@ async def async_step_openai(self, user_input=None):
if self.source == config_entries.SOURCE_RECONFIGURE:
# load existing configuration and add it to the dialog
self.init_info = self._get_reconfigure_entry().data
data_schema=self.add_suggested_values_to_schema(
data_schema = self.add_suggested_values_to_schema(
data_schema, self.init_info
)

Expand Down Expand Up @@ -296,7 +300,7 @@ async def async_step_azure(self, user_input=None):
if self.source == config_entries.SOURCE_RECONFIGURE:
# load existing configuration and add it to the dialog
self.init_info = self._get_reconfigure_entry().data
data_schema=self.add_suggested_values_to_schema(
data_schema = self.add_suggested_values_to_schema(
data_schema, self.init_info
)

Expand Down Expand Up @@ -343,7 +347,7 @@ async def async_step_anthropic(self, user_input=None):
if self.source == config_entries.SOURCE_RECONFIGURE:
# load existing configuration and add it to the dialog
self.init_info = self._get_reconfigure_entry().data
data_schema=self.add_suggested_values_to_schema(
data_schema = self.add_suggested_values_to_schema(
data_schema, self.init_info
)

Expand Down Expand Up @@ -386,7 +390,7 @@ async def async_step_google(self, user_input=None):
if self.source == config_entries.SOURCE_RECONFIGURE:
# load existing configuration and add it to the dialog
self.init_info = self._get_reconfigure_entry().data
data_schema=self.add_suggested_values_to_schema(
data_schema = self.add_suggested_values_to_schema(
data_schema, self.init_info
)

Expand Down Expand Up @@ -429,7 +433,7 @@ async def async_step_groq(self, user_input=None):
if self.source == config_entries.SOURCE_RECONFIGURE:
# load existing configuration and add it to the dialog
self.init_info = self._get_reconfigure_entry().data
data_schema=self.add_suggested_values_to_schema(
data_schema = self.add_suggested_values_to_schema(
data_schema, self.init_info
)

Expand Down Expand Up @@ -473,7 +477,7 @@ async def async_step_custom_openai(self, user_input=None):
if self.source == config_entries.SOURCE_RECONFIGURE:
# load existing configuration and add it to the dialog
self.init_info = self._get_reconfigure_entry().data
data_schema=self.add_suggested_values_to_schema(
data_schema = self.add_suggested_values_to_schema(
data_schema, self.init_info
)

Expand All @@ -482,10 +486,11 @@ async def async_step_custom_openai(self, user_input=None):
user_input["provider"] = self.init_info["provider"]
try:
custom_openai = OpenAI(self.hass,
api_key=user_input[CONF_CUSTOM_OPENAI_API_KEY],
endpoint={'base_url': user_input[CONF_CUSTOM_OPENAI_ENDPOINT]},
default_model=user_input[CONF_CUSTOM_OPENAI_DEFAULT_MODEL],
)
api_key=user_input[CONF_CUSTOM_OPENAI_API_KEY],
endpoint={
'base_url': user_input[CONF_CUSTOM_OPENAI_ENDPOINT]},
default_model=user_input[CONF_CUSTOM_OPENAI_DEFAULT_MODEL],
)
await custom_openai.validate()
# add the mode to user_input
user_input["provider"] = self.init_info["provider"]
Expand Down Expand Up @@ -519,7 +524,7 @@ async def async_step_semantic_index(self, user_input=None):
if self.source == config_entries.SOURCE_RECONFIGURE:
# load existing configuration and add it to the dialog
self.init_info = self._get_reconfigure_entry().data
data_schema=self.add_suggested_values_to_schema(
data_schema = self.add_suggested_values_to_schema(
data_schema, self.init_info
)

Expand Down Expand Up @@ -559,7 +564,7 @@ async def async_step_aws_bedrock(self, user_input=None):
if self.source == config_entries.SOURCE_RECONFIGURE:
# load existing configuration and add it to the dialog
self.init_info = self._get_reconfigure_entry().data
data_schema=self.add_suggested_values_to_schema(
data_schema = self.add_suggested_values_to_schema(
data_schema, self.init_info
)

Expand All @@ -568,11 +573,11 @@ async def async_step_aws_bedrock(self, user_input=None):
user_input["provider"] = self.init_info["provider"]
try:
aws_bedrock = AWSBedrock(self.hass,
aws_access_key_id=user_input[CONF_AWS_ACCESS_KEY_ID],
aws_secret_access_key=user_input[CONF_AWS_SECRET_ACCESS_KEY],
aws_region_name=user_input[CONF_AWS_REGION_NAME],
model=user_input[CONF_AWS_DEFAULT_MODEL],
)
aws_access_key_id=user_input[CONF_AWS_ACCESS_KEY_ID],
aws_secret_access_key=user_input[CONF_AWS_SECRET_ACCESS_KEY],
aws_region_name=user_input[CONF_AWS_REGION_NAME],
model=user_input[CONF_AWS_DEFAULT_MODEL],
)
await aws_bedrock.validate()
# add the mode to user_input
user_input["provider"] = self.init_info["provider"]
Expand Down

0 comments on commit ff2f824

Please sign in to comment.