Skip to content
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

Fixing LitQATaskDatasetcompute_trajectory_metrics crash with bad status extraction #500

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Changes from all 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
21 changes: 13 additions & 8 deletions paperqa/agents/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,20 @@ def compute_trajectory_metrics(
evidence_count: list[float] = []
for t in trajectories:
split_answers = [
re.split(
pattern=GenerateAnswer.ANSWER_SPLIT_REGEX_PATTERN,
string=obs.content,
)
for obs in t.steps[-1].next_observation
if (
isinstance(obs, ToolResponseMessage)
and obs.name == GenerateAnswer.TOOL_FN_NAME
split_answers
for split_answers in (
re.split(
pattern=GenerateAnswer.ANSWER_SPLIT_REGEX_PATTERN,
string=obs.content,
)
for obs in t.steps[-1].next_observation
if (
isinstance(obs, ToolResponseMessage)
and obs.name == GenerateAnswer.TOOL_FN_NAME
)
)
# Filter for places where the regex split succeeded
if len(split_answers) >= 4 # noqa: PLR2004
]
for i, metric_list in enumerate(
(total_paper_count, relevant_paper_count, evidence_count),
Expand Down