AI provider type: Azure OpenAI
Chat completion model: o3-mini
Does anybody have experience with the LLM Chat Completion action and solved the cleanup needed on the Chat History output to bring it back to a usable format?
I had encountered a Status Code -4 of the action, which turns out to mean: “ Unsuccessful (invalid history). See the input parameter Chat history in the table above on how the chat history should be formatted.”
In my example I just put the Output Parameter of the LLM Chat completion in a Process variable and use that again as input of the next request. Turns out the output is so enriched, it does not follow the required format anymore.
Here my example:
Prompt: “Pick a number between 1 and 10”
Received chat message: “Alright, I'll go with the number 7.”
Prompt: “Now add 3 to it”
This fails and that is because the history does not look like mentioned here: https://docs.thinkwisesoftware.com/docs/sf/llm#example-customer-support-with-llm-chat-completion
s
{
"role": "system",
"content": "You are a concise assistant that provides context to and answers questions about customer service tickets. These tickets consist of a number of emails. When asked for a summary, ALWAYS respond with \"order no:\" followed by the order number or \"not provided\" if not provided, and then respond with \"summary:\" followed by a one to two-sentence summary of the support ticket."
},
{
"role": "user",
"content": "email: Dear Customer Support,\n\nI am writing regarding an order that I recently placed on your website. I received the package yesterday, but unfortunately, it was missing an item that I had ordered.\n\nThe order number is #123456 and the missing item is a blue hoodie in size medium. However, when I opened the package, I noticed that the hoodie was not included. I have checked the entire package thoroughly, and it is clear that the item was not included or accidentally removed during the packaging process.\n\nI kindly request your assistance in resolving this issue as soon as possible. I would appreciate if the missing hoodie could be sent to me promptly or if alternative arrangements could be made. I have been a loyal customer for several years and have always been satisfied with the products and services provided by your company.\n\nPlease let me know what steps should be taken to rectify this situation. I have attached a copy of the order confirmation for your reference. If there is any additional information or documentation required, please do not hesitate to ask.\n\nThank you for your attention to this matter. I hope to receive a prompt response and a resolution to this issue.\n\nKind regards,\n\nBob."
},
{
"role": "user",
"content": "email: Hi Customer Support,\n\nQuick follow-up! I forgot to mention but it wasn't blue but more of a greenish.\n\nBob."
},
{
"role": "user",
"content": "Briefly summarize the customer's problem or question."
}
]
But looks like this:
s
{
"AuthorName": null,
"Role": {
"Label": "user"
},
"Content": "Pick a number between 1 and 10",
"Items": <
{
"Text": "Pick a number between 1 and 10",
"Encoding": {
"BodyName": "utf-8",
"EncodingName": "Unicode (UTF-8)",
"HeaderName": "utf-8",
"WebName": "utf-8",
"WindowsCodePage": 1200,
"IsBrowserDisplay": true,
"IsBrowserSave": true,
"IsMailNewsDisplay": true,
"IsMailNewsSave": true,
"IsSingleByte": false,
"EncoderFallback": {
"DefaultString": "�",
"MaxCharCount": 1
},
"DecoderFallback": {
"DefaultString": "�",
"MaxCharCount": 1
},
"IsReadOnly": true,
"CodePage": 65001
},
"MimeType": null,
"InnerContent": null,
"ModelId": null,
"Metadata": null
}
],
"Encoding": {
"BodyName": "utf-8",
"EncodingName": "Unicode (UTF-8)",
"HeaderName": "utf-8",
"WebName": "utf-8",
"WindowsCodePage": 1200,
"IsBrowserDisplay": true,
"IsBrowserSave": true,
"IsMailNewsDisplay": true,
"IsMailNewsSave": true,
"IsSingleByte": false,
"EncoderFallback": {
"DefaultString": "�",
"MaxCharCount": 1
},
"DecoderFallback": {
"DefaultString": "�",
"MaxCharCount": 1
},
"IsReadOnly": true,
"CodePage": 65001
},
"Source": null,
"MimeType": null,
"InnerContent": null,
"ModelId": null,
"Metadata": null
},
{
"AuthorName": null,
"Role": {
"Label": "assistant"
},
"Content": "Alright, I'll go with the number 7.",
"Items": b
{
"Text": "Alright, I'll go with the number 7.",
"Encoding": {
"BodyName": "utf-8",
"EncodingName": "Unicode (UTF-8)",
"HeaderName": "utf-8",
"WebName": "utf-8",
"WindowsCodePage": 1200,
"IsBrowserDisplay": true,
"IsBrowserSave": true,
"IsMailNewsDisplay": true,
"IsMailNewsSave": true,
"IsSingleByte": false,
"EncoderFallback": {
"DefaultString": "�",
"MaxCharCount": 1
},
"DecoderFallback": {
"DefaultString": "�",
"MaxCharCount": 1
},
"IsReadOnly": true,
"CodePage": 65001
},
"MimeType": null,
"InnerContent": null,
"ModelId": null,
"Metadata": null
}
],
"Encoding": {
"BodyName": "utf-8",
"EncodingName": "Unicode (UTF-8)",
"HeaderName": "utf-8",
"WebName": "utf-8",
"WindowsCodePage": 1200,
"IsBrowserDisplay": true,
"IsBrowserSave": true,
"IsMailNewsDisplay": true,
"IsMailNewsSave": true,
"IsSingleByte": false,
"EncoderFallback": {
"DefaultString": "�",
"MaxCharCount": 1
},
"DecoderFallback": {
"DefaultString": "�",
"MaxCharCount": 1
},
"IsReadOnly": true,
"CodePage": 65001
},
"Source": null,
"MimeType": null,
"InnerContent": null,
"ModelId": null,
"Metadata": null
}
]
I can probably manage to rework this to the correct format in a next step, but perhaps there are other solutions that I did not think of.
Thank you in advance.