Spaces:
Sleeping
Sleeping
Kevin Louis
commited on
Commit
•
d636407
1
Parent(s):
2c8f0e3
updated app.py
Browse filesRemoved share=True from ChatToSequence.launch(). Share=True parameter shouldn't be active when app is ran in spaces. It caused an runtime error
app.py
CHANGED
@@ -9,10 +9,7 @@ from helper import list_at_index_0, list_at_index_1, logger
|
|
9 |
|
10 |
|
11 |
def chat_to_sequence(sequence, user_query):
|
12 |
-
|
13 |
-
gr.Warning("Sequence Is Empty. Please Input A Sequence")
|
14 |
-
if user_query is None:
|
15 |
-
gr.Warning("Query Is Empty. Please Input A Query")
|
16 |
# Log information to a CSV file
|
17 |
log_filename = "CTS_user_log.csv"
|
18 |
|
@@ -66,8 +63,7 @@ def chat_to_sequence(sequence, user_query):
|
|
66 |
|
67 |
# Semantic similarity search user query against sample queries
|
68 |
index_result = ref_query_ds.get_nearest_examples("all-mpnet-base-v2_embeddings", query_embedding, k=3)
|
69 |
-
|
70 |
-
|
71 |
# Retrieve results from dataset object
|
72 |
scores, examples = index_result
|
73 |
|
@@ -93,8 +89,7 @@ def chat_to_sequence(sequence, user_query):
|
|
93 |
# Description of query code to be executed
|
94 |
query_code_description = code_function_mapping[code_function_mapping['code'] == query_code]['description'].values[0]
|
95 |
|
96 |
-
#
|
97 |
-
print(ref_question, query_code, query_score)
|
98 |
similarity_metric = "k nearest neighbours"
|
99 |
|
100 |
ref_question_2 = sorted_df.iloc[1]['question']
|
@@ -102,6 +97,7 @@ def chat_to_sequence(sequence, user_query):
|
|
102 |
query_score_2 = sorted_df.iloc[1]['score']
|
103 |
query_score_3 = sorted_df.iloc[1]['score']
|
104 |
|
|
|
105 |
log_data = [
|
106 |
user_query,
|
107 |
ref_question,
|
@@ -116,6 +112,7 @@ def chat_to_sequence(sequence, user_query):
|
|
116 |
proximal_lower_threshold,
|
117 |
proximal_upper_threshold,
|
118 |
]
|
|
|
119 |
# Check the query score against threshold values
|
120 |
if query_score >= proximal_upper_threshold:
|
121 |
response = threshold_exceeded_message
|
@@ -172,4 +169,4 @@ ChatToSequence = gr.Interface(
|
|
172 |
],
|
173 |
).queue()
|
174 |
|
175 |
-
ChatToSequence.launch(
|
|
|
9 |
|
10 |
|
11 |
def chat_to_sequence(sequence, user_query):
|
12 |
+
|
|
|
|
|
|
|
13 |
# Log information to a CSV file
|
14 |
log_filename = "CTS_user_log.csv"
|
15 |
|
|
|
63 |
|
64 |
# Semantic similarity search user query against sample queries
|
65 |
index_result = ref_query_ds.get_nearest_examples("all-mpnet-base-v2_embeddings", query_embedding, k=3)
|
66 |
+
|
|
|
67 |
# Retrieve results from dataset object
|
68 |
scores, examples = index_result
|
69 |
|
|
|
89 |
# Description of query code to be executed
|
90 |
query_code_description = code_function_mapping[code_function_mapping['code'] == query_code]['description'].values[0]
|
91 |
|
92 |
+
# Extra log entities
|
|
|
93 |
similarity_metric = "k nearest neighbours"
|
94 |
|
95 |
ref_question_2 = sorted_df.iloc[1]['question']
|
|
|
97 |
query_score_2 = sorted_df.iloc[1]['score']
|
98 |
query_score_3 = sorted_df.iloc[1]['score']
|
99 |
|
100 |
+
# logger function log_data parameter input
|
101 |
log_data = [
|
102 |
user_query,
|
103 |
ref_question,
|
|
|
112 |
proximal_lower_threshold,
|
113 |
proximal_upper_threshold,
|
114 |
]
|
115 |
+
|
116 |
# Check the query score against threshold values
|
117 |
if query_score >= proximal_upper_threshold:
|
118 |
response = threshold_exceeded_message
|
|
|
169 |
],
|
170 |
).queue()
|
171 |
|
172 |
+
ChatToSequence.launch()
|