With function calls, are system messages or description properties preferable to instruct AI?

I realise that title is not super clear. Basically I've found that both of the following function calls produce the same result. One users a type=system message to instruct AI, while the other omits this and instead provides description properties. If I do neither approach, I get erroneous/extra results from just the two bits asked for (fruit + vegetable). Which is preferable, according to how this functionality is designed? Version 1 - with system message
const response = await env.AI.run('@hf/nousresearch/hermes-2-pro-mistral-7b', {
messages: [{
role: "system",
content: "Extract the user's favourite fruit and vegetable"
}, {
role: "user",
content: 'I like pineapple, cars, carrots and Belgium.',
}],
tools: [{
name: "say",
parameters: {
type: "object",
properties: {
fruit: {type: "string"},
vegetable: {type: "string"},
},
required: ["fruit", "vegetable"],
},
}],
});
const response = await env.AI.run('@hf/nousresearch/hermes-2-pro-mistral-7b', {
messages: [{
role: "system",
content: "Extract the user's favourite fruit and vegetable"
}, {
role: "user",
content: 'I like pineapple, cars, carrots and Belgium.',
}],
tools: [{
name: "say",
parameters: {
type: "object",
properties: {
fruit: {type: "string"},
vegetable: {type: "string"},
},
required: ["fruit", "vegetable"],
},
}],
});
Version 2: with description properties
const response = await env.AI.run('@hf/nousresearch/hermes-2-pro-mistral-7b', {
messages: [{
role: "user",
content: 'I like pineapple, cars, carrots and Belgium.',
}],
tools: [{
name: "say",
description: "Extract the user's favourite fruit and vegetable",
parameters: {
type: "object",
properties: {
fruit: {type: "string", description: "The user's favourite fruit"},
vegetable: {type: "string", description: "The user's favourite vegetable"},
},
required: ["fruit", "vegetable"],
},
}],
});
const response = await env.AI.run('@hf/nousresearch/hermes-2-pro-mistral-7b', {
messages: [{
role: "user",
content: 'I like pineapple, cars, carrots and Belgium.',
}],
tools: [{
name: "say",
description: "Extract the user's favourite fruit and vegetable",
parameters: {
type: "object",
properties: {
fruit: {type: "string", description: "The user's favourite fruit"},
vegetable: {type: "string", description: "The user's favourite vegetable"},
},
required: ["fruit", "vegetable"],
},
}],
});
Thank you in advance.
3 Replies
Mitya
Mitya3mo ago
Can anyone help me here?
rayberra
rayberra3mo ago
The tool definitions will end up in the system prompt regardless of approach, but you should use the syntax you show in version 2.
Mitya
Mitya3mo ago
Awesome, thank you.
Want results from more Discord servers?
Add your server