Added PAN support, fixed few event listeners for proper update in UI
Browse files
app.py
CHANGED
@@ -144,7 +144,7 @@ def execute_text_search(ix, q):
|
|
144 |
def gen_insights(index_name, topic, summary_type):
|
145 |
if topic is not None and len(topic) > 0:
|
146 |
resp = generate_insights(index_name, topic, summary_type)
|
147 |
-
return resp
|
148 |
|
149 |
|
150 |
@lru_cache(maxsize=50)
|
@@ -152,14 +152,18 @@ def generate_insights(index_name, topic, summary_type):
|
|
152 |
if llama_cache[index_name] is None:
|
153 |
return None
|
154 |
query = f"What is the executive summary for the topic \"{topic}\"? Highlight negative aspects in 100 words"
|
|
|
|
|
155 |
if summary_type == "Actions":
|
156 |
query = f"What are the recommended action items for the topic \"{topic}\"? Limit response to 100 words using bullet points"
|
157 |
elif summary_type == "Followup":
|
158 |
query = f"What are the recommended questions to ask team for more clarity and latest status for the topic \"{topic}\"?"
|
159 |
-
return llama_cache[index_name].as_query_engine().query(query)
|
160 |
|
161 |
|
162 |
def generate_comment_insights(index_name, topic, summary_type):
|
|
|
|
|
163 |
if summary_type == "Show Comments":
|
164 |
return show_docs(index_name, topic)
|
165 |
if summary_type == "Show Threads":
|
@@ -249,7 +253,7 @@ def find_topics_by_thread(index_name, query, topic, summary_type):
|
|
249 |
resp = search_keyword_matches(thread_index[index_name], query)
|
250 |
if resp is not None:
|
251 |
result_topics = find_topics_with_llama(index_name, query, resp)
|
252 |
-
return gr.Dropdown.update(choices=result_topics, value=result_topics[0])
|
253 |
|
254 |
return "No matches found" if resp is None else resp
|
255 |
|
@@ -258,7 +262,8 @@ def find_topics_by_comments(index_name, query, topic, summary_type):
|
|
258 |
resp = search_keyword_matches(comment_index[index_name], query)
|
259 |
if resp is not None:
|
260 |
result_topics = find_topics_with_llama(index_name, query, resp)
|
261 |
-
|
|
|
262 |
|
263 |
return "No matches found" if resp is None else resp
|
264 |
|
@@ -271,35 +276,39 @@ def main_demo():
|
|
271 |
load_data(data_sets)
|
272 |
with gr.Tab("Thread"):
|
273 |
data_sets_dd = gr.Dropdown(data_sets,
|
274 |
-
type="value", value=data_sets[0], label="Select
|
275 |
keyword_txt = gr.Textbox(lines=2, label="Enter keywords to search", placeholder='CISO, auth0')
|
276 |
-
find_topics_button = gr.Button("Find Topics")
|
277 |
topics_dd = gr.Dropdown([],
|
278 |
type="value", label="Select Topic with Negative Sentiment", allow_custom_value=True)
|
279 |
|
280 |
-
show_details = gr.Radio(["Summary", "Actions", "Followup"], label="Show Details")
|
281 |
-
|
282 |
find_topics_button.click(find_topics_by_thread,
|
283 |
inputs=[data_sets_dd, keyword_txt, find_topics_button, topics_dd],
|
284 |
-
outputs=topics_dd)
|
285 |
show_details.change(gen_insights, inputs=[data_sets_dd, topics_dd, show_details],
|
286 |
-
outputs=
|
|
|
|
|
287 |
|
288 |
with gr.Tab("Comment"):
|
289 |
data_sets_dd = gr.Dropdown(data_sets,
|
290 |
-
type="value", value=data_sets[0], label="Select
|
291 |
keyword_txt = gr.Textbox(lines=2, label="Enter keywords to search", placeholder='CISO, auth0')
|
292 |
-
find_topics_button = gr.Button("Find Topics")
|
293 |
topics_dd = gr.Dropdown([],
|
294 |
type="value", label="Select Topic with Negative Sentiment", allow_custom_value=True)
|
295 |
|
296 |
-
show_details = gr.Radio(["Show Comments", "Show Threads", "Show Summary"], label="Show Details")
|
297 |
-
|
298 |
find_topics_button.click(find_topics_by_comments,
|
299 |
inputs=[data_sets_dd, keyword_txt, find_topics_button, topics_dd],
|
300 |
-
outputs=topics_dd)
|
301 |
show_details.change(generate_comment_insights, inputs=[data_sets_dd, topics_dd, show_details],
|
302 |
-
outputs=
|
|
|
|
|
303 |
|
304 |
if 'LOGIN_PASS' in os.environ:
|
305 |
demo.launch(auth=('axiamatic', os.environ['LOGIN_PASS']),
|
|
|
144 |
def gen_insights(index_name, topic, summary_type):
|
145 |
if topic is not None and len(topic) > 0:
|
146 |
resp = generate_insights(index_name, topic, summary_type)
|
147 |
+
return resp
|
148 |
|
149 |
|
150 |
@lru_cache(maxsize=50)
|
|
|
152 |
if llama_cache[index_name] is None:
|
153 |
return None
|
154 |
query = f"What is the executive summary for the topic \"{topic}\"? Highlight negative aspects in 100 words"
|
155 |
+
if summary_type == "None":
|
156 |
+
return ""
|
157 |
if summary_type == "Actions":
|
158 |
query = f"What are the recommended action items for the topic \"{topic}\"? Limit response to 100 words using bullet points"
|
159 |
elif summary_type == "Followup":
|
160 |
query = f"What are the recommended questions to ask team for more clarity and latest status for the topic \"{topic}\"?"
|
161 |
+
return llama_cache[index_name].as_query_engine().query(query).response
|
162 |
|
163 |
|
164 |
def generate_comment_insights(index_name, topic, summary_type):
|
165 |
+
if summary_type == "None":
|
166 |
+
return ""
|
167 |
if summary_type == "Show Comments":
|
168 |
return show_docs(index_name, topic)
|
169 |
if summary_type == "Show Threads":
|
|
|
253 |
resp = search_keyword_matches(thread_index[index_name], query)
|
254 |
if resp is not None:
|
255 |
result_topics = find_topics_with_llama(index_name, query, resp)
|
256 |
+
return gr.Dropdown.update(choices=result_topics, value=result_topics[0]), gr.Radio.update(value="None")
|
257 |
|
258 |
return "No matches found" if resp is None else resp
|
259 |
|
|
|
262 |
resp = search_keyword_matches(comment_index[index_name], query)
|
263 |
if resp is not None:
|
264 |
result_topics = find_topics_with_llama(index_name, query, resp)
|
265 |
+
|
266 |
+
return gr.Dropdown.update(choices=result_topics, value=result_topics[0]), gr.Radio.update(value="None")
|
267 |
|
268 |
return "No matches found" if resp is None else resp
|
269 |
|
|
|
276 |
load_data(data_sets)
|
277 |
with gr.Tab("Thread"):
|
278 |
data_sets_dd = gr.Dropdown(data_sets,
|
279 |
+
type="value", value=data_sets[0], label="Select Data Source")
|
280 |
keyword_txt = gr.Textbox(lines=2, label="Enter keywords to search", placeholder='CISO, auth0')
|
281 |
+
find_topics_button = gr.Button("Find Negative Topics")
|
282 |
topics_dd = gr.Dropdown([],
|
283 |
type="value", label="Select Topic with Negative Sentiment", allow_custom_value=True)
|
284 |
|
285 |
+
show_details = gr.Radio(["None", "Summary", "Actions", "Followup"], label="Show Details")
|
286 |
+
out_box = gr.Textbox(lines=11, label="Response")
|
287 |
find_topics_button.click(find_topics_by_thread,
|
288 |
inputs=[data_sets_dd, keyword_txt, find_topics_button, topics_dd],
|
289 |
+
outputs=[topics_dd, show_details])
|
290 |
show_details.change(gen_insights, inputs=[data_sets_dd, topics_dd, show_details],
|
291 |
+
outputs=out_box)
|
292 |
+
topics_dd.change(gen_insights, inputs=[data_sets_dd, topics_dd, show_details],
|
293 |
+
outputs=out_box)
|
294 |
|
295 |
with gr.Tab("Comment"):
|
296 |
data_sets_dd = gr.Dropdown(data_sets,
|
297 |
+
type="value", value=data_sets[0], label="Select Data Source")
|
298 |
keyword_txt = gr.Textbox(lines=2, label="Enter keywords to search", placeholder='CISO, auth0')
|
299 |
+
find_topics_button = gr.Button("Find Negative Topics")
|
300 |
topics_dd = gr.Dropdown([],
|
301 |
type="value", label="Select Topic with Negative Sentiment", allow_custom_value=True)
|
302 |
|
303 |
+
show_details = gr.Radio(["None", "Show Comments", "Show Threads", "Show Summary"], label="Show Details")
|
304 |
+
out_box = gr.Textbox(lines=11, label="Response")
|
305 |
find_topics_button.click(find_topics_by_comments,
|
306 |
inputs=[data_sets_dd, keyword_txt, find_topics_button, topics_dd],
|
307 |
+
outputs=[topics_dd, show_details])
|
308 |
show_details.change(generate_comment_insights, inputs=[data_sets_dd, topics_dd, show_details],
|
309 |
+
outputs=out_box)
|
310 |
+
topics_dd.change(generate_comment_insights, inputs=[data_sets_dd, topics_dd, show_details],
|
311 |
+
outputs=out_box)
|
312 |
|
313 |
if 'LOGIN_PASS' in os.environ:
|
314 |
demo.launch(auth=('axiamatic', os.environ['LOGIN_PASS']),
|