Skip to content

Commit

Permalink
added options to ollama
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonalaird committed Aug 26, 2024
1 parent e950e8b commit 456fb12
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions vision_agent/lmm/lmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,16 @@ def __init__(
model_name: str = "llava",
base_url: Optional[str] = "http://localhost:11434/api",
json_mode: bool = False,
num_ctx: int = 4096,
**kwargs: Any,
):
self.url = base_url
self.model_name = model_name
self.kwargs = {"options": kwargs}

if json_mode:
kwargs["format"] = "json"
self.kwargs = kwargs
self.kwargs["format"] = "json" # type: ignore
self.kwargs["options"]["num_cxt"] = num_ctx

def __call__(
self,
Expand Down Expand Up @@ -370,7 +373,7 @@ def chat(
url = f"{self.url}/chat"
model = self.model_name
messages = fixed_chat
data = {"model": model, "messages": messages}
data: Dict[str, Any] = {"model": model, "messages": messages}

tmp_kwargs = self.kwargs | kwargs
data.update(tmp_kwargs)
Expand Down Expand Up @@ -411,15 +414,15 @@ def generate(
) -> Union[str, Iterator[Optional[str]]]:

url = f"{self.url}/generate"
data = {
data: Dict[str, Any] = {
"model": self.model_name,
"prompt": prompt,
"images": [],
}

if media and len(media) > 0:
for m in media:
data["images"].append(encode_media(m)) # type: ignore
data["images"].append(encode_media(m))

tmp_kwargs = self.kwargs | kwargs
data.update(tmp_kwargs)
Expand Down

0 comments on commit 456fb12

Please sign in to comment.