laudes commited on
Commit
372d185
·
verified ·
1 Parent(s): 01122c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py CHANGED
@@ -73,9 +73,40 @@ def update_button_state(text):
73
  else:
74
  return gr.update(interactive=False)
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  # Gradio interface setup
77
  with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Ubuntu"), "Arial", "sans-serif"], text_size='sm')) as ydcoza_face:
 
78
  text_input = gr.Textbox(lines=2, label="Text Query")
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  examples = gr.Examples(examples=[
80
  "I'm trying to figure out which agents are the busiest. Can you show me like the top few agents who have a lot on their plate? I'd like to see their names and maybe their contact info if we have it.",
81
  "I need to get an overview of our classes. Could you pull up a list that shows what each class is about and which client it's for? Oh, and it would be great to know how many students are in each class. Maybe order it so the biggest classes are at the top?",
@@ -140,3 +171,4 @@ if __name__ == "__main__":
140
  # ydcoza_face.launch(auth=auth_users, auth_message="Demo Login, Username: admin & Password: 1234")
141
  # run gradio deploy in Terminal
142
  ydcoza_face.launch()
 
 
73
  else:
74
  return gr.update(interactive=False)
75
 
76
+
77
+ # Assuming 'table_names' is a list of table names fetched from the schema, e.g., ['Reports', 'Tasks', 'Clients']
78
+
79
+ # Function to fetch table names from schema (you may already have this in your app)
80
+ def get_table_names():
81
+ # Replace this with actual schema fetching logic if needed
82
+ return ["Reports", "Tasks", "Clients", "Agents", "Learners", "Classes", "Events", "Assesments", "Progressions", "Deliveries", "Agent Assignments", "Agent Availability", "Agent Work History"]
83
+
84
+ # Function to update the query textbox when a button is clicked
85
+ def insert_table_name(current_text, table_name):
86
+ # Add the table name to the current text
87
+ return current_text + " " + table_name
88
+
89
+ # Fetch table names from schema
90
+ table_names = get_table_names()
91
+
92
+
93
  # Gradio interface setup
94
  with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Ubuntu"), "Arial", "sans-serif"], text_size='sm')) as ydcoza_face:
95
+
96
  text_input = gr.Textbox(lines=2, label="Text Query")
97
+
98
+
99
+ # Adding buttons below the Textbox in Gradio
100
+ with gr.Blocks() as ydcoza_face:
101
+
102
+
103
+ text_input = gr.Textbox(lines=2, label="Text Query")
104
+
105
+ # Dynamically create buttons for each table
106
+ with gr.Row():
107
+ for table in table_names:
108
+ gr.Button(table, size="small", elem_classes="ydcoza-small-button").click(fn=lambda current_text, t=table: insert_table_name(current_text, t), inputs=text_input, outputs=text_input)
109
+
110
  examples = gr.Examples(examples=[
111
  "I'm trying to figure out which agents are the busiest. Can you show me like the top few agents who have a lot on their plate? I'd like to see their names and maybe their contact info if we have it.",
112
  "I need to get an overview of our classes. Could you pull up a list that shows what each class is about and which client it's for? Oh, and it would be great to know how many students are in each class. Maybe order it so the biggest classes are at the top?",
 
171
  # ydcoza_face.launch(auth=auth_users, auth_message="Demo Login, Username: admin & Password: 1234")
172
  # run gradio deploy in Terminal
173
  ydcoza_face.launch()
174
+