From cce132d1460b4f52541cb4a6f13219fb8fe4f907 Mon Sep 17 00:00:00 2001 From: felixocker Date: Wed, 25 Oct 2023 22:36:57 +0200 Subject: [PATCH] fix sparql queries for relations in schema description (#9136) - **Description**: Fix for the SPARQL QA chain: fixed SPARQL queries for retrieving information about relations in the graph to create a textual description of the schema for the language model. This should resolve #8907 - **Issue**: #8907 - **Dependencies**: None - **Tag maintainer**: @baskaryan, @hwchase17 --- libs/langchain/langchain/graphs/rdf_graph.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/langchain/langchain/graphs/rdf_graph.py b/libs/langchain/langchain/graphs/rdf_graph.py index f3388238ed..1a2b89ba87 100644 --- a/libs/langchain/langchain/graphs/rdf_graph.py +++ b/libs/langchain/langchain/graphs/rdf_graph.py @@ -45,7 +45,7 @@ rel_query_rdf = prefixes["rdfs"] + ( """SELECT DISTINCT ?rel ?com\n""" """WHERE { \n""" """ ?subj ?rel ?obj . \n""" - """ OPTIONAL { ?cls rdfs:comment ?com } \n""" + """ OPTIONAL { ?rel rdfs:comment ?com } \n""" """}""" ) @@ -56,7 +56,7 @@ rel_query_rdfs = ( """SELECT DISTINCT ?rel ?com\n""" """WHERE { \n""" """ ?rel a/rdfs:subPropertyOf* rdf:Property . \n""" - """ OPTIONAL { ?cls rdfs:comment ?com } \n""" + """ OPTIONAL { ?rel rdfs:comment ?com } \n""" """}""" ) ) @@ -68,7 +68,7 @@ op_query_owl = ( """SELECT DISTINCT ?op ?com\n""" """WHERE { \n""" """ ?op a/rdfs:subPropertyOf* owl:ObjectProperty . \n""" - """ OPTIONAL { ?cls rdfs:comment ?com } \n""" + """ OPTIONAL { ?op rdfs:comment ?com } \n""" """}""" ) ) @@ -80,7 +80,7 @@ dp_query_owl = ( """SELECT DISTINCT ?dp ?com\n""" """WHERE { \n""" """ ?dp a/rdfs:subPropertyOf* owl:DatatypeProperty . \n""" - """ OPTIONAL { ?cls rdfs:comment ?com } \n""" + """ OPTIONAL { ?dp rdfs:comment ?com } \n""" """}""" ) )