Fix: toc no chunk found issue. (#12197)

### What problem does this PR solve?

#12170

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu
2025-12-25 14:06:20 +08:00
committed by GitHub
parent 5ebabf5bed
commit 8cbfb5aef6
3 changed files with 9 additions and 2 deletions

View File

@ -827,6 +827,11 @@ async def relevant_chunks_with_toc(query: str, toc:list[dict], chat_mdl, topn: i
META_DATA = load_prompt("meta_data")
async def gen_metadata(chat_mdl, schema:dict, content:str):
template = PROMPT_JINJA_ENV.from_string(META_DATA)
for k, desc in schema.items():
if "enum" in desc and not desc.get("enum"):
del desc["enum"]
if desc.get("enum"):
desc["description"] += "\n** Extracted values must strictly match the given list specified by `enum`. **"
system_prompt = template.render(content=content, schema=schema)
user_prompt = "Output: "
_, msg = message_fit_in(form_message(system_prompt, user_prompt), chat_mdl.max_length)