Skip to content

Commit

Permalink
add base url for openai client
Browse files Browse the repository at this point in the history
  • Loading branch information
hawktang authored Apr 4, 2024
1 parent d668350 commit 70326e8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions adala/runtimes/_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ class OpenAIChatRuntime(Runtime):

@computed_field
def _client(self) -> OpenAI:
return OpenAI(api_key=self.openai_api_key)
return OpenAI(
api_key=self.openai_api_key,
base_url=DEFAULT_CREATE_COMPLETION_URL
)

def init_runtime(self) -> "Runtime":
# check model availability
Expand Down Expand Up @@ -286,7 +289,10 @@ class AsyncOpenAIChatRuntime(AsyncRuntime):
def init_runtime(self) -> "Runtime":
# check model availability
try:
_client = OpenAI(api_key=self.openai_api_key)
_client = OpenAI(
api_key=self.openai_api_key,
base_url=DEFAULT_CREATE_COMPLETION_URL
)
_client.models.retrieve(self.openai_model)
except NotFoundError:
raise ValueError(
Expand Down

0 comments on commit 70326e8

Please sign in to comment.