Created
November 14, 2023 08:46
-
-
Save samirsaci/cbfb256787d486fc8fdf0f892abd47a3 to your computer and use it in GitHub Desktop.
LangChain SQL - Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create the prompt template | |
template = PromptTemplate( | |
input_variables=["input_question", "context_explanation"], | |
template="""{context_explanation} | |
Question: {input_question} | |
""" | |
) | |
# Agent | |
agent_executor = create_sql_agent( | |
llm=llm, | |
toolkit=toolkit, | |
verbose=True, | |
handle_parsing_errors=True, | |
agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION, | |
return_intermediate_steps=True, | |
) | |
try: | |
print("Question: ", template.format(context_explanation = context_explanation, input_question = input_question)) | |
result = agent_executor.run(template.format(context_explanation = context_explanation, input_question = input_question)) | |
print("Result: ", result) | |
except Exception as e: | |
print(f"An error occurred: {e}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment