get keep alive from env (#9039)

### What problem does this PR solve?

get keepalive from env

### Type of change

- [x] Refactoring
This commit is contained in:
Stephen Hu
2025-07-25 12:16:33 +08:00
committed by GitHub
parent 6aaad85cc6
commit 53b0b0e583
2 changed files with 6 additions and 4 deletions

View File

@ -469,6 +469,7 @@ class OllamaCV(Base):
self.client = Client(host=kwargs["base_url"])
self.model_name = model_name
self.lang = lang
self.keep_alive = kwargs.get("ollama_keep_alive", int(os.environ.get("OLLAMA_KEEP_ALIVE", -1)))
def describe(self, image):
prompt = self.prompt("")
@ -517,7 +518,7 @@ class OllamaCV(Base):
model=self.model_name,
messages=history,
options=options,
keep_alive=-1,
keep_alive=self.keep_alive,
)
ans = response["message"]["content"].strip()
@ -548,7 +549,7 @@ class OllamaCV(Base):
messages=history,
stream=True,
options=options,
keep_alive=-1,
keep_alive=self.keep_alive,
)
for resp in response:
if resp["done"]: