Merge branch 'function_calls' of https://github.com/openai/openai-cookbook into function_calls

This commit is contained in:
Colin Jarvis 2023-06-13 17:59:11 +01:00
commit d9677ebb89

View File

@ -269,7 +269,7 @@
} }
], ],
"source": [ "source": [
"# The model first prompts the user for the information it needs to use the weather tool\n", "# The model first prompts the user for the information it needs to use the weather function\n",
"chat_response = chat_completion_request(\n", "chat_response = chat_completion_request(\n",
" conversation.conversation_history, functions=functions\n", " conversation.conversation_history, functions=functions\n",
")\n", ")\n",
@ -428,7 +428,7 @@
"functions = [\n", "functions = [\n",
" {\n", " {\n",
" \"name\": \"ask_database\",\n", " \"name\": \"ask_database\",\n",
" \"description\": \"Use this tool to answer user questions about music. Output should be a fully formed SQL query.\",\n", " \"description\": \"Use this function to answer user questions about music. Output should be a fully formed SQL query.\",\n",
" \"parameters\": {\n", " \"parameters\": {\n",
" \"type\": \"object\",\n", " \"type\": \"object\",\n",
" \"properties\": {\n", " \"properties\": {\n",
@ -760,13 +760,13 @@
"id": "c282b9e3", "id": "c282b9e3",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Using Multiple Tools at Once\n", "## Using Multiple Functions\n",
"\n", "\n",
"Now let's construct a scenario in which we provide a model with more than one function to call. We'll create an agent that uses data from arXiv to answer questions about academic subjects. It has two new functions at its disposal:\n", "Now let's construct a scenario in which we provide a model with more than one function to call. We'll create an agent that uses data from arXiv to answer questions about academic subjects. It has two new functions at its disposal:\n",
"- **get_articles**: A function that gets arXiv articles on a subject and summarizes them for the user with links.\n", "- **get_articles**: A function that gets arXiv articles on a subject and summarizes them for the user with links.\n",
"- **reader_tool**: This function takes one of the previously searched articles, reads it in its entirety and summarizes the core argument, evidence and conclusions.\n", "- **read_article_and_summarize**: This function takes one of the previously searched articles, reads it in its entirety and summarizes the core argument, evidence and conclusions.\n",
"\n", "\n",
"This will get you comfortable with a multi-tool workflow that can choose from multiple services, and where some of the data from the first function is persisted to be used by the second." "This will get you comfortable with a multi-function workflow that can choose from multiple services, and where some of the data from the first function is persisted to be used by the second."
] ]
}, },
{ {