Fix streaming doesn't return finish reason (#798)
When streaming the yield that contains the finish can be skipped. This change ensures that yield isn't skipped.
This commit is contained in:
parent
28c2b884e2
commit
09a8406c83
1 changed files with 14 additions and 28 deletions
|
@ -1232,20 +1232,6 @@ class Llama:
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
yield {
|
|
||||||
"id": completion_id,
|
|
||||||
"object": "text_completion",
|
|
||||||
"created": created,
|
|
||||||
"model": model_name,
|
|
||||||
"choices": [
|
|
||||||
{
|
|
||||||
"text": "",
|
|
||||||
"index": 0,
|
|
||||||
"logprobs": None,
|
|
||||||
"finish_reason": finish_reason,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
returned_tokens += 1
|
returned_tokens += 1
|
||||||
yield {
|
yield {
|
||||||
|
@ -1264,20 +1250,20 @@ class Llama:
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
yield {
|
yield {
|
||||||
"id": completion_id,
|
"id": completion_id,
|
||||||
"object": "text_completion",
|
"object": "text_completion",
|
||||||
"created": created,
|
"created": created,
|
||||||
"model": model_name,
|
"model": model_name,
|
||||||
"choices": [
|
"choices": [
|
||||||
{
|
{
|
||||||
"text": "",
|
"text": "",
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"logprobs": None,
|
"logprobs": None,
|
||||||
"finish_reason": finish_reason,
|
"finish_reason": finish_reason,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
if self.cache:
|
if self.cache:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print("Llama._create_completion: cache save", file=sys.stderr)
|
print("Llama._create_completion: cache save", file=sys.stderr)
|
||||||
|
|
Loading…
Reference in a new issue