Skip to content

Commit fe3b044

Browse files
update expected value (#414)
* update expected value * use "some" to be order agnostic * obj instead of arr
1 parent ec8989b commit fe3b044

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

evals/tasks/extract_csa.ts

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ export const extract_csa: EvalFunction = async ({
3939
await stagehand.close();
4040

4141
const publications = result.publications;
42-
const expectedLength = 15;
42+
const expectedLength = 14;
4343

4444
const expectedFirstItem = {
45-
publication_date: "01-09-2025",
45+
publication_date: "11-30-2024",
4646
session_type: "Regular Session",
4747
publication_type: "Assembly Weekly History",
48-
annotation: "",
48+
annotation:
49+
"2024 -- This publication includes the complete histories of second-year bills. The complete electronic history of all bills is always available at leginfo.legislature.ca.gov",
4950
};
5051

5152
const expectedLastItem = {
@@ -55,13 +56,13 @@ export const extract_csa: EvalFunction = async ({
5556
annotation: "",
5657
};
5758

58-
if (publications.length !== expectedLength) {
59+
if (publications.length < expectedLength) {
5960
logger.error({
6061
message: "Incorrect number of publications extracted",
6162
level: 0,
6263
auxiliary: {
6364
expected: {
64-
value: expectedLength.toString(),
65+
value: `>= ${expectedLength}`,
6566
type: "integer",
6667
},
6768
actual: {
@@ -78,64 +79,67 @@ export const extract_csa: EvalFunction = async ({
7879
sessionUrl,
7980
};
8081
}
81-
const firstItemMatches =
82-
publications[0].publication_date === expectedFirstItem.publication_date &&
83-
publications[0].session_type === expectedFirstItem.session_type &&
84-
publications[0].publication_type === expectedFirstItem.publication_type &&
85-
publications[0].annotation === expectedFirstItem.annotation;
8682

87-
if (!firstItemMatches) {
83+
const hasExpectedFirstItem = publications.some((publication) => {
84+
return (
85+
publication.publication_date === expectedFirstItem.publication_date &&
86+
publication.session_type === expectedFirstItem.session_type &&
87+
publication.publication_type === expectedFirstItem.publication_type &&
88+
publication.annotation === expectedFirstItem.annotation
89+
);
90+
});
91+
92+
if (!hasExpectedFirstItem) {
8893
logger.error({
89-
message: "First publication extracted does not match expected",
94+
message: "Expected 'first' item not found in publications",
9095
level: 0,
9196
auxiliary: {
9297
expected: {
9398
value: JSON.stringify(expectedFirstItem),
9499
type: "object",
95100
},
96101
actual: {
97-
value: JSON.stringify(publications[0]),
102+
value: JSON.stringify(publications),
98103
type: "object",
99104
},
100105
},
101106
});
102107
return {
103108
_success: false,
104-
error: "First publication extracted does not match expected",
109+
error: "Expected 'first' item not found in publications",
105110
logs: logger.getLogs(),
106111
debugUrl,
107112
sessionUrl,
108113
};
109114
}
110115

111-
const lastItemMatches =
112-
publications[publications.length - 1].publication_date ===
113-
expectedLastItem.publication_date &&
114-
publications[publications.length - 1].session_type ===
115-
expectedLastItem.session_type &&
116-
publications[publications.length - 1].publication_type ===
117-
expectedLastItem.publication_type &&
118-
publications[publications.length - 1].annotation ===
119-
expectedLastItem.annotation;
116+
const hasExpectedLastItem = publications.some((publication) => {
117+
return (
118+
publication.publication_date === expectedLastItem.publication_date &&
119+
publication.session_type === expectedLastItem.session_type &&
120+
publication.publication_type === expectedLastItem.publication_type &&
121+
publication.annotation === expectedLastItem.annotation
122+
);
123+
});
120124

121-
if (!lastItemMatches) {
125+
if (!hasExpectedLastItem) {
122126
logger.error({
123-
message: "Last publication extracted does not match expected",
127+
message: "Expected 'last' item not found in publications",
124128
level: 0,
125129
auxiliary: {
126130
expected: {
127131
value: JSON.stringify(expectedLastItem),
128132
type: "object",
129133
},
130134
actual: {
131-
value: JSON.stringify(publications[publications.length - 1]),
135+
value: JSON.stringify(publications),
132136
type: "object",
133137
},
134138
},
135139
});
136140
return {
137141
_success: false,
138-
error: "Last publication extracted does not match expected",
142+
error: "Expected 'last' item not found in publications",
139143
logs: logger.getLogs(),
140144
debugUrl,
141145
sessionUrl,

0 commit comments

Comments
 (0)