I was previously using SQLDatabaseChain to connect LLM (Language Model) with my database, and it was functioning correctly with GPT-3.5. However, when attempting the same process with GPT-4, I encountered an error stating "incorrect syntax near 's"
To address this issue, I opted to use SQLDatabaseToolkit
and the create_sql_agent
function. However, I encountered a problem with this approach as I was unable to pass a prompt. When attempting to include a PromptTemplate
in the create_sql_agent
argument, it resulted in errors.
ValueError: Prompt missing required variables: {'tool_names', 'agent_scratchpad', 'tools'}
Below is my code:
toolkit = SQLDatabaseToolkit(db=db, llm=llm)
agent_executor = create_sql_agent(
llm=llm,
toolkit=toolkit,
verbose=True,
prompt=MSSQL_PROMPT,
)
I found solution for it.
will worked for me. And it also work with prompt based approach. So if you want to add prompt in it then it should be like
where
You can add more data in prompt as per your use cases.