Skip to content

Commit 4b9ad04

Browse files
committed
fix: fix schema loading
1 parent 4c3d2f9 commit 4b9ad04

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

compose.text2sparql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
env_file:
1717
- .env
1818
environment:
19-
- BENCH_MODEL=openrouter/openai/gpt-oss-120b:free
19+
- BENCH_MODEL=openrouter/openai/gpt-oss-120b
2020
- PYTHONUNBUFFERED=1
2121
- VECTORDB_URL=http://vectordb:6334/
2222
# - DBPEDIA_URL=http://141.57.8.18:9081/sparql

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ dev = [
9292
]
9393
bench = [
9494
"pytrec-eval",
95+
# NOTE: use maintained pytrec_eval_terrier https://github.com/terrierteam/pytrec_eval
9596
]
9697

9798
# # Required for onnxruntime-gpu on CUDA 12

tests/text2sparql/api.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ def get_dataset_id_from_iri(dataset_iri: str) -> str:
3535
for dataset_iri in DATASETS_ENDPOINTS.keys():
3636
try:
3737
with open(
38-
os.path.join("/", "data", f"{get_dataset_id_from_iri(dataset_iri)}_schema.json"),
38+
os.path.join("data", f"{get_dataset_id_from_iri(dataset_iri)}_schema.json"),
3939
encoding="utf-8",
4040
) as f:
41+
print(f"Loading schema for dataset {dataset_iri} from {f}...")
4142
SCHEMAS[dataset_iri] = json.load(f)
4243
except FileNotFoundError:
4344
print(
44-
f"Schema file for dataset {dataset_iri} not found. Please run the indexing script to generate the schema files."
45+
f"⚠️ Schema file for dataset {dataset_iri} not found. Please run the indexing script to generate the schema files."
4546
)
47+
SCHEMAS[dataset_iri] = {}
4648

4749
RAG_PROMPT = """
4850
@@ -179,7 +181,7 @@ async def get_answer(question: str, dataset: str):
179181

180182
except Exception as e:
181183
validation_output = validate_sparql(
182-
query=generated_sparql, endpoint_url=endpoint_url, endpoints_void_dict=SCHEMAS[dataset]
184+
query=generated_sparql, endpoint_url=endpoint_url, endpoints_void_dict=SCHEMAS.get(dataset, {})
183185
)
184186
if validation_output["errors"]:
185187
error_str = "- " + "\n- ".join(validation_output["errors"])

0 commit comments

Comments
 (0)