sudip1987 commited on
Commit
ec2da61
·
verified ·
1 Parent(s): 50337b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -6
app.py CHANGED
@@ -88,6 +88,7 @@ def execute_sql_query(user_query):
88
  table_schema = sql_model.fetch_table_schema("sql_pdf")
89
  if table_schema:
90
  # Generate and execute query
 
91
  if user_query.strip():
92
  query = sql_model.text2sql_gemini(table_schema, def_query, user_query)
93
  else:
@@ -109,26 +110,35 @@ image = Image.open(os.path.join(os.path.abspath(''), "house_excel_sheet.png"))
109
 
110
  # Create web interface
111
  with gr.Blocks(title="House Database Query") as demo:
112
- # Header
 
 
 
113
  gr.Markdown("# House Database Query System")
114
 
115
  # Display database schema image
116
  gr.Image(image)
117
 
118
  # Description
 
 
119
  gr.Markdown("""### The database contains information about different properties including their fundamental details.
120
  You can query this database using natural language.""")
121
 
122
  # Input section
 
 
123
  with gr.Row():
124
  query_input = gr.Textbox(
125
- lines=2,
126
  label="Database Query",
 
127
  placeholder="Enter your query or choose from examples below. Default: 'Properties in India'"
128
  )
129
 
130
  # Submit button section
131
  with gr.Row():
 
132
  submit_btn = gr.Button("Submit Query", variant="primary")
133
 
134
  # Results section
@@ -136,6 +146,8 @@ with gr.Blocks(title="House Database Query") as demo:
136
  query_output = gr.JSON(label="Query Results")
137
 
138
  # Connect button click to query function
 
 
139
  submit_btn.click(
140
  fn=execute_sql_query,
141
  inputs=query_input,
@@ -143,15 +155,26 @@ with gr.Blocks(title="House Database Query") as demo:
143
  )
144
 
145
  # Example queries section
146
- gr.Examples(
 
 
 
 
 
 
 
 
 
 
 
147
  examples=[
148
  "Properties in France",
149
  "Properties greater than an acre",
150
  "Properties with more than 400 bedrooms"
151
  ],
152
- inputs=query_input,
153
- outputs=query_output,
154
- fn=execute_sql_query
155
  )
156
 
157
  if __name__ == "__main__":
 
88
  table_schema = sql_model.fetch_table_schema("sql_pdf")
89
  if table_schema:
90
  # Generate and execute query
91
+ # strip() -> removed initial & after query spaces
92
  if user_query.strip():
93
  query = sql_model.text2sql_gemini(table_schema, def_query, user_query)
94
  else:
 
110
 
111
  # Create web interface
112
  with gr.Blocks(title="House Database Query") as demo:
113
+ # Header Markdown -> descrption
114
+ # one # -> heading
115
+ # two ## -> sub heading
116
+ # three ### -> sub minor heading
117
  gr.Markdown("# House Database Query System")
118
 
119
  # Display database schema image
120
  gr.Image(image)
121
 
122
  # Description
123
+ # Markdown -> description/note
124
+ # three ### -> sub minor heading
125
  gr.Markdown("""### The database contains information about different properties including their fundamental details.
126
  You can query this database using natural language.""")
127
 
128
  # Input section
129
+ # gr.Row() -> Create new row layout to organize components
130
+ # horizontal
131
  with gr.Row():
132
  query_input = gr.Textbox(
133
+ lines=2,# 2 lines max will be visible
134
  label="Database Query",
135
+ # Display hints for user until they start typing
136
  placeholder="Enter your query or choose from examples below. Default: 'Properties in India'"
137
  )
138
 
139
  # Submit button section
140
  with gr.Row():
141
+ # variant="primary" -> default style/color
142
  submit_btn = gr.Button("Submit Query", variant="primary")
143
 
144
  # Results section
 
146
  query_output = gr.JSON(label="Query Results")
147
 
148
  # Connect button click to query function
149
+ # Click event
150
+
151
  submit_btn.click(
152
  fn=execute_sql_query,
153
  inputs=query_input,
 
155
  )
156
 
157
  # Example queries section
158
+ # gr.Examples(
159
+ # examples=[
160
+ # "Properties in France",
161
+ # "Properties greater than an acre",
162
+ # "Properties with more than 400 bedrooms"
163
+ # ],
164
+ # inputs=query_input,
165
+ # outputs=query_output,
166
+ # fn=execute_sql_query
167
+ # )
168
+ # Example queries section
169
+ example = gr.Examples(
170
  examples=[
171
  "Properties in France",
172
  "Properties greater than an acre",
173
  "Properties with more than 400 bedrooms"
174
  ],
175
+ inputs=query_input
176
+ # outputs=query_output,
177
+ # fn=execute_sql_query
178
  )
179
 
180
  if __name__ == "__main__":