diff --git a/openai_patch/__init__.py b/openai_patch/__init__.py index b606ed22292db6b088790e94159ee6d3bc86ee6a..085ef1654cab764468d80aaf1be7ef7d5e7d484f 100644 --- a/openai_patch/__init__.py +++ b/openai_patch/__init__.py @@ -1,10 +1,6 @@ -import re -import json import logging import openai -from homeassistant.helpers import intent -from homeassistant.exceptions import ServiceNotFound from homeassistant.components import conversation from homeassistant.components.openai_conversation.conversation import OpenAIConversationEntity @@ -15,18 +11,12 @@ async def async_setup(hass, config): original = OpenAIConversationEntity.async_process async def async_process(self, user_input: conversation.ConversationInput) -> conversation.ConversationResult: - _LOGGER.debug("OpenAIConversationEntity.async_process") client: openai.AsyncClient = self.entry.runtime_data - if "|" in client.api_key: - _LOGGER.debug(f"Modifying base_url and api_key: {client.api_key}") client.base_url = client.api_key.split("|")[0] client.api_key = client.api_key.split("|")[1] - - _LOGGER.debug(dir(client)) - _LOGGER.debug(vars(client)) - result = await original(self, user_input) - return result + _LOGGER.debug(f"Modified Base URL: {client.base_url}") + return await original(self, user_input) OpenAIConversationEntity.async_process = async_process _LOGGER.info("Patched OpenAIConversationEntity.async_process")