Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
model changed to Haiku 3.5 for query re=write
Browse files31 unmodified lines3233343536373839404142434445464748495051353637199 unmodified lines23723823925725824026026124124226424324424563 unmodified lines30931031133433533631231331431531 unmodified lines
bedrock_params = { "max_tokens_to_sample":2048, "temperature":0.0001, "top_k":250, "top_p":1, "stop_sequences":["\\n\\nHuman:"]}bedrock_region="us-east-1"
#boto3_bedrock = boto3.client(service_name="bedrock-runtime", endpoint_url=f"https://bedrock-runtime.{bedrock_region}.amazonaws.com")boto3_bedrock = boto3.client(service_name="bedrock-runtime", config=Config(region_name=bedrock_region))
bedrock_titan_llm = Bedrock(model_id="anthropic.claude-instant-v1", client=boto3_bedrock)bedrock_titan_llm.model_kwargs = bedrock_paramsbedrock_embeddings = BedrockEmbeddings(model_id='amazon.titan-embed-text-v1',client=boto3_bedrock)
schema = """{{ "content": "Brief summary of a retail product", "attributes": {{199 unmodified lines
res = invoke_models.invoke_llm_model( prompt_.format(query=query,schema = schema) ,False) inter_query = res[7:-3].replace('\\"',"'").replace("\n","") print("inter_query") print(inter_query) query_struct = StructuredQueryOutputParser.from_components().parse(inter_query) print("query_struct") print(query_struct) opts = OpenSearchTranslator() result_query_llm = opts.visit_structured_query(query_struct)[1]['filter'] print(result_query_llm) draft_new_query = {'bool':{'should':[],'must':[]}} if('bool' in result_query_llm and ('must' in result_query_llm['bool'] or 'should' in result_query_llm['bool'])): #draft_new_query['bool']['should'] = []63 unmodified lines # return words_stem.strip() #imp_item = stem_(imp_item) print("imp_item---------------") print(imp_item) print(query_) if('must' in query_['bool']): query_['bool']['must'].append({ "simple_query_string": {semantic_search/query_rewrite.py+1-25