Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions dialogue2graph/metrics/no_llm_metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавить в классы семплинга и генерации

return bool(re.match(r"^hello|^hi|^greetings", text, flags=re.IGNORECASE))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добить прощание



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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отдельно добавить использование LLM



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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Проверить на валидность