How to use this model ?
#1
by
tusharsarde
- opened
For example I am using following model to predict sql query with streamlit.
if st.button("Predict"):
tok_model = "juierror/flan-t5-text2sql-with-schema"
tokenizer,model = tokmod(tok_model)
# text = "what interface is measure indicator code = 72_HR_ABX and version is 1 and source is TD"
table_name = "df_qna"
table_column = ['Patient_Name', 'Country', 'Disease', 'CUI', 'Snomed', 'Oxygen_Rate','Med_Type', 'Admission_Date']
txt_sql = inference(question=sql_txt, table=table_column)
### SQL Modification
sql_avg = ["AVG","COUNT","DISTINCT","MAX","MIN","SUM"]
txt_sql = txt_sql.replace("table",table_name)
sql_quotes = []
for match in re.finditer("=",txt_sql):
new_txt = txt_sql[match.span()[1]+1:]
try:
match2 = re.search("AND",new_txt)
sql_quotes.append((new_txt[:match2.span()[0]]).strip())
except:
sql_quotes.append(new_txt.strip())
for i in sql_quotes:
qts = "'" + i + "'"
txt_sql = txt_sql.replace(i, qts)
for r in sql_avg:
if r in txt_sql:
rr = re.search(rf"{r} (\w+)", txt_sql)
init = " " + rr[1]
qts = "(" + rr[1] + ")"
txt_sql = txt_sql.replace(init,qts)
else:
pass
st.success(f"{txt_sql}")
all_students = sqldf(txt_sql)
st.text("Output - ")
st.write(all_students)