Skip to content

Commit

Permalink
refactor agent templates
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinHuSh committed Oct 28, 2024
1 parent db6e4d7 commit ac89e36
Show file tree
Hide file tree
Showing 5 changed files with 1,616 additions and 2,780 deletions.
10 changes: 2 additions & 8 deletions agent/component/retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,19 @@ def check(self):
self.check_decimal_float(self.similarity_threshold, "[Retrieval] Similarity threshold")
self.check_decimal_float(self.keywords_similarity_weight, "[Retrieval] Keywords similarity weight")
self.check_positive_number(self.top_n, "[Retrieval] Top N")
self.check_empty(self.kb_ids, "[Retrieval] Knowledge bases")


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 = 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))
return Retrieval.be_output("")

embd_nms = list(set([kb.embd_id for kb in kbs]))
assert len(embd_nms) == 1, "Knowledge bases use different embedding models."

Expand Down
Loading

0 comments on commit ac89e36

Please sign in to comment.