From 41fab3c318d83e9e0306dbaa69560d1463ead97f Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Thu, 29 Jun 2023 16:13:28 -0700 Subject: [PATCH] fix imports --- ollama/engine.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ollama/engine.py b/ollama/engine.py index 6b7944d1..e6bbadb5 100644 --- a/ollama/engine.py +++ b/ollama/engine.py @@ -1,5 +1,6 @@ -from os import path, dup, dup2, devnull +import os import sys +from os import path from contextlib import contextmanager from llama_cpp import Llama as LLM @@ -9,12 +10,12 @@ import ollama.prompt @contextmanager def suppress_stderr(): - stderr = dup(sys.stderr.fileno()) - with open(devnull, "w") as devnull: - dup2(devnull.fileno(), sys.stderr.fileno()) + stderr = os.dup(sys.stderr.fileno()) + with open(os.devnull, "w") as devnull: + os.dup2(devnull.fileno(), sys.stderr.fileno()) yield - dup2(stderr, sys.stderr.fileno()) + os.dup2(stderr, sys.stderr.fileno()) def generate(model, prompt, models_home=".", llms={}, *args, **kwargs):