Feat: support uploading in dialog.

This commit is contained in:
Kevin Hu 2025-12-01 16:25:15 +08:00
parent 221947acc4
commit f7279a3bf1
2 changed files with 6 additions and 1 deletions

View file

@ -179,6 +179,9 @@ class DialogService(CommonService):
return res
def chat_solo(dialog, messages, stream=True):
attachments = ""
if "files" in messages[-1]:
attachments = "\n\n".join(FileService.get_files(messages[-1]["files"]))
if TenantLLMService.llm_id2llm_type(dialog.llm_id) == "image2text":
chat_mdl = LLMBundle(dialog.tenant_id, LLMType.IMAGE2TEXT, dialog.llm_id)
else:
@ -189,6 +192,8 @@ def chat_solo(dialog, messages, stream=True):
if prompt_config.get("tts"):
tts_mdl = LLMBundle(dialog.tenant_id, LLMType.TTS)
msg = [{"role": m["role"], "content": re.sub(r"##\d+\$\$", "", m["content"])} for m in messages if m["role"] != "system"]
if attachments and msg:
msg[-1]["content"] += attachments
if stream:
last_ans = ""
delta_ans = ""

View file

@ -645,7 +645,7 @@ class Dealer:
if not chunks:
return []
idx_nms = [index_name(tid) for tid in tenant_ids]
mom_chunks = defaultdict([])
mom_chunks = defaultdict(list)
i = 0
while i < len(chunks):
ck = chunks[i]