laxminarasimha6 commited on
Commit
8a6f366
1 Parent(s): 5730ab0

Upload 17 files

Browse files
SQL LLM App with Gemini Pro/.env ADDED
@@ -0,0 +1 @@
 
 
1
+ GOOGLE_API_KEY = "AIzaSyAq4dZC1shBKa6MXkAjOP80seDZ0CAChYc"
SQL LLM App with Gemini Pro/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
SQL LLM App with Gemini Pro/.idea/SQL LLM App with Gemini Pro.iml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
SQL LLM App with Gemini Pro/.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="PyStubPackagesAdvertiser" enabled="true" level="WARNING" enabled_by_default="true">
5
+ <option name="ignoredPackages">
6
+ <list>
7
+ <option value="pyspark-stubs==3.0.0.post3" />
8
+ </list>
9
+ </option>
10
+ </inspection_tool>
11
+ </profile>
12
+ </component>
SQL LLM App with Gemini Pro/.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
SQL LLM App with Gemini Pro/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
4
+ </project>
SQL LLM App with Gemini Pro/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/SQL LLM App with Gemini Pro.iml" filepath="$PROJECT_DIR$/.idea/SQL LLM App with Gemini Pro.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
SQL LLM App with Gemini Pro/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
SQL LLM App with Gemini Pro/.idea/workspace.xml ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="SELECTIVE" />
5
+ </component>
6
+ <component name="ChangeListManager">
7
+ <list default="true" id="388c7a06-58ad-492c-8429-6edd735aaecc" name="Changes" comment="">
8
+ <change afterPath="$PROJECT_DIR$/.env" afterDir="false" />
9
+ <change afterPath="$PROJECT_DIR$/.idea/.gitignore" afterDir="false" />
10
+ <change afterPath="$PROJECT_DIR$/.idea/SQL LLM App with Gemini Pro.iml" afterDir="false" />
11
+ <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
12
+ <change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
13
+ <change afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
14
+ <change afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
15
+ <change afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
16
+ <change afterPath="$PROJECT_DIR$/sql.py" afterDir="false" />
17
+ <change afterPath="$PROJECT_DIR$/student.db" afterDir="false" />
18
+ <change afterPath="$PROJECT_DIR$/venv/.nonadmin" afterDir="false" />
19
+ </list>
20
+ <option name="SHOW_DIALOG" value="false" />
21
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
22
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
23
+ <option name="LAST_RESOLUTION" value="IGNORE" />
24
+ </component>
25
+ <component name="FileTemplateManagerImpl">
26
+ <option name="RECENT_TEMPLATES">
27
+ <list>
28
+ <option value="Python Script" />
29
+ </list>
30
+ </option>
31
+ </component>
32
+ <component name="Git.Settings">
33
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
34
+ </component>
35
+ <component name="HighlightingSettingsPerFile">
36
+ <setting file="file://$PROJECT_DIR$/app.py" root0="SKIP_INSPECTION" />
37
+ <setting file="file://$PROJECT_DIR$/sql.py" root0="SKIP_INSPECTION" />
38
+ </component>
39
+ <component name="MarkdownSettingsMigration">
40
+ <option name="stateVersion" value="1" />
41
+ </component>
42
+ <component name="ProjectId" id="2bp3RvaMjfwjiPhVwRbKtH2PigE" />
43
+ <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
44
+ <component name="ProjectViewState">
45
+ <option name="hideEmptyMiddlePackages" value="true" />
46
+ <option name="showLibraryContents" value="true" />
47
+ </component>
48
+ <component name="PropertiesComponent">{
49
+ &quot;keyToString&quot;: {
50
+ &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
51
+ &quot;last_opened_file_path&quot;: &quot;C:/Users/laxmi/PycharmProjects/pythonProject5&quot;,
52
+ &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
53
+ &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
54
+ &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
55
+ &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
56
+ &quot;settings.editor.selected.configurable&quot;: &quot;preferences.fileTypes&quot;
57
+ }
58
+ }</component>
59
+ <component name="RunManager" selected="Python.app">
60
+ <configuration name="app" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
61
+ <module name="SQL LLM App with Gemini Pro" />
62
+ <option name="INTERPRETER_OPTIONS" value="" />
63
+ <option name="PARENT_ENVS" value="true" />
64
+ <envs>
65
+ <env name="PYTHONUNBUFFERED" value="1" />
66
+ </envs>
67
+ <option name="SDK_HOME" value="" />
68
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
69
+ <option name="IS_MODULE_SDK" value="true" />
70
+ <option name="ADD_CONTENT_ROOTS" value="true" />
71
+ <option name="ADD_SOURCE_ROOTS" value="true" />
72
+ <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
73
+ <option name="SCRIPT_NAME" value="$PROJECT_DIR$/app.py" />
74
+ <option name="PARAMETERS" value="" />
75
+ <option name="SHOW_COMMAND_LINE" value="false" />
76
+ <option name="EMULATE_TERMINAL" value="false" />
77
+ <option name="MODULE_MODE" value="false" />
78
+ <option name="REDIRECT_INPUT" value="false" />
79
+ <option name="INPUT_FILE" value="" />
80
+ <method v="2" />
81
+ </configuration>
82
+ <configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
83
+ <module name="SQL LLM App with Gemini Pro" />
84
+ <option name="INTERPRETER_OPTIONS" value="" />
85
+ <option name="PARENT_ENVS" value="true" />
86
+ <envs>
87
+ <env name="PYTHONUNBUFFERED" value="1" />
88
+ </envs>
89
+ <option name="SDK_HOME" value="" />
90
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
91
+ <option name="IS_MODULE_SDK" value="true" />
92
+ <option name="ADD_CONTENT_ROOTS" value="true" />
93
+ <option name="ADD_SOURCE_ROOTS" value="true" />
94
+ <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
95
+ <option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
96
+ <option name="PARAMETERS" value="" />
97
+ <option name="SHOW_COMMAND_LINE" value="false" />
98
+ <option name="EMULATE_TERMINAL" value="false" />
99
+ <option name="MODULE_MODE" value="false" />
100
+ <option name="REDIRECT_INPUT" value="false" />
101
+ <option name="INPUT_FILE" value="" />
102
+ <method v="2" />
103
+ </configuration>
104
+ <configuration name="sql" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
105
+ <module name="SQL LLM App with Gemini Pro" />
106
+ <option name="INTERPRETER_OPTIONS" value="" />
107
+ <option name="PARENT_ENVS" value="true" />
108
+ <envs>
109
+ <env name="PYTHONUNBUFFERED" value="1" />
110
+ </envs>
111
+ <option name="SDK_HOME" value="" />
112
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
113
+ <option name="IS_MODULE_SDK" value="true" />
114
+ <option name="ADD_CONTENT_ROOTS" value="true" />
115
+ <option name="ADD_SOURCE_ROOTS" value="true" />
116
+ <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
117
+ <option name="SCRIPT_NAME" value="$PROJECT_DIR$/sql.py" />
118
+ <option name="PARAMETERS" value="" />
119
+ <option name="SHOW_COMMAND_LINE" value="false" />
120
+ <option name="EMULATE_TERMINAL" value="false" />
121
+ <option name="MODULE_MODE" value="false" />
122
+ <option name="REDIRECT_INPUT" value="false" />
123
+ <option name="INPUT_FILE" value="" />
124
+ <method v="2" />
125
+ </configuration>
126
+ <recent_temporary>
127
+ <list>
128
+ <item itemvalue="Python.app" />
129
+ <item itemvalue="Python.sql" />
130
+ </list>
131
+ </recent_temporary>
132
+ </component>
133
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
134
+ <component name="TaskManager">
135
+ <task active="true" id="Default" summary="Default task">
136
+ <changelist id="388c7a06-58ad-492c-8429-6edd735aaecc" name="Changes" comment="" />
137
+ <created>1706898188410</created>
138
+ <option name="number" value="Default" />
139
+ <option name="presentableId" value="Default" />
140
+ <updated>1706898188410</updated>
141
+ <workItem from="1706898192651" duration="3945000" />
142
+ <workItem from="1709787206565" duration="695000" />
143
+ <workItem from="1711617686805" duration="612000" />
144
+ <workItem from="1711990443125" duration="3773000" />
145
+ <workItem from="1712031147376" duration="2369000" />
146
+ </task>
147
+ <servers />
148
+ </component>
149
+ <component name="TypeScriptGeneratedFilesManager">
150
+ <option name="version" value="3" />
151
+ </component>
152
+ <component name="Vcs.Log.Tabs.Properties">
153
+ <option name="TAB_STATES">
154
+ <map>
155
+ <entry key="MAIN">
156
+ <value>
157
+ <State />
158
+ </value>
159
+ </entry>
160
+ </map>
161
+ </option>
162
+ </component>
163
+ <component name="com.intellij.coverage.CoverageDataManagerImpl">
164
+ <SUITE FILE_PATH="coverage/SQL_LLM_App_with_Gemini_Pro$sql.coverage" NAME="sql Coverage Results" MODIFIED="1712031312739" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
165
+ <SUITE FILE_PATH="coverage/SQL_LLM_App_with_Gemini_Pro$app.coverage" NAME="app Coverage Results" MODIFIED="1712031323033" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
166
+ </component>
167
+ </project>
SQL LLM App with Gemini Pro/app.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dotenv import load_dotenv
2
+ import streamlit as st
3
+ import os
4
+ import sqlite3
5
+ import google.generativeai as genai
6
+
7
+ # Configure API key
8
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
9
+
10
+ def get_gemini_response(question, prompt):
11
+ model = genai.GenerativeModel('gemini-pro')
12
+ response = model.generate_content([prompt[0], question])
13
+ return response.text.strip()
14
+
15
+ def read_sql_query(sql, db):
16
+ conn = sqlite3.connect(db)
17
+ cur = conn.cursor()
18
+ cur.execute(sql)
19
+ rows = cur.fetchall()
20
+ conn.commit()
21
+ conn.close()
22
+ return rows
23
+
24
+ # Prompt for the application
25
+ prompt = [
26
+ """
27
+ You are an expert in converting English questions to SQL query!
28
+ The SQL database has the name STUDENT and has the following columns - NAME, CLASS,
29
+ SECTION \n\nFor example,\nExample 1 - How many entries of records are present?,
30
+ the SQL command will be something like this SELECT COUNT(*) FROM STUDENT ;
31
+ \nExample 2 - Tell me all the students studying in Data Science class?,
32
+ the SQL command will be something like this SELECT * FROM STUDENT
33
+ where CLASS="Data Science";
34
+ """
35
+ ]
36
+
37
+ # Streamlit app
38
+ st.set_page_config(page_title="Text to SQL Query Converter")
39
+ st.title("Text to SQL Query Converter")
40
+
41
+ # User input
42
+ question = st.text_input("Enter your question:", key="input")
43
+
44
+ # Submit button
45
+ if st.button("Convert to SQL Query"):
46
+ if not question:
47
+ st.error("Please enter a question.")
48
+ else:
49
+ # Generate SQL query from the question
50
+ sql_query = get_gemini_response(question, prompt)
51
+ st.write("SQL Query:")
52
+ st.code(sql_query)
53
+
54
+ # Execute the SQL query and display results
55
+ try:
56
+ results = read_sql_query(sql_query, "student.db")
57
+ if results:
58
+ st.success("Query executed successfully. Results:")
59
+ st.table(results)
60
+ else:
61
+ st.warning("No results found.")
62
+ except Exception as e:
63
+ st.error(f"An error occurred: {e}")
SQL LLM App with Gemini Pro/main.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This is a sample Python script.
2
+
3
+ # Press Shift+F10 to execute it or replace it with your code.
4
+ # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
5
+
6
+
7
+ def print_hi(name):
8
+ # Use a breakpoint in the code line below to debug your script.
9
+ print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
10
+
11
+
12
+ # Press the green button in the gutter to run the script.
13
+ if __name__ == '__main__':
14
+ print_hi('PyCharm')
15
+
16
+ # See PyCharm help at https://www.jetbrains.com/help/pycharm/
SQL LLM App with Gemini Pro/requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ google-generativeai
3
+ python-dotenv
SQL LLM App with Gemini Pro/sql.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sqlite3
2
+
3
+ ## Connectt to SQlite
4
+ connection=sqlite3.connect("student.db")
5
+
6
+ # Create a cursor object to insert record,create table
7
+
8
+ cursor=connection.cursor()
9
+
10
+ ## create the table
11
+ table_info="""
12
+ Create table if not exists STUDENT(NAME VARCHAR(25),CLASS VARCHAR(25),
13
+ SECTION VARCHAR(25),MARKS INT);
14
+
15
+ """
16
+ cursor.execute(table_info)
17
+ ## Insert Some more records
18
+
19
+ cursor.execute('''Insert Into STUDENT values('Vijay','Data Science','A',90)''')
20
+ cursor.execute('''Insert Into STUDENT values('Vaish','Data Science','B',100)''')
21
+ cursor.execute('''Insert Into STUDENT values('Piyush','Data Science','A',86)''')
22
+ cursor.execute('''Insert Into STUDENT values('Anas','DEVOPS','A',50)''')
23
+ cursor.execute('''Insert Into STUDENT values('Rana','DEVOPS','A',35)''')
24
+
25
+ ## Disspaly ALl the records
26
+
27
+ print("The isnerted records are")
28
+ data=cursor.execute('''Select * from STUDENT''')
29
+ for row in data:
30
+ print(row)
31
+
32
+ ## Commit your changes int he databse
33
+ connection.commit()
34
+ connection.close()
SQL LLM App with Gemini Pro/student.db ADDED
Binary file (8.19 kB). View file
 
SQL LLM App with Gemini Pro/venv/.nonadmin ADDED
File without changes
SQL LLM App with Gemini Pro/venv/conda-meta/history ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ==> 2024-02-03 00:00:18 <==
2
+ # cmd: C:\Users\laxmi\anaconda3\Scripts\conda-script.py create -p venv -y
3
+ # conda version: 23.7.4
SQL LLM App with Gemini Pro/venv/etc/aau_token ADDED
@@ -0,0 +1 @@
 
 
1
+ otmkr4oY7a8dVV9N8XFi4A