# Post\_process\_function

**URL:** <https://forum.opensearch.org/t/post-process-function/20552>\
**Category:** Machine Learning\
**Tags:** troubleshoot, configure\
**Created:** [July 27, 2024, 9:50am UTC](https://forum.opensearch.org/t/post-process-function/20552 "2024-07-27T09:50:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkrajput](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@dkrajput](https://forum.opensearch.org/u/dkrajput)\
**Post date:** [July 27, 2024, 9:50am UTC](https://forum.opensearch.org/t/post-process-function/20552/1 "2024-07-27T09:50:24Z")

</div>

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

**Describe the issue** :

**Configuration** :

**Relevant Logs or Screenshots** :

Anyone having post processing function which can overwrite the output of inference\_response.

I tried multiple things but found that **post\_process\_function** always return string output, which get’s added under DataMap.

Example,  
If I use below function:

“post\_process\_function”: "def json = [‘{ "model": "’ + params.model + ‘",’ +\n ‘"dataAsMap": { "choices": "’ + params.message +\n ‘"}}’];\n return ‘’+json+‘’;\n \n "

then out put is:

{  
“inference\_results”: [  
{  
“output”: [  
{  
“name”: “response”,  
“dataAsMap”: {  
“response”: “”“[{ “model”: “llama3:latest”,“dataAsMap”: { “choices”: “{role=assistant, content=What a great question!..etc  
}”}}]”“”  
}  
}  
],  
“status\_code”: 200  
}  
]  
}

But expecting is:

“response”: [  
{ “model”: “llama3:latest”,“dataAsMap”: { “choices”: “{role=assistant, content=What a great question!..etc  
}”}}  
]

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [September 25, 2024, 9:50am UTC](https://forum.opensearch.org/t/post-process-function/20552/2 "2024-09-25T09:50:40Z")

</div>

Closed on September 25, 2024, 9:50am UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
