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

chore(generative-ai): add additional accuracy tests COMPASS-7299 #5091

Merged
merged 1 commit into from
Nov 10, 2023
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
80 changes: 79 additions & 1 deletion packages/compass-generative-ai/scripts/ai-accuracy-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const TESTS_TO_RUN_CONCURRENTLY = 3;
// To avoid rate limit we also reduce the time between tests running
// when the test returns a result quickly.
const ADD_TIMEOUT_BETWEEN_TESTS_THRESHOLD_MS = 5000;
const TIMEOUT_BETWEEN_TESTS_MS = 2000;
const TIMEOUT_BETWEEN_TESTS_MS = 3000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

still issues with the rate limit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Saw it once on my local when I ran it vs 50 so I figured we might as well be safe here. Shouldn't slow it down too much.


let PQueue;

Expand Down Expand Up @@ -500,6 +500,84 @@ const tests = [
},
]),
},
{
type: 'query',
databaseName: 'sample_airbnb',
collectionName: 'listingsAndReviews',
userInput:
'give me just the price and the first 3 amenities of the listing has "Step-free access" in its amenities.',
assertResult: anyOf([
isDeepStrictEqualTo([
{
_id: '10108388',
price: {
$numberDecimal: '185.00',
},
amenities: ['TV', 'Wifi', 'Air conditioning'],
},
]),
isDeepStrictEqualTo([
{
price: {
$numberDecimal: '185.00',
},
amenities: ['TV', 'Wifi', 'Air conditioning'],
},
]),
]),
},
{
type: 'aggregation',
databaseName: 'sample_airbnb',
collectionName: 'listingsAndReviews',
userInput:
'¿Qué alojamiento tiene el precio más bajo? devolver el número en un campo llamado "precio"',
assertResult: anyOf([
isDeepStrictEqualTo([
{
precio: {
$numberDecimal: '40.00',
},
},
]),
isDeepStrictEqualTo([
{
_id: '10117617',
precio: {
$numberDecimal: '40.00',
},
},
]),
isDeepStrictEqualTo([
{
precio: 40,
},
]),
]),
},
{
type: 'aggregation',
databaseName: 'sample_airbnb',
collectionName: 'listingsAndReviews',
userInput:
'give only me the cancellation policy and host url of the most expensive listing',
assertResult: anyOf([
isDeepStrictEqualTo([
{
cancellation_policy: 'moderate',
host: {
host_url: 'https://www.airbnb.com/users/show/51471538',
},
},
]),
isDeepStrictEqualTo([
{
cancellation_policy: 'moderate',
host_url: 'https://www.airbnb.com/users/show/51471538',
},
]),
]),
},
{
type: 'aggregation',
databaseName: 'netflix',
Expand Down
Loading