Преглед на файлове

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)
tags/v0.14.0
Kevin Hu преди 11 месеца
родител
ревизия
34d1daac67
No account linked to committer's email address
променени са 1 файла, в които са добавени 7 реда и са изтрити 3 реда
  1. 7
    3
      rag/llm/chat_model.py

+ 7
- 3
rag/llm/chat_model.py Целия файл

@@ -1249,6 +1249,8 @@ class AnthropicChat(Base):
self.system = system
if "max_tokens" not in gen_conf:
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 = ""
try:
@@ -1278,6 +1280,8 @@ class AnthropicChat(Base):
self.system = system
if "max_tokens" not in gen_conf:
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 = ""
total_tokens = 0
@@ -1290,11 +1294,11 @@ class AnthropicChat(Base):
**gen_conf,
)
for res in response.iter_lines():
res = res.decode("utf-8")
if "content_block_delta" in res and "data" in res:
text = json.loads(res[6:])["delta"]["text"]
if res.type == 'content_block_delta':
text = res.delta.text
ans += text
total_tokens += num_tokens_from_string(text)
yield ans
except Exception as e:
yield ans + "\n**ERROR**: " + str(e)


Loading…
Отказ
Запис