mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-03 05:34:01 +00:00
Fixed sparql SELECT and UPDATE query function (#7758)
- Description: Changed "SELECT" and "UPDTAE" intent check from "=" to "in", - Issue: Based on my own testing, most of the LLM (StarCoder, NeoGPT3, etc..) doesn't return a single word response ("SELECT" / "UPDATE") through this modification, we can accomplish the same output without curated prompt engineering. - Dependencies: None - Tag maintainer: @baskaryan - Twitter handle: @aditya_0290 Thank you for maintaining this library, Keep up the good efforts. --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
parent
3662aca7d4
commit
00de334f81
@ -85,15 +85,17 @@ class GraphSparqlQAChain(Chain):
|
||||
_intent = self.sparql_intent_chain.run({"prompt": prompt}, callbacks=callbacks)
|
||||
intent = _intent.strip()
|
||||
|
||||
if intent == "SELECT":
|
||||
sparql_generation_chain = self.sparql_generation_select_chain
|
||||
elif intent == "UPDATE":
|
||||
sparql_generation_chain = self.sparql_generation_update_chain
|
||||
else:
|
||||
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"):
|
||||
sparql_generation_chain = self.sparql_generation_select_chain
|
||||
intent = "SELECT"
|
||||
else:
|
||||
sparql_generation_chain = self.sparql_generation_update_chain
|
||||
intent = "UPDATE"
|
||||
|
||||
_run_manager.on_text("Identified intent:", end="\n", verbose=self.verbose)
|
||||
_run_manager.on_text(intent, color="green", end="\n", verbose=self.verbose)
|
||||
|
Loading…
Reference in New Issue
Block a user