From 03874b590f0f3b0fe13dd69d441fa204d2c20cf2 Mon Sep 17 00:00:00 2001 From: whuwkl Date: Wed, 29 Jan 2025 23:21:55 +0800 Subject: [PATCH] fix: pass the mypy check. --- camel/utils/deduplication.py | 4 +++- pyproject.toml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/camel/utils/deduplication.py b/camel/utils/deduplication.py index 5717db27a1..cbb28884d0 100644 --- a/camel/utils/deduplication.py +++ b/camel/utils/deduplication.py @@ -149,7 +149,7 @@ def deduplicate_internally( embeddings = embedding_instance.embed_list(texts) else: # Use pre-supplied embeddings. - if len(embeddings) != len(texts): + if embeddings and len(embeddings) != len(texts): raise ValueError( "The length of 'embeddings' does not match the length " "of 'texts'." @@ -184,6 +184,8 @@ def deduplicate_internally( unique_ids = [] unique_embeddings_dict = {} + assert embeddings, "embeddings must be valid" + for i, (_, emb) in enumerate(zip(texts, embeddings)): if i not in duplicate_to_target_map: unique_ids.append(i) diff --git a/pyproject.toml b/pyproject.toml index 51109b9385..dae2f1acaa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -535,5 +535,6 @@ module = [ "tree-sitter", "ragas", "pandasai", + "sklearn.metrics.pairwise", ] ignore_missing_imports = true \ No newline at end of file