(cx_Oracle.DatabaseError) ORA-00933: SQL command not properly ended
[SQL: SELECT state FROM add_master WHERE city = ‘Danvers’ FETCH FIRST 5 ROWS ONLY;]
Here, I am using default text-davinci-003 model, connected with my oracle database… while executing
response = SQLDatabaseChain.from_llm(llm=llm, db=db,verbose=True).run(conversation) this model… in response… getting this error…
Is there any way to remove semicolon in the intermediate step…
Thank you
Going on from @udm17’s post, if you show an example (called a “shot”) Query string that does not contain a ; then the model will typically follow your lead.
is there any way to get an intermediate step, which generates sqlQuery from
response = SQLDatabaseChain.from_llm(llm=llm, db=db,verbose=True).run(conversation)… so that i can do transformation on that query and proceed the data fetching process
If you have a setup like this, it would be best to add a single sample to the prompt like @Foxalabs has suggested or you can add an instruction in the prompt to not end the SQL query with a ;.
I’m not sure if the chain will allow for an intermediate step
I haven’t worked with python or Oracle, but if you look at SQLDatabaseChain.from_llm(llm=llm, db=db,verbose=True).run(conversation)
there are actually two function calls happening, first is to SQLDatabaseChain.from_llm(), and the value that is returned from that function, you then are calling .run() on it, while passing in I guess yoiur conversation context.
So if you break it up into multiple lines, you should be able to insert your own intermediate step.
Capture the return value of from_llm() into a new variable.
Run your custom logic on it (“does it end in a semi colon? if so, remove it” i think is what you are wanting?)
call .run() on it, and set its return value into your “response” variable
Edit- by the way, it is awlays useful to dont crop out the line numebrs when you’re posting code