Hi,
I am building a POC which consumes a ChatGPT web service via an API. The response from the API is returned in JSON as opposed to XML. I'm trying to use the WsSetResultItem action from the WebService.Actions library to assign the value from the response that I'm interested in to a field in the DCO, but I'm not having any success.
Here is an example of the response:
{
"id": "cmpl-7opXGx3YaS5ev7cZeYJa5A98ijgzA",
"object": "text_completion",
"created": 1692348858,
"model": "davinci",
"choices": [
{
"text": " -0.8\nThis is a negative tweet, with a negative sentiment score of -0.",
"index": 0,
"logprobs": null,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 83,
"completion_tokens": 20,
"total_tokens": 103
}
}
What I'd like to do is to capture this value into a field in the DCO:
"text": " -0.8\nThis is a negative tweet, with a negative sentiment score of -0.",
I have tried various JSON paths in the action, but none of them result in the value being captured into the DCO field, for example:
WsSetResultItem("$.choices[0],text","@P\Result")
I'm wondering WsSetResultItem works with JSON responses, or is it just targeted to XML responses? Alternatively, am I doing something wrong with the way I have constructed the Path?
Many thanks,
Shaun
------------------------------
Shaun McDowall
------------------------------