prasadnu commited on
Commit
1ad7661
·
1 Parent(s): 426cbe0

model changed to Haiku 3.5 for query re=write

Browse files
Files changed (1) hide show
  1. semantic_search/query_rewrite.py +5 -0
semantic_search/query_rewrite.py CHANGED
@@ -234,12 +234,17 @@ def get_new_query_res(query):
234
  if(query == ""):
235
  query = st.session_state.input_rekog_label
236
  if(st.session_state.input_is_rewrite_query == 'enabled'):
 
237
 
 
238
  res = invoke_models.invoke_llm_model( prompt_.format(query=query,schema = schema) ,False)
 
239
  inter_query = res[7:-3].replace('\\"',"'").replace("\n","")
 
240
  query_struct = StructuredQueryOutputParser.from_components().parse(inter_query)
241
  opts = OpenSearchTranslator()
242
  result_query_llm = opts.visit_structured_query(query_struct)[1]['filter']
 
243
  draft_new_query = {'bool':{'should':[],'must':[]}}
244
  if('bool' in result_query_llm and ('must' in result_query_llm['bool'] or 'should' in result_query_llm['bool'])):
245
  #draft_new_query['bool']['should'] = []
 
234
  if(query == ""):
235
  query = st.session_state.input_rekog_label
236
  if(st.session_state.input_is_rewrite_query == 'enabled'):
237
+ import time
238
 
239
+ start = time.time()
240
  res = invoke_models.invoke_llm_model( prompt_.format(query=query,schema = schema) ,False)
241
+ print(f"Claude latency: {time.time() - start:.2f} sec")
242
  inter_query = res[7:-3].replace('\\"',"'").replace("\n","")
243
+ start = time.time()
244
  query_struct = StructuredQueryOutputParser.from_components().parse(inter_query)
245
  opts = OpenSearchTranslator()
246
  result_query_llm = opts.visit_structured_query(query_struct)[1]['filter']
247
+ print(f"Langchain latency: {time.time() - start:.2f} sec")
248
  draft_new_query = {'bool':{'should':[],'must':[]}}
249
  if('bool' in result_query_llm and ('must' in result_query_llm['bool'] or 'should' in result_query_llm['bool'])):
250
  #draft_new_query['bool']['should'] = []