File size: 1,137 Bytes
d3eaa89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import streamlit as st 
import google.generativeai as genai


genai.configure(api_key="AIzaSyDHXUnKE7cPbgxMg7BrRSQkO1WIBD0PsuI")

model = genai.GenerativeModel('gemini-pro')



st.set_page_config(page_title="AI SQL Query Generator")
st.markdown(
    """ 
    <div style="text-align:center;">
    <h1> SQL Query Generator using LLM </h1>
    <h3>This tool can generate SQL queries for given prompt</h3>
    <h3>With Explanation of Queries </h3>
    </div>
    """,
    unsafe_allow_html=True, 
)

text_input = st.text_area("Enter you Query here:")

submit = st.button("Generate SQL Query")

if submit:
    with st.spinner("Generating SQL Query..."):
        template = """ 
        Generate a SQL query for 
        '''
        {text_input}
        '''
        Also explain the query and concepts used in generated query.
        """
        formatted_template = template.format(text_input=text_input)
        
        # st.write(formatted_template)
        response = model.generate_content(formatted_template)
        sql_query = response.text
        st.write("Generated query with explaination: ")
        st.write(sql_query)