Skip to content

Commit 00c44b6

Browse files
author
LittleCoinCoin
committed
fix: openai_api_base assignment before query
Add, just like for api_key, the re-assignment of the api_base value because updating the value at runtime in the settings do not spring up the update in the OpenAI server.
1 parent 67290dc commit 00c44b6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

hatchling/core/llm/providers/openai_provider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,13 @@ async def stream_chat_response(
229229
raise RuntimeError("OpenAI client not initialized. Call initialize() first.")
230230

231231
try:
232-
# Given that OpenAI's API key can be set in the settings at any time by the user,
232+
# Given that OpenAI's API baseurl and api_key can be set in the settings at any time by the user,
233233
# we always re-assign before making a request
234234
# TODO: Although less severe, this is similar to Ollama's case where we
235235
# constantly have to re-assign data. An necessary optimization will be
236236
# made once the command pattern to set the settings will allow callbacks
237237
# using the publish-subscribe pattern.
238+
self._client.base_url = self._settings.openai.api_base
238239
self._client.api_key = self._settings.openai.api_key
239240

240241
# Ensure streaming is enabled for this request

0 commit comments

Comments
 (0)