Skip to content

Commit 951dbc4

Browse files
committed
Expanded test_chain_completion to check different response IDs and text
1 parent 58933e2 commit 951dbc4

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

tests/test_paperqa.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from io import BytesIO
1010
from pathlib import Path
1111
from typing import cast
12+
from uuid import UUID
1213

1314
import httpx
1415
import numpy as np
@@ -387,25 +388,28 @@ def accum(x) -> None:
387388
outputs.append(x)
388389

389390
llm = s.get_llm()
391+
messages = [Message(content="The duck says")]
390392

391-
messages = [
392-
Message(content="The duck says"),
393-
]
394-
completion = await llm.call_single(
395-
messages=messages,
396-
callbacks=[accum],
397-
)
393+
# With callbacks uses streaming
394+
completion = await llm.call_single(messages=messages, callbacks=[accum])
395+
first_id = completion.id
396+
assert isinstance(first_id, UUID)
397+
assert completion.text
398398
assert completion.seconds_to_first_token > 0
399399
assert completion.prompt_count > 0
400400
assert completion.completion_count > 0
401401
assert str(completion) == "".join(outputs)
402+
assert completion.cost > 0
402403

403-
completion = await llm.call_single(
404-
messages=messages,
405-
)
404+
# Without callbacks we don't use streaming
405+
completion = await llm.call_single(messages=messages)
406+
assert isinstance(completion.id, UUID)
407+
assert completion.id != first_id, "Expected different response ID"
408+
assert completion.text
406409
assert completion.seconds_to_first_token == 0
407410
assert completion.seconds_to_last_token > 0
408-
411+
assert completion.prompt_count > 0
412+
assert completion.completion_count > 0
409413
assert completion.cost > 0
410414

411415

0 commit comments

Comments
 (0)