File size: 705 Bytes
e74dcf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 29 16:38:41 2022

@author: Sai.Praveen
"""
import streamlit as st
import layer

model = layer.get_model('layer/t5-fine-tuning-with-layer/models/t5-english-to-sql').get_train()
tokenizer = layer.get_model('layer/t5-fine-tuning-with-layer/models/t5-tokenizer').get_train()

def convert(query):
    inputs = tokenizer.encode(f"translate English to SQL: {query}", return_tensors="pt")
    outputs = model.generate(inputs, max_length=1024)
    sql = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return sql


query = st.text_input("Enter Text here", value="")
output =  convert(query)
st.text_area(label="Output Sql Query:", value=output, height=100)