Skip to content

Commit

Permalink
Node group error type (#185)
Browse files Browse the repository at this point in the history
* add new error

* update for compatibility wit hdev environment

* update

* fix mmr score

* make mmr more readable
  • Loading branch information
prasmussen15 authored Oct 11, 2024
1 parent 6c3b32e commit fca1f73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions graphiti_core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def __init__(self, group_ids: list[str]):
super().__init__(self.message)


class GroupsNodesNotFoundError(GraphitiError):
"""Raised when no nodes are found for a list of group ids."""

def __init__(self, group_ids: list[str]):
self.message = f'no nodes found for group ids {group_ids}'
super().__init__(self.message)


class NodeNotFoundError(GraphitiError):
"""Raised when a node is not found."""

Expand Down
2 changes: 1 addition & 1 deletion graphiti_core/search/search_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def maximal_marginal_relevance(
candidates_with_mmr: list[tuple[str, float]] = []
for candidate in candidates:
max_sim = max([np.dot(normalize_l2(candidate[1]), normalize_l2(c[1])) for c in candidates])
mmr = mmr_lambda * np.dot(candidate[1], query_vector) + (1 - mmr_lambda) * max_sim
mmr = mmr_lambda * np.dot(candidate[1], query_vector) - (1 - mmr_lambda) * max_sim
candidates_with_mmr.append((candidate[0], mmr))

candidates_with_mmr.sort(reverse=True, key=lambda c: c[1])
Expand Down

0 comments on commit fca1f73

Please sign in to comment.