mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-15 18:25:59 +08:00
Refa: remove ollama keep alive. (#7560)
### What problem does this PR solve? #7518 ### Type of change - [x] Refactoring
This commit is contained in:
parent
2ccec93d71
commit
5b626870d0
@ -915,7 +915,7 @@ class OllamaChat(Base):
|
|||||||
if "frequency_penalty" in gen_conf:
|
if "frequency_penalty" in gen_conf:
|
||||||
options["frequency_penalty"] = gen_conf["frequency_penalty"]
|
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()
|
ans = response["message"]["content"].strip()
|
||||||
token_count = response.get("eval_count", 0) + response.get("prompt_eval_count", 0)
|
token_count = response.get("eval_count", 0) + response.get("prompt_eval_count", 0)
|
||||||
return ans, token_count
|
return ans, token_count
|
||||||
@ -944,7 +944,7 @@ class OllamaChat(Base):
|
|||||||
|
|
||||||
ans = ""
|
ans = ""
|
||||||
try:
|
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:
|
for resp in response:
|
||||||
if resp["done"]:
|
if resp["done"]:
|
||||||
token_count = resp.get("prompt_eval_count", 0) + resp.get("eval_count", 0)
|
token_count = resp.get("prompt_eval_count", 0) + resp.get("eval_count", 0)
|
||||||
|
@ -500,8 +500,7 @@ class OllamaCV(Base):
|
|||||||
response = self.client.chat(
|
response = self.client.chat(
|
||||||
model=self.model_name,
|
model=self.model_name,
|
||||||
messages=history,
|
messages=history,
|
||||||
options=options,
|
options=options
|
||||||
keep_alive=-1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
ans = response["message"]["content"].strip()
|
ans = response["message"]["content"].strip()
|
||||||
@ -531,8 +530,7 @@ class OllamaCV(Base):
|
|||||||
model=self.model_name,
|
model=self.model_name,
|
||||||
messages=history,
|
messages=history,
|
||||||
stream=True,
|
stream=True,
|
||||||
options=options,
|
options=options
|
||||||
keep_alive=-1
|
|
||||||
)
|
)
|
||||||
for resp in response:
|
for resp in response:
|
||||||
if resp["done"]:
|
if resp["done"]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user