|
|
|
@@ -50,12 +50,15 @@ class Retrieval(ComponentBase, ABC): |
|
|
|
component_name = "Retrieval" |
|
|
|
|
|
|
|
def _run(self, history, **kwargs): |
|
|
|
query = [] |
|
|
|
for role, cnt in history[::-1][:self._param.message_history_window_size]: |
|
|
|
if role != "user":continue |
|
|
|
query.append(cnt) |
|
|
|
# query = "\n".join(query) |
|
|
|
query = query[0] |
|
|
|
# query = [] |
|
|
|
# for role, cnt in history[::-1][:self._param.message_history_window_size]: |
|
|
|
# if role != "user":continue |
|
|
|
# query.append(cnt) |
|
|
|
# # query = "\n".join(query) |
|
|
|
# query = query[0] |
|
|
|
query = self.get_input() |
|
|
|
query = str(query["content"][0]) if "content" in query else "" |
|
|
|
|
|
|
|
kbs = KnowledgebaseService.get_by_ids(self._param.kb_ids) |
|
|
|
if not kbs: |
|
|
|
raise ValueError("Can't find knowledgebases by {}".format(self._param.kb_ids)) |