Skip to content

Commit

Permalink
Update unit test for stream completion object
Browse files Browse the repository at this point in the history
  • Loading branch information
vinovo committed Sep 2, 2024
1 parent f95d6fb commit f0c9488
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions nexa/gguf/llama/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,7 @@ def logit_bias_processor(
"choices": [
{
"index": 0,
"logprobs": None,
"delta": {
"content": ts,
},
Expand Down
3 changes: 2 additions & 1 deletion nexa/gguf/llama/llama_chat_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ def _convert_text_completion_chunks_to_chat(
}
],
}

yield {
"id": "chat" + chunk["id"],
"model": chunk["model"],
Expand All @@ -314,7 +315,7 @@ def _convert_text_completion_chunks_to_chat(
"index": 0,
"delta": (
{
"content": chunk["choices"][0]["text"],
"content": chunk["choices"][0]["delta"]["content"],
}
if chunk["choices"][0]["finish_reason"] is None
else {}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_streaming():
)
for chunk in output:
if "choices" in chunk:
print(chunk["choices"][0]["text"], end="", flush=True)
print(chunk["choices"][0]["delta"]["content"], end="", flush=True)
# TODO: add assertions here

# Test conversation mode with chat format
Expand Down

0 comments on commit f0c9488

Please sign in to comment.