Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
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
12 changes: 11 additions & 1 deletion 12 llama_cpp/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,24 @@ def _create_completion(
break
text = all_text[: len(all_text) - longest]
returned_characters += len(text[start:])
_text = ''
try:
_text = text[start:].decode("utf-8")
except UnicodeDecodeError:
for i in range(1,4):
try:
_text = text[start:-i].decode("utf-8")
break
except UnicodeDecodeError:
continue
yield {
"id": completion_id,
"object": "text_completion",
"created": created,
"model": self.model_path,
"choices": [
{
"text": text[start:].decode("utf-8", errors="ignore"),
"text": _text,
"index": 0,
"logprobs": None,
"finish_reason": None,
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.