Update- it appears that in my case, setting the temperature to 0 seemed to work for the above case, however, when I added another variable, it wouldn’t display it even though it was required (granted, I’m not following chatGPT’s format exactly, but pretty close):
[{‘name’: ‘getNews’, ‘description’: ‘News API function’, ‘parameters’: {‘type’: ‘object’, ‘properties’: {‘module’: {‘description’: ‘Python Module to Call to run function’, ‘type’: ‘string’, ‘default’: ‘functions.newsapi_org’}, ‘q’: {‘description’: ‘Query to return news stories’, ‘type’: ‘string’}, ‘language’: {‘description’: ‘Language of News’, ‘enum’: [‘en’, ‘es’], ‘default’: ‘en’, ‘type’: ‘string’}, ‘sortBy’: {‘description’: ‘Sort By item’, ‘type’: ‘string’}, ‘pageSize’: {‘description’: ‘Page Size’, ‘type’: ‘integer’}}}, ‘required’: [‘module’, ‘q’, ‘language’, ‘pageSize’]}]
Reply from chatcompletion:
“choices”: [
{
“index”: 0,
“message”: {
“role”: “assistant”,
“content”: null,
“function_call”: {
“name”: “getNews”,
“arguments”: “{\n "q": "US Economic News",\n "language": "en",\n "pageSize": 5\n}”
}
},
“finish_reason”: “function_call”
}
],
And yes, I understand the gaping security flaws with this, and yes, I will have a dictionary of “allowable” modules and functions to validate against prior to running code from chatGPT. 