mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix:max_tokens must be at least 1, got -950, BadRequestError (#10252)
### What problem does this PR solve? https://github.com/infiniflow/ragflow/issues/10235 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [x] Refactoring
This commit is contained in:
@ -870,6 +870,7 @@ class MistralChat(Base):
|
|||||||
return gen_conf
|
return gen_conf
|
||||||
|
|
||||||
def _chat(self, history, gen_conf={}, **kwargs):
|
def _chat(self, history, gen_conf={}, **kwargs):
|
||||||
|
gen_conf = self._clean_conf(gen_conf)
|
||||||
response = self.client.chat(model=self.model_name, messages=history, **gen_conf)
|
response = self.client.chat(model=self.model_name, messages=history, **gen_conf)
|
||||||
ans = response.choices[0].message.content
|
ans = response.choices[0].message.content
|
||||||
if response.choices[0].finish_reason == "length":
|
if response.choices[0].finish_reason == "length":
|
||||||
@ -882,9 +883,7 @@ class MistralChat(Base):
|
|||||||
def chat_streamly(self, system, history, gen_conf={}, **kwargs):
|
def chat_streamly(self, system, history, gen_conf={}, **kwargs):
|
||||||
if system and history and history[0].get("role") != "system":
|
if system and history and history[0].get("role") != "system":
|
||||||
history.insert(0, {"role": "system", "content": system})
|
history.insert(0, {"role": "system", "content": system})
|
||||||
for k in list(gen_conf.keys()):
|
gen_conf = self._clean_conf(gen_conf)
|
||||||
if k not in ["temperature", "top_p", "max_tokens"]:
|
|
||||||
del gen_conf[k]
|
|
||||||
ans = ""
|
ans = ""
|
||||||
total_tokens = 0
|
total_tokens = 0
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user