Refa: chat with tools. (#8210)

### What problem does this PR solve?


### Type of change
- [x] Refactoring
This commit is contained in:
Kevin Hu
2025-06-12 12:31:10 +08:00
committed by GitHub
parent 44287fb05f
commit 56ee69e9d9
2 changed files with 130 additions and 171 deletions

View File

@ -119,7 +119,7 @@ def kb_prompt(kbinfos, max_tokens):
doc2chunks = defaultdict(lambda: {"chunks": [], "meta": []})
for i, ck in enumerate(kbinfos["chunks"][:chunks_num]):
cnt = f"---\nID: {i}\n" + (f"URL: {ck['url']}\n" if "url" in ck else "")
cnt += ck["content_with_weight"]
cnt += re.sub(r"( style=\"[^\"]+\"|</?(html|body|head|title)>|<!DOCTYPE html>)", " ", ck["content_with_weight"], flags=re.DOTALL|re.IGNORECASE)
doc2chunks[ck["docnm_kwd"]]["chunks"].append(cnt)
doc2chunks[ck["docnm_kwd"]]["meta"] = docs.get(ck["doc_id"], {})