adamboom111 commited on
Commit
bf9eb1e
·
verified ·
1 Parent(s): 78ca708

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -48
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from dotenv import load_dotenv
2
  import os
3
  import gradio as gr
@@ -73,41 +74,7 @@ def explain_sql_output(sql_query, query_result):
73
  return chat_completion.choices[0].message.content.strip()
74
 
75
 
76
- ### --- TAB 3: SQL Follow-Ups --- ###
77
- def followup_prompt(sql_query, query_result):
78
- system_prompt = """
79
- You are an assistant that suggests insightful follow-up questions based on SQL query output.
80
-
81
- Instructions:
82
- - Use the SQL query and result to infer possible next questions.
83
- - Output 3 to 5 follow-up questions.
84
- - Be helpful, curious, and relevant to the data.
85
- - Do NOT repeat the explanation. Only return follow-up questions.
86
- - Format as a list.
87
- """
88
- user_prompt = f"""
89
- SQL Query:
90
- {sql_query}
91
- Query Result:
92
- {query_result}
93
-
94
- Follow-Up Questions:
95
- """
96
- return system_prompt.strip(), user_prompt.strip()
97
-
98
- def generate_followups(sql_query, query_result):
99
- system_prompt, user_prompt = followup_prompt(sql_query, query_result)
100
- chat_completion = client.chat.completions.create(
101
- messages=[
102
- {"role": "system", "content": system_prompt},
103
- {"role": "user", "content": user_prompt}
104
- ],
105
- model="llama3-70b-8192"
106
- )
107
- return chat_completion.choices[0].message.content.strip()
108
-
109
-
110
- ### --- Gradio Interfaces --- ###
111
  tab1 = gr.Interface(
112
  fn=response,
113
  inputs=gr.JSON(label="Input JSON (question, schema)"),
@@ -127,18 +94,7 @@ tab2 = gr.Interface(
127
  description="Input a SQL query and its result. Get an AI-generated explanation."
128
  )
129
 
130
- tab3 = gr.Interface(
131
- fn=generate_followups,
132
- inputs=[
133
- gr.Textbox(label="SQL Query"),
134
- gr.Textbox(label="SQL Output (Raw JSON or Table Result)")
135
- ],
136
- outputs="text",
137
- title="Follow-Up Generator (Groq + LLaMA3)",
138
- description="Suggests follow-up questions based on a SQL query and its result."
139
- )
140
-
141
- demo = gr.TabbedInterface([tab1, tab2, tab3], ["SQL Generator", "Explain Output", "SQL Follow-Ups"])
142
 
143
  if __name__ == '__main__':
144
- demo.launch()
 
1
+ does my currect app.pu able to do it?
2
  from dotenv import load_dotenv
3
  import os
4
  import gradio as gr
 
74
  return chat_completion.choices[0].message.content.strip()
75
 
76
 
77
+ ### --- Gradio Interface --- ###
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  tab1 = gr.Interface(
79
  fn=response,
80
  inputs=gr.JSON(label="Input JSON (question, schema)"),
 
94
  description="Input a SQL query and its result. Get an AI-generated explanation."
95
  )
96
 
97
+ demo = gr.TabbedInterface([tab1, tab2], ["SQL Generator", "Explain Output"])
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  if __name__ == '__main__':
100
+ demo.launch()