Skip to content

Commit d930cfe

Browse files
committed
fixes
1 parent 36cb6a1 commit d930cfe

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
@@ -2717,6 +2717,8 @@ class Llava15ChatHandler:
27172717
)
27182718

27192719
def __init__(self, clip_model_path: str, llama_model: Optional[llama.Llama] = None, verbose: bool = True):
2720+
import llama_cpp.mtmd_cpp as mtmd_cpp
2721+
27202722
self.clip_model_path = clip_model_path
27212723
self.verbose = verbose
27222724
self._mtmd_cpp = mtmd_cpp
@@ -3081,11 +3083,18 @@ def _load_image(image_url: str) -> bytes:
30813083
import base64
30823084
image_bytes = base64.b64decode(image_url.split(",")[1])
30833085
return image_bytes
3084-
else:
3086+
elif image_url.startswith("http") or image_url.startswith("https"):
30853087
import urllib.request
30863088
with urllib.request.urlopen(image_url) as f:
30873089
image_bytes = f.read()
30883090
return image_bytes
3091+
else:
3092+
import os
3093+
if os.path.exists(image_url):
3094+
with open(image_url, "rb") as f:
3095+
image_bytes = f.read()
3096+
return image_bytes
3097+
raise ValueError(f"Image file does not exist: {image_url}")
30893098

30903099
@staticmethod
30913100
def get_image_urls(messages: List[llama_types.ChatCompletionRequestMessage]):

0 commit comments

Comments
 (0)