From c6f24bab1044dde91c233bc348e4f62d2fe3fedd Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Thu, 30 May 2024 10:57:17 +0800 Subject: [PATCH] Update OpenAI API base URL handling --- devchat/openai/openai_chat.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/devchat/openai/openai_chat.py b/devchat/openai/openai_chat.py index 46cf2456..70e76ece 100755 --- a/devchat/openai/openai_chat.py +++ b/devchat/openai/openai_chat.py @@ -99,7 +99,10 @@ def stream_response(self, prompt: OpenAIPrompt) -> Iterator: api_key = os.environ.get("OPENAI_API_KEY", None) base_url = os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1/") - if not os.environ.get("USE_TIKTOKEN", False) and base_url != "https://api.openai.com/v1/": + if ( + not os.environ.get("USE_TIKTOKEN", False) + and base_url.find("https://api.openai.com/v1") == -1 + ): config_params = self.config.dict(exclude_unset=True) if prompt.get_functions(): config_params["functions"] = prompt.get_functions()