mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
fix: Anthropic param error (#3327)
### What problem does this PR solve? #3263 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -1249,6 +1249,8 @@ class AnthropicChat(Base):
|
|||||||
self.system = system
|
self.system = system
|
||||||
if "max_tokens" not in gen_conf:
|
if "max_tokens" not in gen_conf:
|
||||||
gen_conf["max_tokens"] = 4096
|
gen_conf["max_tokens"] = 4096
|
||||||
|
if "presence_penalty" in gen_conf: del gen_conf["presence_penalty"]
|
||||||
|
if "frequency_penalty" in gen_conf: del gen_conf["frequency_penalty"]
|
||||||
|
|
||||||
ans = ""
|
ans = ""
|
||||||
try:
|
try:
|
||||||
@ -1278,6 +1280,8 @@ class AnthropicChat(Base):
|
|||||||
self.system = system
|
self.system = system
|
||||||
if "max_tokens" not in gen_conf:
|
if "max_tokens" not in gen_conf:
|
||||||
gen_conf["max_tokens"] = 4096
|
gen_conf["max_tokens"] = 4096
|
||||||
|
if "presence_penalty" in gen_conf: del gen_conf["presence_penalty"]
|
||||||
|
if "frequency_penalty" in gen_conf: del gen_conf["frequency_penalty"]
|
||||||
|
|
||||||
ans = ""
|
ans = ""
|
||||||
total_tokens = 0
|
total_tokens = 0
|
||||||
@ -1290,11 +1294,11 @@ class AnthropicChat(Base):
|
|||||||
**gen_conf,
|
**gen_conf,
|
||||||
)
|
)
|
||||||
for res in response.iter_lines():
|
for res in response.iter_lines():
|
||||||
res = res.decode("utf-8")
|
if res.type == 'content_block_delta':
|
||||||
if "content_block_delta" in res and "data" in res:
|
text = res.delta.text
|
||||||
text = json.loads(res[6:])["delta"]["text"]
|
|
||||||
ans += text
|
ans += text
|
||||||
total_tokens += num_tokens_from_string(text)
|
total_tokens += num_tokens_from_string(text)
|
||||||
|
yield ans
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
yield ans + "\n**ERROR**: " + str(e)
|
yield ans + "\n**ERROR**: " + str(e)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user