Skip to content

Instantly share code, notes, and snippets.

@hansvdam
Last active March 12, 2024 06:51
Show Gist options
  • Save hansvdam/8b9269390e16fa0bf394d7656bec1ea5 to your computer and use it in GitHub Desktop.
Save hansvdam/8b9269390e16fa0bf394d7656bec1ea5 to your computer and use it in GitHub Desktop.
sample openai curl with function calling
curl --location 'https://api.openai.com/v1/chat/completions' \
--header 'Content-Type: application/json' \
-u :$OPENAI_API_KEY \
--data '{
"messages": [
{
"role": "system",
"content": "The current date and time is 2023-07-22T13:57:34+02:00. Be very presumptive when guessing the values of function parameters."
},
{
"role": "user",
"content": "What things can I do in Amsterdam?"
}
],
"model": "gpt-4-0613",
"max_tokens": null,
"stream": false,
"n": 1,
"temperature": 0.0,
"functions": [
{
"name": "planner",
"description": "Plan a public transport trip from train station A to station B in the Netherlands.",
"parameters": {
"type": "object",
"properties": {
"origin": {
"description": "origin station name in the Netherlands for the trip. Be presumtive and accept very short shorthands.",
"type": "string"
},
"destination": {
"description": "destination station name in the Netherlands for the trip. Be presumptive and accept very short shorthands.",
"type": "string"
},
"trip_date_time": {
"description": "Requested DateTime for the departure or arrival of the trip in '\''YYYY-MM-DDTHH:MM:SS+02:00'\'' format. The user will use a time in a 12 hour system, make an intelligent guess about what the user is most likely to mean in terms of a 24 hour system, e.g. not planning for the past.",
"type": "string"
},
"departure": {
"description": "True to depart at the given time, False to arrive at the given time",
"type": "boolean"
},
"language": {
"description": "Language of the input text",
"type": "string"
}
},
"required": [
"origin",
"destination",
"departure",
"language"
]
}
},
{
"name": "train_station_departures",
"description": "Show the departures from a train station in the Netherlands",
"parameters": {
"type": "object",
"properties": {
"departure_station": {
"description": "Departure train station in the Netherlands",
"type": "string"
},
"dateTime": {
"description": "Requested DateTime for the departures or arrival of the trip in '\''YYYY-MM-DDTHH:MM:SS+02:00'\'' format.",
"type": "string"
},
"transport_type": {
"description": "Type of departures to show. Either '\''train'\'' or '\''bus'\''",
"enum": [
"train",
"bus"
],
"type": "string"
}
},
"required": [
"departure_station",
"dateTime"
]
}
},
{
"name": "outings",
"description": "Show the available outings in an area in the Netherlands",
"parameters": {
"type": "object",
"properties": {
"area": {
"description": "Area in the Netherlands",
"type": "string"
}
},
"required": [
"area"
]
}
},
{
"name": "show_screen",
"description": "Determine which screen the user wants to see",
"parameters": {
"type": "object",
"properties": {
"screen_to_show": {
"description": "type of screen to show. Either '\''account'\'': '\''all personal data of the user'\'', '\''settings'\'': '\''if the user wants to change the settings of the app'\''",
"enum": [
"account",
"settings"
],
"type": "string"
}
},
"required": [
"screen_to_show"
]
}
},
{
"name": "custom_search",
"description": "answer all questions about NS",
"parameters": {
"title": "QAToolInput",
"type": "object",
"properties": {
"question": {
"title": "Question",
"description": "question about NS",
"type": "string"
}
},
"required": [
"question"
]
}
}
]
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment