Can AI Functions work effectively with multiple inputs that it needs to iterate over?

I have a simple AI Function setup that's working. It extracts a couple of bits of info from the user message and returns them as arguments for my function. So far, so simple. What I'm struggling to do (and this may not be possible) is to get it to perform well with multiple inputs. Suppose my user message was this - a JSON-formatted array of user messages, and I wanted to extract the sentiment and categories for each one:
{
role: "user",
content: JSON.stringify([
"I like cars and parsnips",
"Potholes are a real problem on city roads",
"Christmas comes around too early"
])
}
{
role: "user",
content: JSON.stringify([
"I like cars and parsnips",
"Potholes are a real problem on city roads",
"Christmas comes around too early"
])
}
I'm struggling to sest up the tools > parameters > properties section such that it can report on each message in the input. I've tried something like:
parameters: {
type: 'object',
properties: {
msg1Sentiment: {type: 'string', description: 'The sentiment of message 1 - unhappy, neutral or happy'},
msg1Categories: {type: 'array', description: 'One or more categories relating to message 1'},
msg2Sentiment: {type: 'string', description: 'The sentiment of message 2 - unhappy, neutral or happy'},
msg2Categories: {type: 'array', description: 'One or more categories relating to message 2'},
...
}
}
parameters: {
type: 'object',
properties: {
msg1Sentiment: {type: 'string', description: 'The sentiment of message 1 - unhappy, neutral or happy'},
msg1Categories: {type: 'array', description: 'One or more categories relating to message 1'},
msg2Sentiment: {type: 'string', description: 'The sentiment of message 2 - unhappy, neutral or happy'},
msg2Categories: {type: 'array', description: 'One or more categories relating to message 2'},
...
}
}
Sometimes this sort of works and at other times it just gives nonsensical responses or breaks down. I've also tried asking it to give me an object of params per message, like so:
parameters: {
type: 'object',
properties: {
msg1Data: {type: 'object', description: 'Object about message 1, containing two properties: "sentiment" and "categories"'},
msg2Data: {type: 'object', description: 'Object about message 2, containing two properties: "sentiment" and "categories"'},
...
}
}
parameters: {
type: 'object',
properties: {
msg1Data: {type: 'object', description: 'Object about message 1, containing two properties: "sentiment" and "categories"'},
msg2Data: {type: 'object', description: 'Object about message 2, containing two properties: "sentiment" and "categories"'},
...
}
}
...but this rarely works out well. Is there a better way here?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server