Pārlūkot izejas kodu

add doc ids to chat (#1944)

### What problem does this PR solve?

### Type of change

- [x] Performance Improvement
tags/v0.10.0
Kevin Hu pirms 1 gada
vecāks
revīzija
78ed8fe9a5
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
2 mainītis faili ar 5 papildinājumiem un 0 dzēšanām
  1. 3
    0
      api/db/services/dialog_service.py
  2. 2
    0
      rag/nlp/search.py

+ 3
- 0
api/db/services/dialog_service.py Parādīt failu

attachments = kwargs["doc_ids"].split(",") if "doc_ids" in kwargs else None attachments = kwargs["doc_ids"].split(",") if "doc_ids" in kwargs else None
if "doc_ids" in messages[-1]: if "doc_ids" in messages[-1]:
attachments = messages[-1]["doc_ids"] attachments = messages[-1]["doc_ids"]
for m in messages[:-1]:
if "doc_ids" in m:
attachments.extend(m["doc_ids"])
embd_mdl = LLMBundle(dialog.tenant_id, LLMType.EMBEDDING, embd_nms[0]) embd_mdl = LLMBundle(dialog.tenant_id, LLMType.EMBEDDING, embd_nms[0])
if llm_id2llm_type(dialog.llm_id) == "image2text": if llm_id2llm_type(dialog.llm_id) == "image2text":

+ 2
- 0
rag/nlp/search.py Parādīt failu

es_logger.info("TOTAL: {}".format(self.es.getTotal(res))) es_logger.info("TOTAL: {}".format(self.es.getTotal(res)))
if self.es.getTotal(res) == 0 and "knn" in s: if self.es.getTotal(res) == 0 and "knn" in s:
bqry, _ = self.qryr.question(qst, min_match="10%") bqry, _ = self.qryr.question(qst, min_match="10%")
if req.get("doc_ids"):
bqry = Q("bool", must=[])
bqry = self._add_filters(bqry, req) bqry = self._add_filters(bqry, req)
s["query"] = bqry.to_dict() s["query"] = bqry.to_dict()
s["knn"]["filter"] = bqry.to_dict() s["knn"]["filter"] = bqry.to_dict()

Notiek ielāde…
Atcelt
Saglabāt