Refa: remove ollama keep alive. (#7560)

### What problem does this PR solve?

#7518

### Type of change

- [x] Refactoring
This commit is contained in:
Kevin Hu 2025-05-09 17:51:49 +08:00 committed by GitHub
parent 2ccec93d71
commit 5b626870d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 6 deletions

View File

@ -915,7 +915,7 @@ class OllamaChat(Base):
if "frequency_penalty" in gen_conf:
options["frequency_penalty"] = gen_conf["frequency_penalty"]
response = self.client.chat(model=self.model_name, messages=history, options=options, keep_alive=10)
response = self.client.chat(model=self.model_name, messages=history, options=options)
ans = response["message"]["content"].strip()
token_count = response.get("eval_count", 0) + response.get("prompt_eval_count", 0)
return ans, token_count
@ -944,7 +944,7 @@ class OllamaChat(Base):
ans = ""
try:
response = self.client.chat(model=self.model_name, messages=history, stream=True, options=options, keep_alive=10)
response = self.client.chat(model=self.model_name, messages=history, stream=True, options=options)
for resp in response:
if resp["done"]:
token_count = resp.get("prompt_eval_count", 0) + resp.get("eval_count", 0)

View File

@ -500,8 +500,7 @@ class OllamaCV(Base):
response = self.client.chat(
model=self.model_name,
messages=history,
options=options,
keep_alive=-1
options=options
)
ans = response["message"]["content"].strip()
@ -531,8 +530,7 @@ class OllamaCV(Base):
model=self.model_name,
messages=history,
stream=True,
options=options,
keep_alive=-1
options=options
)
for resp in response:
if resp["done"]: