소스 검색

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 파일 보기

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:
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
**gen_conf, **gen_conf,
) )
for res in response.iter_lines(): 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 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)



Loading…
취소
저장