-
Notifications
You must be signed in to change notification settings - Fork 2
Propose validators to detect start loops #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
7f4a1de
9f65ff5
9b43684
8875195
205df40
e1d08f3
bb884da
18ea27c
34c5742
34547c1
060d5b5
9fe45ff
04cbde5
230731a
f9d6508
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| from typing import List, TypedDict, Optional | ||
| import numpy as np | ||
| import networkx as nx | ||
| import re | ||
|
|
||
| from dialogue2graph.pipelines.core.graph import BaseGraph | ||
| from dialogue2graph.pipelines.core.dialogue import Dialogue | ||
|
|
@@ -607,3 +608,30 @@ def compute_graph_metrics(graph_list: List[BaseGraph]) -> dict: | |
| "total_edges": total_edges, | ||
| "total_nodes": total_nodes, | ||
| } | ||
|
|
||
|
|
||
| def _message_has_greeting(text: str) -> bool: | ||
| return bool(re.match(r"^hello|^hi|^greetings", text, flags=re.IGNORECASE)) | ||
|
||
|
|
||
|
|
||
| def is_greeting_repeated(dialogues: list[Dialogue]) -> bool: | ||
| """ | ||
| Checks whether greeting is repeated within dialogues. | ||
| Returns True if greeting has been repeated, False otherwise. | ||
| """ | ||
| for dialogue in dialogues: | ||
| for i, message in enumerate(dialogue.messages): | ||
| if i != 0 and message.participant == "assistant" and _message_has_greeting(message.text): | ||
| return True | ||
| return False | ||
|
||
|
|
||
|
|
||
| def has_loop_to_start(G: BaseGraph) -> bool: | ||
| """ | ||
| Checks whether graph has node returning to the start node. | ||
| Returns True if there is a loop to start, False otherwise | ||
| """ | ||
| for edge in G.graph.edges: | ||
| if edge[1] == 1: | ||
| return True | ||
| return False | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавить в классы семплинга и генерации