Skip to content

Commit

Permalink
Allow to load structured documents for ms marco v2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mam10eks committed Aug 11, 2024
1 parent 8676f47 commit a162470
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions chatnoir_api/cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Union
from urllib.parse import urljoin
from uuid import UUID, uuid5, NAMESPACE_URL
import json

from requests import get, Response

Expand Down Expand Up @@ -31,4 +32,11 @@ def cache_contents(
}
)
response.raise_for_status()

if index in (Index.MSMarcoV21, Index.MSMarcoV21Segmented):
ret = json.loads(response.text)
if uuid_or_document_id != ret['docid']:
raise ValueError(f'Document Id is not as expected. Expected "{uuid_or_document_id}" but have "{ret["docid"]}".')
return ret

return response.text

0 comments on commit a162470

Please sign in to comment.