fix: guard against empty query in SPARQL generator (#870)

This commit is contained in:
SAY-5 2026-05-12 00:34:03 -07:00
parent dd974b0cac
commit e03df17f5c

View file

@ -202,11 +202,14 @@ ASK {{
if response and isinstance(response, dict):
query = response.get('query', '').strip()
if query.upper().startswith(('SELECT', 'ASK', 'CONSTRUCT', 'DESCRIBE')):
parts = query.split()
if parts and parts[0].upper() in (
'SELECT', 'ASK', 'CONSTRUCT', 'DESCRIBE'
):
return SPARQLQuery(
query=query,
variables=self._extract_variables(query),
query_type=query.split()[0].upper(),
query_type=parts[0].upper(),
explanation=response.get('explanation', 'Generated by LLM'),
complexity_score=self._calculate_complexity(query)
)