Skip to content

Commit cbca30c

Browse files
committed
Added typer, improved messaging, use OLLAMA_HOST
1 parent a3f11e6 commit cbca30c

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

interpreter/core/llm/llm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ def load(self):
339339

340340
if self.model.startswith("ollama/"):
341341
model_name = self.model.replace("ollama/", "")
342-
api_base = getattr(self, "api_base", None) or "http://localhost:11434"
342+
api_base = getattr(self, "api_base", None) or os.getenv(
343+
"OLLAMA_HOST", "http://localhost:11434"
344+
)
343345
names = []
344346
try:
345347
# List out all downloaded ollama models. Will fail if ollama isn't installed

interpreter/terminal_interface/local_setup.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,25 @@ def download_model(models_dir, models, interpreter):
245245
names = [
246246
line.split()[0].replace(":latest", "")
247247
for line in lines
248-
if line.strip() and not line.startswith("failed") and not line.startswith("NAME")
248+
if line.strip()
249+
and not line.startswith("failed")
250+
and not line.startswith("NAME")
249251
] # Extract names, trim out ":latest", skip header
250252

251253
# Models whose name contain one of these keywords will be moved to the front of the list
252-
priority_models=["llama3","codestral"]
253-
priority_models_found=[]
254+
priority_models = ["llama3", "codestral"]
255+
priority_models_found = []
254256
for word in priority_models:
255-
models_to_move=[name for name in names if word.lower() in name.lower()]
257+
models_to_move = [
258+
name for name in names if word.lower() in name.lower()
259+
]
256260
priority_models_found.extend(models_to_move)
257-
names=[name for name in names if not any(word.lower() in name.lower() for word in priority_models)]
258-
names=priority_models_found+names
261+
names = [
262+
name
263+
for name in names
264+
if not any(word.lower() in name.lower() for word in priority_models)
265+
]
266+
names = priority_models_found + names
259267

260268
for model in ["llama3.1", "phi3", "mistral-nemo", "gemma2", "codestral"]:
261269
if model not in names:
@@ -297,7 +305,6 @@ def download_model(models_dir, models, interpreter):
297305
interpreter.llm.model = f"ollama/{model}"
298306

299307
# Send a ping, which will actually load the model
300-
interpreter.display_message("Loading model...")
301308

302309
old_max_tokens = interpreter.llm.max_tokens
303310
old_context_window = interpreter.llm.context_window

poetry.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ yaspin = "^3.0.2"
6666
shortuuid = "^1.0.13"
6767
litellm = "^1.41.26"
6868
starlette = "^0.37.2"
69+
typer = "^0.12.4"
6970

7071
[tool.poetry.extras]
7172
os = ["opencv-python", "pyautogui", "plyer", "pywinctl", "pytesseract", "sentence-transformers", "ipywidgets", "torch", "timm", "screeninfo"]

0 commit comments

Comments
 (0)