prasadnu commited on
Commit
d1e16b2
·
1 Parent(s): 33fcb20

model changed to Haiku 3.5 for query re=write

Browse files
semantic_search/query_rewrite.py CHANGED
@@ -235,18 +235,18 @@ def get_new_query_res(query):
235
  if(query == ""):
236
  query = st.session_state.input_rekog_label
237
  if(st.session_state.input_is_rewrite_query == 'enabled'):
238
- start = time.time()
239
  get_prompt = prompt_.format(query=query,schema = schema)
240
- print(f"prompt latency: {time.time() - start:.2f} sec")
241
- start = time.time()
242
  res = invoke_models.invoke_llm_model( get_prompt,False)
243
- print(f"Claude latency: {time.time() - start:.2f} sec")
244
  inter_query = res[7:-3].replace('\\"',"'").replace("\n","")
245
- start = time.time()
246
  query_struct = StructuredQueryOutputParser.from_components().parse(inter_query)
247
  opts = OpenSearchTranslator()
248
  result_query_llm = opts.visit_structured_query(query_struct)[1]['filter']
249
- print(f"Langchain latency: {time.time() - start:.2f} sec")
250
  draft_new_query = {'bool':{'should':[],'must':[]}}
251
  if('bool' in result_query_llm and ('must' in result_query_llm['bool'] or 'should' in result_query_llm['bool'])):
252
  #draft_new_query['bool']['should'] = []
 
235
  if(query == ""):
236
  query = st.session_state.input_rekog_label
237
  if(st.session_state.input_is_rewrite_query == 'enabled'):
238
+ #tart = time.time()
239
  get_prompt = prompt_.format(query=query,schema = schema)
240
+ #print(f"prompt latency: {time.time() - start:.2f} sec")
241
+ #start = time.time()
242
  res = invoke_models.invoke_llm_model( get_prompt,False)
243
+ #print(f"Claude latency: {time.time() - start:.2f} sec")
244
  inter_query = res[7:-3].replace('\\"',"'").replace("\n","")
245
+ #start = time.time()
246
  query_struct = StructuredQueryOutputParser.from_components().parse(inter_query)
247
  opts = OpenSearchTranslator()
248
  result_query_llm = opts.visit_structured_query(query_struct)[1]['filter']
249
+ #print(f"Langchain latency: {time.time() - start:.2f} sec")
250
  draft_new_query = {'bool':{'should':[],'must':[]}}
251
  if('bool' in result_query_llm and ('must' in result_query_llm['bool'] or 'should' in result_query_llm['bool'])):
252
  #draft_new_query['bool']['should'] = []
utilities/invoke_models.py CHANGED
@@ -108,7 +108,7 @@ def read_from_table(file,question):
108
 
109
  model = BedrockChat(
110
  client=bedrock_runtime_client,
111
- model_id='anthropic.claude-3-haiku-20240307-v1:0',
112
  model_kwargs=bedrock_params,
113
  streaming=False
114
  )
@@ -130,7 +130,7 @@ def generate_image_captions_llm(base64_string,question):
130
 
131
 
132
  response = bedrock_runtime_client.invoke_model(
133
- modelId= "anthropic.claude-3-haiku-20240307-v1:0",
134
  contentType = "application/json",
135
  accept = "application/json",
136
 
 
108
 
109
  model = BedrockChat(
110
  client=bedrock_runtime_client,
111
+ model_id="anthropic.claude-3-5-haiku-20241022-v1:0",
112
  model_kwargs=bedrock_params,
113
  streaming=False
114
  )
 
130
 
131
 
132
  response = bedrock_runtime_client.invoke_model(
133
+ modelId= "anthropic.claude-3-5-haiku-20241022-v1:0",
134
  contentType = "application/json",
135
  accept = "application/json",
136