Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions unit_tests/openai_util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Optional

from openai import OpenAI, Stream
Expand All @@ -13,7 +14,10 @@ def create_chat_completion_chunks(
"""
Create streaming responses.
"""
_client = client or OpenAI()
_client = client or OpenAI(
api_key=os.environ.get("OPENAI_API_KEY", None),
base_url=os.environ.get("OPENAI_API_BASE", None),
)

# Force to use streaming
kwargs["stream"] = True
Expand All @@ -36,7 +40,10 @@ def create_chat_completion_content(client: Optional[OpenAI] = None, **kwargs) ->

This is a replacement of creating non-streaming chat completion.
"""
_client = client or OpenAI()
_client = client or OpenAI(
api_key=os.environ.get("OPENAI_API_KEY", None),
base_url=os.environ.get("OPENAI_API_BASE", None),
)

# Force to use streaming
kwargs["stream"] = True
Expand Down