messages = [{"role": "user", "content": "What's the weather like in Boston?"}]
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": [
{
"role": role,
"content": [
{
"type": "text",
"text": content,
}
],
}
for (role, content) in map(lambda x: x.values(), messages)
],
"functions": functions,
}
})
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages,
functions=functions,
function_call="auto",
)