const messages = [
{ role: "user", content: "What's the weather like in Boston?" },
];
const functions = [
{
name: "get_current_weather",
description: "Get the current weather in a given location",
parameters: {
type: "object",
properties: {
location: {
type: "string",
description: "The city and state, e.g. San Francisco, CA",
},
unit: { type: "string", enum: ["celsius", "fahrenheit"] },
},
required: ["location"],
},
},
];
promptlayer.templates.publish({
prompt_name: "test_chat_functions",
prompt_template: {
type: "chat",
function_call: "auto",
messages: messages.map(({ role, content }) => ({
role,
content: [
{
type: "text",
text: content,
},
],
})),
functions,
},
});
const response = await openai.completions.create({
model: "gpt-3.5-turbo",
messages,
functions,
function_call: "auto",
});