set ollama keep_alive (#985)

### What problem does this PR solve?

#980 

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
KevinHuSh 2024-05-30 11:27:58 +08:00 committed by GitHub
parent c62834f870
commit f077b57f8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -532,8 +532,8 @@ def init_llm_factory():
{ {
"fid": factory_infos[12]["name"], "fid": factory_infos[12]["name"],
"llm_name": "BAAI/bge-reranker-v2-m3", "llm_name": "BAAI/bge-reranker-v2-m3",
"tags": "LLM,CHAT,", "tags": "RE-RANK,2k",
"max_tokens": 16385, "max_tokens": 2048,
"model_type": LLMType.RERANK.value "model_type": LLMType.RERANK.value
}, },
] ]

View File

@ -303,7 +303,8 @@ class OllamaChat(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()
return ans, response["eval_count"] + response.get("prompt_eval_count", 0) return ans, response["eval_count"] + response.get("prompt_eval_count", 0)
@ -325,7 +326,8 @@ class OllamaChat(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"]: