/**
* This part feels a bit weird to me.
*
* Is this the intended usage?
*/
messages.push(
// Add tool-call as the first tool-related message
Prompt.makeMessage("assistant", {
content: firstResponse.toolCalls.map((call: any) =>
Prompt.makePart("tool-call", {
id: call.id,
name: call.name,
params: call.params,
providerExecuted: call.providerExecuted ?? false,
})
),
}),
// Add tool results as their own messages
// I believe this format has to do with the OpenAI API
// https://platform.openai.com/docs/guides/function-calling#the-tool-calling-flow
...firstResponse.toolResults.map((tr: any) =>
Prompt.makeMessage("tool", {
content: [
Prompt.makePart("tool-result", {
id: tr.id,
name: tr.name,
result: tr.result,
isFailure: tr.isFailure ?? false,
}),
],
})
)
);
/**
* This part feels a bit weird to me.
*
* Is this the intended usage?
*/
messages.push(
// Add tool-call as the first tool-related message
Prompt.makeMessage("assistant", {
content: firstResponse.toolCalls.map((call: any) =>
Prompt.makePart("tool-call", {
id: call.id,
name: call.name,
params: call.params,
providerExecuted: call.providerExecuted ?? false,
})
),
}),
// Add tool results as their own messages
// I believe this format has to do with the OpenAI API
// https://platform.openai.com/docs/guides/function-calling#the-tool-calling-flow
...firstResponse.toolResults.map((tr: any) =>
Prompt.makeMessage("tool", {
content: [
Prompt.makePart("tool-result", {
id: tr.id,
name: tr.name,
result: tr.result,
isFailure: tr.isFailure ?? false,
}),
],
})
)
);