Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created June 14, 2023 13:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odrobnik/bda5d89836dc9794fb9dcd614b123966 to your computer and use it in GitHub Desktop.
Save odrobnik/bda5d89836dc9794fb9dcd614b123966 to your computer and use it in GitHub Desktop.
POST https://api.openai.com/v1/chat/completions
{
"functions" : [
{
"name" : "date",
"description" : "Get the current date and time",
"parameters" : {
"type" : "object",
"properties" : {
}
}
},
{
"name" : "birthday",
"description" : "Get the user's birthday",
"parameters" : {
"type" : "object",
"properties" : {
"user" : {
"type" : "string"
}
}
}
}
],
"messages" : [
{
"content" : "You are a personal assistent.",
"role" : "system"
},
{
"content" : "How many days until my next birthday?",
"role" : "user",
"name" : "Oliver"
}
],
"model" : "gpt-3.5-turbo-0613"
}
------------------------------------------
{
"id": "chatcmpl-7RKa8oqbI8yQ3WctWBpYFqjsa2erI",
"object": "chat.completion",
"created": 1686748328,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"function_call": {
"name": "birthday",
"arguments": "{\n \"user\": \"Oliver\"\n}"
}
},
"finish_reason": "function_call"
}
],
"usage": {
"prompt_tokens": 77,
"completion_tokens": 16,
"total_tokens": 93
}
}
POST https://api.openai.com/v1/chat/completions
{
"functions" : [
{
"name" : "date",
"description" : "Get the current date and time",
"parameters" : {
"type" : "object",
"properties" : {
}
}
},
{
"name" : "birthday",
"description" : "Get the user's birthday",
"parameters" : {
"type" : "object",
"properties" : {
"user" : {
"type" : "string"
}
}
}
}
],
"messages" : [
{
"content" : "You are a personal assistent.",
"role" : "system"
},
{
"content" : "How many days until my next birthday?",
"role" : "user",
"name" : "Oliver"
},
{
"content" : null,
"role" : "assistant",
"function_call" : {
"name" : "birthday",
"arguments" : "{\n \"user\": \"Oliver\"\n}"
}
},
{
"content" : "24 Jul 1974",
"role" : "function",
"name" : "birthday"
}
],
"model" : "gpt-3.5-turbo-0613"
}
------------------------------------------
{
"id": "chatcmpl-7RKa8xULeyAE9Ad8ryliqAduR3oR5",
"object": "chat.completion",
"created": 1686748328,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"function_call": {
"name": "date",
"arguments": "{}"
}
},
"finish_reason": "function_call"
}
],
"usage": {
"prompt_tokens": 105,
"completion_tokens": 6,
"total_tokens": 111
}
}
POST https://api.openai.com/v1/chat/completions
{
"functions" : [
{
"name" : "date",
"description" : "Get the current date and time",
"parameters" : {
"type" : "object",
"properties" : {
}
}
},
{
"name" : "birthday",
"description" : "Get the user's birthday",
"parameters" : {
"type" : "object",
"properties" : {
"user" : {
"type" : "string"
}
}
}
}
],
"messages" : [
{
"content" : "You are a personal assistent.",
"role" : "system"
},
{
"content" : "How many days until my next birthday?",
"role" : "user",
"name" : "Oliver"
},
{
"content" : null,
"role" : "assistant",
"function_call" : {
"name" : "birthday",
"arguments" : "{\n \"user\": \"Oliver\"\n}"
}
},
{
"content" : "24 Jul 1974",
"role" : "function",
"name" : "birthday"
},
{
"content" : null,
"role" : "assistant",
"function_call" : {
"name" : "date",
"arguments" : "{}"
}
},
{
"content" : "Mi 14 Jun 2023 13:46:22 CEST",
"role" : "function",
"name" : "date"
}
],
"model" : "gpt-3.5-turbo-0613"
}
------------------------------------------
{
"id": "chatcmpl-7RKa8jXfGDUPnMtlX6L431XjUcYFA",
"object": "chat.completion",
"created": 1686748328,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"function_call": {
"name": "python",
"arguments": "from datetime import datetime\n\ncurrent_date = datetime.now()\nnext_birthday = datetime(current_date.year, 7, 24)\n\nif current_date > next_birthday:\n next_birthday = datetime(current_date.year + 1, 7, 24)\n\ndays_until_birthday = (next_birthday - current_date).days\ndays_until_birthday"
}
},
"finish_reason": "function_call"
}
],
"usage": {
"prompt_tokens": 133,
"completion_tokens": 77,
"total_tokens": 210
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment