import requests
# URL and headers
url = "http://api.promptlayer.com/track-request"
headers = {
"Content-Type": "application/json",
}
# Data payload
data_payload = {
"function_name": "openai.ChatCompletion.create",
"kwargs": {
"messages": [
{
"content": "You are a helpful AI assistant.",
"role": "system"
},
{
"content": "What's the weather like in Boston?",
"role": "user"
}
],
"model": "gpt-3.5-turbo-16k",
"function_call": "auto",
"functions": [
{
"description": "Get the current weather in a given location",
"name": "get_current_weather",
"parameters": {
"properties": {
"location": {
"description": "The city and state, e.g. San Francisco, CA",
"type": "string"
},
"unit": {
"enum": [
"celsius",
"fahrenheit"
],
"type": "string"
}
},
"required": [
"location"
],
"type": "object"
}
}
]
},
"request_response": {
"choices": [
{
"index": 0,
"message": {
"content": "",
"function_call": {
"arguments": "{\n\"location\": \"Boston, MA\"\n}",
"name": "get_current_weather"
},
"role": "assistant"
},
"finish_reason": "function_call"
}
],
"usage": {
"prompt_tokens": 778,
"completion_tokens": 28,
"total_tokens": 806
}
},
"tags": [
"docs"
],
"request_start_time": 1693505089.21,
"request_end_time": 1693505093.572,
"api_key": "pl_<YOUR_API_KEY>"
}
# Making the request
response = requests.post(url, headers=headers, json=data_payload)
print(response.json())