mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Feat: support uploading in dialog. (#11634)
### What problem does this PR solve? #9590 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -179,6 +179,9 @@ class DialogService(CommonService):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def chat_solo(dialog, messages, stream=True):
|
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":
|
if TenantLLMService.llm_id2llm_type(dialog.llm_id) == "image2text":
|
||||||
chat_mdl = LLMBundle(dialog.tenant_id, LLMType.IMAGE2TEXT, dialog.llm_id)
|
chat_mdl = LLMBundle(dialog.tenant_id, LLMType.IMAGE2TEXT, dialog.llm_id)
|
||||||
else:
|
else:
|
||||||
@ -189,6 +192,8 @@ def chat_solo(dialog, messages, stream=True):
|
|||||||
if prompt_config.get("tts"):
|
if prompt_config.get("tts"):
|
||||||
tts_mdl = LLMBundle(dialog.tenant_id, LLMType.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"]
|
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:
|
if stream:
|
||||||
last_ans = ""
|
last_ans = ""
|
||||||
delta_ans = ""
|
delta_ans = ""
|
||||||
|
|||||||
@ -645,7 +645,7 @@ class Dealer:
|
|||||||
if not chunks:
|
if not chunks:
|
||||||
return []
|
return []
|
||||||
idx_nms = [index_name(tid) for tid in tenant_ids]
|
idx_nms = [index_name(tid) for tid in tenant_ids]
|
||||||
mom_chunks = defaultdict([])
|
mom_chunks = defaultdict(list)
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(chunks):
|
while i < len(chunks):
|
||||||
ck = chunks[i]
|
ck = chunks[i]
|
||||||
|
|||||||
Reference in New Issue
Block a user