0

{ "id": "chatcmpl-7bfXu0KfUg1NaPV4CVR3BRi0eFcPT", "object": "chat.completion", "created": 1689212194, "model": "gpt-3.5-turbo-0613", "choices": [{ "index": 0, "message": { "role": "assistant", "content": "<!DOCTYPE html>\n<html>\n<head>\n <title>Thank You Email</title>\n</head>\n<body>\n <div style="padding: 20px;">\n <h1><img src="https://example.com/logo.png%5C" alt="Logo" style="height: 50px;"> Thank You for Your Support!</h1>\n <p>Dear [Recipient's Name],</p>\n <p>We would like to express our heartfelt gratitude for your support and cooperation. Your contribution has made a significant impact on our organization and our cause.</p>\n <p>Thanks to your generosity, we have been able to [describe the achievement or project made possible with their support]. Without your help, this would not have been possible.</p>\n <p>We value your ongoing commitment and would like to extend our sincere thanks once again for believing in our mission and choosing to support our work. Your contribution is truly appreciated.</p>\n <p>If you have any further questions or would like to stay updated on our progress, please feel free to reach out to us. We are always here to answer any queries you may have.</p>\n <p>Once again, thank you for your kindness and support.</p>\n <p>Warm regards,<br>[Your Name]<br>[Your Organization]</p>\n </div>\n</body>\n</html>" }, "finish_reason": "stop" }], "usage": { "prompt_tokens": 13, "completion_tokens": 281, "total_tokens": 294 } }

I have used the BuildRowsetFromJSON(), below is the code

%%[ SET @json = '{"id":"chatcmpl-7bfXu0KfUg1NaPV4CVR3BRi0eFcPT","object":"chat.completion","created":1689212194,"model":"gpt-3.5-turbo-0613","choices":[{"index":0,"message":{"role":"assistant","content":"\n\n\n Thank You Email</title>\n</head>\n\n <div style="padding: 20px;">\n <img src="https://example.com/logo.png" alt="Logo" style="height: 50px;"> Thank You for Your Support!</h1>\n

Dear </p>\n

We would like to express our heartfelt gratitude for your support and cooperation. Your contribution has made a significant impact on our organization and our cause.</p>\n

Thanks to your generosity, we have been able to [describe the achievement or project made possible with their support]. Without your help, this would not have been possible.</p>\n

We value your ongoing commitment and would like to extend our sincere thanks once again for believing in our mission and choosing to support our work. Your contribution is truly appreciated.</p>\n

If you have any further questions or would like to stay updated on our progress, please feel free to reach out to us. We are always here to answer any queries you may have.</p>\n

Once again, thank you for your kindness and support.</p>\n

Warm regards,
[Your Name]
[Your Organization]</p>\n </div>\n</body>\n</html>"},"finish_reason":"stop"}],"usage":{"prompt_tokens":13,"completion_tokens":281,"total_tokens":294}}'

SET @rows = BuildRowsetFromJson(@json, '$.choices[*]', 0)

SET @rowcount =Rowcount(@rows) SET @row = Field(Row(@rows,1),3)

]%%

Out: %%=v(@row)=%%

I am getting output as - Out: stop

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jul 19 '23 at 12:29

1 Answers1

0

I got your code to work with the following:

%%[
Set @passedJSON = '{"id":"chatcmpl-7bfXu0KfUg1NaPV4CVR3BRi0eFcPT","object":"chat.completion","created":1689212194,"model":"gpt-3.5-turbo-0613","choices":[{"index":0,"message":{"role":"assistant","content":"\n\n\n Thank You Email</title>\n</head>\n\n <div style=''padding: 20px;''>\n <img src=''https://example.com/logo.png'' alt=''Logo'' style=''height: 50px;''> Thank You for Your Support!</h1>\nDear </p>\nWe would like to express our heartfelt gratitude for your support and cooperation. Your contribution has made a significant impact on our organization and our cause.</p>\nThanks to your generosity, we have been able to [describe the achievement or project made possible with their support]. Without your help, this would not have been possible.</p>\nWe value your ongoing commitment and would like to extend our sincere thanks once again for believing in our mission and choosing to support our work. Your contribution is truly appreciated.</p>\nf you have any further questions or would like to stay updated on our progress, please feel free to reach out to us. We are always here to answer any queries you may have.</p>\nOnce again, thank you for your kindness and support.</p>\nWarm regards,[Your Name][Your Organization]</p>\n </div>\n</body>\n</html>"},"finish_reason":"stop"}],"usage":{"prompt_tokens":13,"completion_tokens":281,"total_tokens":294}}'
Set @key_content = BuildRowSetFromJSON(@passedJSON, '$.choices[*].message', 1)

If RowCount(@key_content) > 0 Then
  Set @row_passedJSON = Row(@key_content, 1)
  Set @content        = Field(@row_passedJSON,'content')
Else
/*RowCount() returned 0*/
EndIf
]%%

%%=v(@content)=%%
  • Your JSON payload isn't in the correct syntax, specifically the double-quotes are not cancelled out properly.
  • The JSON argument in your BuildRowSetFromJSON function needs to go another level in.
edu8rdo
  • 216
  • 1
  • 8