The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Fix bug in SPARQL intent selection (#8521)
Mario Scrocca334bd8ebbee5
diff --git a/libs/langchain/langchain/chains/graph_qa/sparql.py b/libs/langchain/langchain/chains/graph_qa/sparql.pyindex eb8a365d76..2e1c017748 100644--- a/libs/langchain/langchain/chains/graph_qa/sparql.py+++ b/libs/langchain/langchain/chains/graph_qa/sparql.py@@ -84,17 +84,17 @@ class GraphSparqlQAChain(Chain):_intent = self.sparql_intent_chain.run({"prompt": prompt}, callbacks=callbacks)intent = _intent.strip()- if "SELECT" not in intent and "UPDATE" not in intent:- raise ValueError(- "I am sorry, but this prompt seems to fit none of the currently "- "supported SPARQL query types, i.e., SELECT and UPDATE."- )- elif intent.find("SELECT") < intent.find("UPDATE"):+ if "SELECT" in intent and "UPDATE" not in intent:sparql_generation_chain = self.sparql_generation_select_chainintent = "SELECT"- else:+ elif "UPDATE" in intent and "SELECT" not in intent:sparql_generation_chain = self.sparql_generation_update_chainintent = "UPDATE"+ else:+ raise ValueError(+ "I am sorry, but this prompt seems to fit none of the currently "+ "supported SPARQL query types, i.e., SELECT and UPDATE."+ )_run_manager.on_text("Identified intent:", end="\n", verbose=self.verbose)_run_manager.on_text(intent, color="green", end="\n", verbose=self.verbose)