as is outlined in this blog post. I have also tried entering it manually: [{"role":"user","content":"Hello"},{"role":"assistant","content":"Hello! How can I assist you today?"}]
I keep getting the same configuration error.
What am I doing wrong?
The prop input field can accept strings or evaluate JS code. So when you input {{steps.chat.$return_value.original_messages_with_assistant_response}} it will evaluate the return value given from the chat step, taking the original_messages_with_assistant_response key in the resulted object.
So can you confirm that the chat step returned object has the original_messages_with_assistant_response key?
You can also input it manually, as you mentioned. But for it to be evaluated as JS, it should be wrapped in {{ }}, as so: {{[{"role":"user","content":"Hello"},{"role":"assistant","content":"Hello! How can I assist you today?"}]}}
Yes, it returns as follows: Configuration error The following message doesn't have a "role" property: [ { "role": "user", "content": "Hello" }, { "role": "assistant", "content": "Hi there! How may I assist you today?" } ]
When I enter manually in this format: {{[{"role":"user","content":"Hello"},{"role":"assistant","content":"Hello! How can I assist you today?"}]}}
I get back "SyntaxError
Invalid or unexpected token"
I tried by copying and pasting the manual code, and ran successfully.
Are you able to take a screenshot of the step? Feel free to block any sensitive information
Yes! that worked.
Can you explain this?
I want to build a chat with a data store that updates the chat history, based on previous results. How can I do this if the result I result I update the data store with returns an error. How would I add those numbers you added in my data store automatically?
Thank You
After openai generates content, I append it to a data record. In the workflow, before openai I include ‘get record’ from data store. In prior messages I input the result from ‘get record’.
Thanks for the screenshots, they are very helpful.
So in the second image, instead of passing the value through Construct an array, can you please try in Enter a custom expression? Because currently it is passing inside an array with length 1
With this method I am only retrieving one result from the dataset. How would I write in a few numbers
for example 1 to 18
{{steps.get_record_or_create.$return_value[1,18]}}
Thank You for your help.
In your data store, you can save an array of objects like {"role":"user","content":"Hello"} , start with an empty array [] . Then in the end of your workflow execution, you can append the response in the data store object and save it again. For example:
Get array of prior messages from data store
Pass array to OpenAI with your prompt
Create a new object with your prompt and the OpenAI response, e.g. priorMessagesArray.push([{"role": "user", "content": "your prompt"}, {"role": "assistant": "response from OpenAI"}])
Save the updated array back to the data store
Then as you workflow executes, you can append the response
My question is, being that I can’t pass the whole array to prior message history like: {{steps.get_record_or_create.$return_value}}
only by writing the actual value like: {{steps.get_record_or_create.$return_value[18]}}
How can I write the last 2 values
I want to write something like this: {{steps.get_record_or_create.$return_value[-1, -2]}}