Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
2.15.0
Problem
I’m trying to implement hybrid search.
I created a connector to my own service, where the model is deployed
data_connector = {
'name': 'proba_connector',
'description': 'The connector for proba_connector',
'version': 1,
'protocol': 'http',
'actions': [{
"action_type": "predict",
"method": "POST",
"headers": {
"content-type": "application/json"
},
"url": "http://localhost:8000/",
"request_body":"{ \"text\":${parameters.text}}",
"post_process_function": "connector.post_process.default.embedding"}],
'credential': {},
'parameters':{
'skip_validating_missing_parameters': True
}
}
With output:
{"connector_id":"7IuE75QBSNMx2eSv1MRQ"}
When I make a request like this for a model
data_predict = {
"parameters": {
"text": ["how are you"]}
}
r = requests.post('https://localhost:9201/_plugins/_ml/models/7ouF75QBSNMx2eSvCsQ-/_predict', auth=('admin', 'admin'), verify=False, json=data_predict, headers=headers)
then it gives the following answer
{"inference_results":[{"output":[{"name":"sentence_embedding","data_type":"FLOAT32","shape":[4096],"data":[0.0110944714397192,0.019420204684138298,0.012235138565301895,0.008400695398449898,0.008350025862455368,0.009718209505081177,-0.00913007277995348,0.009152905084192753,0.02582375705242157,0.0064290789887309074,0.0084756501019001,-0.0023967644665390253,-0.004717715550214052,-0.010794127359986305,0.01587575674057007,-0.015306735411286354,0.02125721424818039,-0.0015540372114628553,-0.00030985873308964074,0.002872861921787262,0.0008000598754733801,0.014949942007660866,-0.0232723169028759,-0.008435241878032684,0.0018127607181668282,0.009296631440520287,-0.0017149467021226883,-0.005 ... 0.014812000095844269,-0.021458394825458527,0.005142853129655123]}],"status_code":200}]}
The following example request creates an ingest pipeline
body = {
"description": "An NLP ingest pipeline",
"processors": [
{
"text_embedding": {
"model_id": "7ouF75QBSNMx2eSvCsQ-",
"field_map": {
"text": "sentence_embedding"
}
}
}
]
}
ingest_client = IngestClient(client)
ingest_client.put_pipeline(id=1, body=body)
ingest_client.get_pipeline()
Next output
{'1': {'description': 'An NLP ingest pipeline',
'processors': [{'text_embedding': {'model_id': '7ouF75QBSNMx2eSvCsQ-',
'field_map': {'text': 'sentence_embedding'}}}]}
Test the pipeline
body_simulate = {
"docs": [
{
"_index": "run",
"_id": "1",
"_source": {
"text": ["how are you"]
}
}
]
}
ingest_client.simulate(id=1, body=body_simulate)
gives the following error
{'docs': [{'error': {'root_cause': [{'type': 'illegal_argument_exception',
'reason': 'Invalid payload: { "text":${parameters.text}}'}],
'type': 'illegal_argument_exception',
'reason': 'Invalid payload: { "text":${parameters.text}}'}}]}
why does this error occur? what’s wrong?