Skip to content

Commit d4983a5

Browse files
committed
fixes
1 parent dae49b8 commit d4983a5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

llama_cpp/llama.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,6 +2454,9 @@ def _create_context(
24542454
self.context_params.no_perf = no_perf
24552455
self.last_n_tokens_size = last_n_tokens_size
24562456

2457+
# Store logits_all as instance attribute
2458+
self._logits_all = self.context_params.logits_all
2459+
24572460
# Set the default value for the context and correct the batch
24582461
if n_ctx == 0:
24592462
n_ctx = self._model.n_ctx_train()

llama_cpp/llama_chat_format.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2723,6 +2723,8 @@ class Llava15ChatHandler:
27232723
)
27242724

27252725
def __init__(self, clip_model_path: str, llama_model: Optional[llama.Llama] = None, verbose: bool = True):
2726+
import llama_cpp.mtmd_cpp as mtmd_cpp
2727+
27262728
self.clip_model_path = clip_model_path
27272729
self.verbose = verbose
27282730
self._mtmd_cpp = mtmd_cpp
@@ -3087,11 +3089,18 @@ def _load_image(image_url: str) -> bytes:
30873089
import base64
30883090
image_bytes = base64.b64decode(image_url.split(",")[1])
30893091
return image_bytes
3090-
else:
3092+
elif image_url.startswith("http") or image_url.startswith("https"):
30913093
import urllib.request
30923094
with urllib.request.urlopen(image_url) as f:
30933095
image_bytes = f.read()
30943096
return image_bytes
3097+
else:
3098+
import os
3099+
if os.path.exists(image_url):
3100+
with open(image_url, "rb") as f:
3101+
image_bytes = f.read()
3102+
return image_bytes
3103+
raise ValueError(f"Image file does not exist: {image_url}")
30953104

30963105
@staticmethod
30973106
def get_image_urls(messages: List[llama_types.ChatCompletionRequestMessage]):

0 commit comments

Comments
 (0)