Pre_process_function not working

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser): 2.19
0

Describe the issue: I’m trying to create a custom pre_process_function for a self hosted vllm based cross-encoder. I followed the exampled provided by the documentation but it doesn’t look like the pre_process_function is being called. I tried to put an invalid syntax in the painless script but opensearch didn’t flag it. When i put the same invalid code in the post_process_function, opensearch flagged it.

Configuration:

Relevant Logs or Screenshots: Here’s the connector definition:
{
“name”: “connector-multifield”,
“version”: “1”,
“description”: “Connector to externally hosted cross-encoder model”,
“protocol”: “http”,
“parameters”: {
“endpoint”: “vllm-rerank:7777”,
“model”: “/models/custom-rerank-model”
},
“actions”: [
{
“action_type”: “PREDICT”,
“method”: “POST”,
“url”: “http://${parameters.endpoint}/v2/rerank”,
“headers”: {
“content-type”: “application/json”
},
“request_body”: “”“{
“model”:”${parameters.model}“,
“truncate_prompt_tokens”:1,
“priority”:0,
“query”:”${parameters.query}“,
“documents”: ${parameters.chunks}
}
“””,
“pre_process_function”: “”"
def chunks = new ArrayList();
if( params.topic_chunks != null){
chunks.addAll(params.topic_chunks);
}
if( params.discussion_chunks != null){
chunks.addAll(discussion_chunks);
}
if( params.recommendation_chunks != null ){
chunks.addAll(recommendation_chunks);
}
return ‘{“parameters”:{“chunks”:’+ chunks +‘}}’;
“”“,
“post_process_function”: “””
double maxScore = Double.NEGATIVE_INFINITY;

    if (params.containsKey('results') && params.results != null){
      for (def item : params.results) {
        double s = ((Number)item.relevance_score).doubleValue();
        if (s > maxScore) {
          maxScore = s;
        }
      }
    }
    
    if (maxScore == Double.NEGATIVE_INFINITY) {
      maxScore = 0.0;
    }
    return ""+ maxScore + "";
  """
}

]
}
}