Skip to content
Closed
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions tests/unittest/llmapi/apps/_test_openai_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import openai
import pytest
from utils.util import similar

from ..test_llm import get_model_path
from .openai_server import RemoteOpenAIServer
Expand Down Expand Up @@ -206,7 +207,7 @@ async def test_batch_completions_streaming(async_client: openai.AsyncOpenAI,


@pytest.mark.asyncio(loop_scope="module")
@pytest.mark.parametrize("prompts", [["Hello, my name is", "What is the AI?"]])
@pytest.mark.parametrize("prompts", [["Hello, my name is"] * 2])
async def test_batch_completions_with_option_n_streaming(
async_client: openai.AsyncOpenAI, model_name, prompts):
# test beam search with streaming
Expand All @@ -215,7 +216,7 @@ async def test_batch_completions_with_option_n_streaming(
prompt=prompts,
n=3, # number of completions to generate for each prompt.
max_tokens=5,
temperature=0.0,
temperature=0.0001,
stream=True,
)
texts = [""] * 6 # 2 prompts × 3 generations per prompt = 6 choices
Expand All @@ -224,7 +225,10 @@ async def test_batch_completions_with_option_n_streaming(
choice = chunk.choices[0]
texts[choice.index] += choice.text

assert [""] not in texts # Assert all the generations are not empty
assert "" not in texts # Assert all the generations are not empty

for i, j in zip(texts[:3], texts[3:]):
assert similar(i, j, threshold=0.8)


@pytest.mark.asyncio(loop_scope="module")
Expand Down