PageSourceSearch

https://www.promptingguide.ai/_next/static/chunks/pages/applications/function_calling.en-29199eea4f7bae7c.js

js promptingguide.ai collected 2026-09-24 08:28:08 UTC 50,056 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[43832],{98295:function(e,n,i){(window.__NEXT_P=window.__NEXT_P||[]).push(["/applications/function_calling.en",function(){return i(87515)}])},87515:function(e,n,i){"use strict";i.r(n),i.d(n,{__toc:function(){return d}});var t=i(52676),a=i(45118),o=i(23742),s=i(40241);i(21729),i(29814);var l=i(41619),r=i(70754),c=i(82658);let d=[{depth:2,value:"Getting Started with Function Calling",id:"getting-started-with-function-calling"},{depth:2,value:"Function Calling with GPT-4",id:"function-calling-with-gpt-4"},{depth:2,value:"Notebooks",id:"notebooks"},{depth:2,value:"Function Calling with Open-Source LLMs",id:"function-calling-with-open-source-llms"},{depth:2,value:"Function Calling Use Cases",id:"function-calling-use-cases"},{depth:2,value:"References",id:"references"}];function _createMdxContent(e){let n=Object.assign({h1:"h1",h2:"h2",p:"p",ul:"ul",li:"li",code:"code",pre:"pre",span:"span",a:"a",strong:"strong"},(0,l.a)(),e.components);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{children:"Function Calling with LLMs"}),"\n","\n",(0,t.jsx)(n.h2,{id:"getting-started-with-function-calling",children:"Getting Started with Function Calling"}),"\n",(0,t.jsx)("iframe",{width:"100%",height:"415px",src:"https://www.youtube.com/embed/p0I-hwZSWMs?si=tQgi-LiHe6Oj_rzm",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}),"\n",(0,t.jsx)(n.p,{children:"Function calling is the ability to reliably connect LLMs to external tools to enable effective tool usage and interaction with external APIs."}),"\n",(0,t.jsx)(n.p,{children:"LLMs like GPT-4 and GPT-3.5 have been fine-tuned to detect when a function needs to be called and then output JSON containing arguments to call the function. The functions that are being called by function calling will act as tools in your AI application and you can define more than one in a single request."}),"\n",(0,t.jsx)(n.p,{children:"Function calling is an important ability for building LLM-powered chatbots or agents that need to retrieve context for an LLM or interact with external tools by converting natural language into API calls."}),"\n",(0,t.jsx)(n.p,{children:"Functional calling enables developers to create:"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:['conversational agents that can efficiently use external tools to answer questions. For example, the query "What is the weather like in Belize?" will be converted to a function call such as ',(0,t.jsx)(n.code,{children:"get_current_weather(location: string, unit: 'celsius' | 'fahrenheit')"})]}),"\n",(0,t.jsx)(n.li,{children:"LLM-powered solutions for extracting and tagging data (e.g., extracting people names from a Wikipedia article)"}),"\n",(0,t.jsx)(n.li,{children:"applications that can help convert natural language to API calls or valid database queries"}),"\n",(0,t.jsx)(n.li,{children:"conversational knowledge retrieval engines that interact with a knowledge base"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"In this guide, we demonstrate how to prompt models like GPT-4 and open-source models to perform function calling for different use cases."}),"\n",(0,t.jsx)(n.h2,{id:"function-calling-with-gpt-4",children:"Function Calling with GPT-4"}),"\n",(0,t.jsx)(n.p,{children:"As a basic example, let's say we asked the model to check the weather in a given location."}),"\n",(0,t.jsx)(n.p,{children:"The LLM alone would not be able to respond to this request because it has been trained on a dataset with a cutoff point. The way to solve this is to combine the LLM with an external tool. You can leverage the function calling capabilities of the model to determine an external function to call along with its arguments and then have it return a final response. Below is a simple example of how you can achieve this using the OpenAI APIs."}),"\n",(0,t.jsx)(n.p,{children:"Let's say a user is asking the following question to the model:"}),"\n",(0,t.jsx)(n.pre,{"data-language":"text","data-theme":"default",children:(0,t.jsx)(n.code,{"data-language":"text","data-theme":"default",children:(0,t.jsx)(n.span,{className:"line",children:(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"What is the weather like in London?"})})})}),"\n",(0,t.jsx)(n.p,{children:"To handle this request using function calling, the first step is to define a weather function or set of functions that you will be passing as part of the OpenAI API request:"}),"\n",(0,t.jsx)(n.pre,{"data-language":"python","data-theme":"default",children:(0,t.jsxs)(n.code,{"data-language":"python","data-theme":"default",children:[(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"tools "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ["})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"{"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"        "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"type"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"function"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"        "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"function"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"{"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"            "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"name"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"get_current_weather"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"            "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"description"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"Get the current weather in a given location"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"            "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"parameters"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"{"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"type"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"object"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"properties"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"{"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                    "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"location"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"{"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                        "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"type"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"string"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                        "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"description"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"The city and state, e.g. San Francisco, CA"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                    "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"},"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                    "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"unit"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"{"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                        "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"type"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"string"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                        "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"enum"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ["}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"celsius"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"}
1,children:'"fahrenheit"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"]"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"},"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"},"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"                "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"required"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ["}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"location"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"]"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"            "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"},"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"        "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"},"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"   "})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"}"})]}),"\n",(0,t.jsx)(n.span,{className:"line",children:(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"]"})})]})}),"\n",(0,t.jsxs)(n.p,{children:["The ",(0,t.jsx)(n.code,{children:"get_current_weather"})," function returns the current weather in a given location. When you pass this function definition as part of the request, it doesn't actually executes a function, it just returns a JSON object containing the arguments needed to call the function. Here are some code snippets of how to achieve this."]}),"\n",(0,t.jsx)(n.p,{children:"You can define a completion function as follows:"}),"\n",(0,t.jsx)(n.pre,{"data-language":"python","data-theme":"default",children:(0,t.jsxs)(n.code,{"data-language":"python","data-theme":"default",children:[(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"def"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"get_completion"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-parameter)"},children:"messages"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-parameter)"},children:"model"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"gpt-3.5-turbo-1106"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-parameter)"},children:"temperature"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"0"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-parameter)"},children:"max_tokens"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"300"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-parameter)"},children:"tools"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"None"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"):"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    response "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" openai"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"chat"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"completions"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"create"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"("})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"        model"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"model,"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"        messages"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"messages,"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"        temperature"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"temperature,"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"        max_tokens"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"max_tokens,"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"        tools"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"tools"})]}),"\n",(0,t.jsx)(n.span,{className:"line",children:(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"    )"})}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"return"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" response"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"."}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"choices"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"["}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"0"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"]."}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"message"})]})]})}),"\n",(0,t.jsx)(n.p,{children:"This is how you can compose the user question:"}),"\n",(0,t.jsx)(n.pre,{"data-language":"python","data-theme":"default",children:(0,t.jsxs)(n.code,{"data-language":"python","data-theme":"default",children:[(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"messages "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ["})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"{"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"        "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"role"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"user"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"        "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"content"'}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"What is the weather like in London?"'})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"}"})]}),"\n",(0,t.jsx)(n.span,{className:"line",children:(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"]"})})]})}),"\n",(0,t.jsxs)(n.p,{children:["Finally, you can call the  ",(0,t.jsx)(n.code,{children:"get_completion"})," above and passing both the ",(0,t.jsx)(n.code,{children:"messages"})," and ",(0,t.jsx)(n.code,{children:"tools"}),":"]}),"\n",(0,t.jsx)(n.pre,{"data-language":"python","data-theme":"default",children:(0,t.jsx)(n.code,{"data-language":"python","data-theme":"default",children:(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"response "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"get_completion"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"(messages, tools"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"tools)"})]})})}),"\n",(0,t.jsxs)(n.p,{children:["The ",(0,t.jsx)(n.code,{children:"response"}
1)," object contains the following:"]}),"\n",(0,t.jsx)(n.pre,{"data-language":"python","data-theme":"default",children:(0,t.jsx)(n.code,{"data-language":"python","data-theme":"default",children:(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"ChatCompletionMessage"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"(content"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"None"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:", role"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'assistant'"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:", function_call"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"None"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:", tool_calls"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"["}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"ChatCompletionMessageToolCall"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"(id"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'...'"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:", function"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"Function"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"(arguments"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'\'{"location":"London","unit":"celsius"}\''}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:", name"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'get_current_weather'"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:"), type"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'function'"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:")])"})]})})}),"\n",(0,t.jsxs)(n.p,{children:["In particular, the ",(0,t.jsx)(n.code,{children:"arguments"})," object contains the important arguments extracted by the model and that will be needed to complete the request."]}),"\n",(0,t.jsx)(n.p,{children:"You can then choose to call an external weather API for the actual weather. Once you have the weather information available you can pass it back to the model to summarize a final response given the original user question."}),"\n",(0,t.jsx)(n.h2,{id:"notebooks",children:"Notebooks"}),"\n",(0,t.jsx)(r.UW,{type:"info",emoji:"\uD83C\uDF93",children:(0,t.jsxs)(n.p,{children:["Learn more about function calling in our new AI courses. ",(0,t.jsx)(n.a,{href:"https://academy.dair.ai/",children:"Join now!"}),"\nUse code PROMPTING20 to get an extra 20% off."]})}),"\n",(0,t.jsx)(n.p,{children:"Here is a notebook with a simple example that demonstrates how to use function calling with the OpenAI APIs:"}),"\n",(0,t.jsx)(r.oy,{children:(0,t.jsx)(r.Zb,{icon:(0,t.jsx)(c.dN,{}),title:"Function Calling with OpenAI APIs",href:"https://github.com/dair-ai/Prompt-Engineering-Guide/blob/main/notebooks/pe-function-calling.ipynb"})}),"\n",(0,t.jsx)(n.h2,{id:"function-calling-with-open-source-llms",children:"Function Calling with Open-Source LLMs"}),"\n",(0,t.jsx)(n.p,{children:"More notes on function calling with open-source LLMs coming soon."}),"\n",(0,t.jsx)(n.h2,{id:"function-calling-use-cases",children:"Function Calling Use Cases"}),"\n",(0,t.jsx)(n.p,{children:"Below is a list of use cases that can benefit from the function calling capability of LLMs:"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Conversational Agents"}),": Function calling can be used to create complex conversational agents or chatbots that answer complex questions by calling external APIs or external knowledge base and providing more relevant and useful responses."]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Natural Language Understanding"}),": It can convert natural language into structured JSON data, extract structured data from text, and perform tasks like named entity recognition, sentiment analysis, and keyword extraction."]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Math Problem Solving"}),": Function calling can be used to define custom functions to solve complex mathematical problems that require multiple steps and different types of advanced calculations."]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"API Integration"}
1),": It can be used to effectively integrate LLMs with external APIs to fetch data or perform actions based on the input. This could be helpful to build either a QA system or creative assistant. In general, function calling can convert natural language into valid API calls."]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Information Extraction"}),": Function calling be effectively used to extract specific information from a given input, such as retrieving relevant news stories or references from an article."]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"references",children:"References"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://blog.fireworks.ai/fireworks-raises-the-quality-bar-with-function-calling-model-and-api-release-e7f49d1e98e9",children:"Fireworks Raises the Quality Bar with Function Calling Model and API Release"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://blog.langchain.dev/benchmarking-agent-tool-use/",children:"Benchmarking Agent Tool Use and Function Calling"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://ai.google.dev/docs/function_calling",children:"Function Calling"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://python.langchain.com/docs/use_cases/apis",children:"Interacting with APIs"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://platform.openai.com/docs/guides/function-calling",children:"OpenAI's Function Calling"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://cookbook.openai.com/examples/how_to_call_functions_with_chat_models",children:"How to call functions with chat models"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://minimaxir.com/2023/12/chatgpt-structured-data/",children:"Pushing ChatGPT's Structured Data Support To Its Limits"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://github.com/svpino/openai-function-calling/blob/main/sample.ipynb",children:"Math Problem Solving with Function Calling"})}),"\n"]})]})}let h={MDXContent:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:n}=Object.assign({},(0,l.a)(),e.components);return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(_createMdxContent,{...e})}):_createMdxContent(e)},pageOpts:{filePath:"pages/applications/function_calling.en.mdx",route:"/applications/function_calling",timestamp:1769980197e3,pageMap:[{kind:"Meta",locale:"en",data:{index:"Prompt Engineering",introduction:"Introduction",techniques:"Prompting Techniques",agents:"AI Agents",guides:"Guides",applications:"Applications",prompts:"Prompt Hub",models:"Models",risks:"Risks & Misuses",research:"LLM Research Findings",papers:"Papers",tools:"Tools",notebooks:"Notebooks",datasets:"Datasets",readings:"Additional Readings",courses:{title:"\uD83C\uDF93 Courses",type:"menu",items:{"intro-prompt-engineering":{title:"Intro to Prompt Engineering",href:"https://academy.dair.ai/courses/introduction-prompt-engineering"},"advanced-prompt-engineering":{title:"Advanced Prompt Engineering",href:"https://academy.dair.ai/courses/advanced-prompt-engineering"},"intro-ai-agents":{title:"Intro to AI Agents",href:"https://academy.dair.ai/courses/introduction-ai-agents"},"agents-with-n8n":{title:"Building Effective AI Agents with n8n",href:"https://academy.dair.ai/courses/building-effective-ai-agents"},"rag-systems":{title:"Build RAG Systems",href:"https://academy.dair.ai/courses/introduction-to-rag"},"advanced-agents":{title:"Building Advanced AI Agents",href:"https://academy.dair.ai/courses/advanced-ai-agents"},"all-courses":{title:"See all →",href:"https://academy.dair.ai/courses"}}},about:{title:"About",type:"page"},services:"Services"}},{kind:"MdxPage",name:"about",route:"/about",locale:"en"},{kind:"Folder",name:"agents",route:"/agents",children:[{kind:"Meta",locale:"en",data:{introduction:"Introduction to Agents",components:"Agent Components","ai-workflows-vs-ai-agents":"AI Workflows vs AI Agents","context-engineering":"Context Engineering for AI Agents","context-engineering-deep-dive":"Context Engineering Deep Dive","function-calling":"Function Calling","deep-agents":"Deep Agents"}},{kind:"MdxPage",name:"ai-workflows-vs-ai-agents",route:"/agents/ai-workflows-vs-ai-agents",locale:"en"},{kind:"MdxPage",name:"components",route:"/agents/components",locale:"en"},{kind:"MdxPage",name:"context-engineering-deep-dive",route:"/agents/context-engineering-deep-dive",locale:"en"},{kind:"MdxPage",name:"context-engineering",route:"/agents/context-engineering",locale:"en"},{kind:"MdxPage",name:"deep-agents",route:"/agents/deep-agents",locale:"en"},{kind:"MdxPage",name:"function-calling",route:"/agents/function-calling",locale:"en"},{kind:"MdxPage",name:"introduction",route:"/agents/introduction",locale:"en"}]},{kind:"MdxPage",name:"agents",route:"/agents",locale:"en"},{kind:"Folder",name:"applications",route:"/applications",children:[{kind:"Meta",locale:"en",data:{"finetuning-gpt4o":"Fine-tuning GPT-4o",function_calling:"Function Calling","context-caching":"Context Caching with LLMs",generating:"Generating Data",synthetic_rag:"Generating Synthetic Dataset for RAG",generating_textbooks:"Tackling Generated Datasets Diversity",coding:"Generating Code",workplace_casestudy:"Graduate Job Classification Case Study",pf:"Prompt Function"}},{kind:"MdxPage",name:"coding",route:"/applications/coding",locale:"en"},{kind:"MdxPage",name:"context-caching",route:"/applications/context-caching",locale:"en"},{kind:"MdxPage",name:"finetuning-gpt4o",route:"/applications/finetuning-gpt4o",locale:"en"},{kind:"MdxPage",name:"function_calling",route:"/applications/function_calling",locale:"en"},{kind:"MdxPage",name:"generating",route:"/applications/generating",locale:"en"},{kind:"MdxPage",name:"generating_textbooks",route:"/applications/generating_textbooks",locale:"en"},{kind:"MdxPage",name:"pf",route:"/applications/pf",locale:"en"},{kind:"MdxPage",name:"synthetic_rag",route:"/applications/synthetic_rag",locale:"en"},{kind:"MdxPage",name:"workplace_casestudy",route:"/applications/workplace_casestudy",locale:"en"}]},{kind:"MdxPage",name:"applications",route:"/applications",locale:"en"},{kind:"MdxPage",name:"courses",route:"/courses",locale:"en"},{kind:"MdxPage",name:"datasets",route:"/datasets",locale:"en"},{kind:"Folder",name:"guides",route:"/guides",children:[{kind:"MdxPage",name:"4o-image-generation",route:"/guides/4o-image-generation",locale:"en"},{kind:"Meta",locale:"en",data:{"optimizing-prompts":"Optimizing Prompts","deep-research":"OpenAI Deep Research","reasoning-llms":"Reasoning LLMs","4o-image-generation":"4o Image Generation","context-engineering-guide":"Context Engineering Guide"}},{kind:"MdxPage",name:"context-engineering-guide",route:"/guides/context-engineering-guide",locale:"en"},{kind:"MdxPage",name:"deep-research",route:"/guides/deep-research",locale:"en"},{kind:"MdxPage",name:"optimizing-prompts",route:"/guides/optimizing-prompts",locale:"en"},{kind:"MdxPage",name:"reasoning-llms",route:"/guides/reasoning-llms",locale:"en"}]},{kind:"MdxPage",name:"index",route:"/",locale:"en"},{kind:"Folder",name:"introduction",route:"/introduction",children:[{kind:"Meta",locale:"en",data:{settings:"LLM 
1Settings",basics:"Basics of Prompting",elements:"Prompt Elements",tips:"General Tips for Designing Prompts",examples:"Examples of Prompts"}},{kind:"MdxPage",name:"basics",route:"/introduction/basics",locale:"en"},{kind:"MdxPage",name:"elements",route:"/introduction/elements",locale:"en"},{kind:"MdxPage",name:"examples",route:"/introduction/examples",locale:"en"},{kind:"MdxPage",name:"settings",route:"/introduction/settings",locale:"en"},{kind:"MdxPage",name:"tips",route:"/introduction/tips",locale:"en"}]},{kind:"MdxPage",name:"introduction",route:"/introduction",locale:"en"},{kind:"Folder",name:"models",route:"/models",children:[{kind:"Meta",locale:"en",data:{chatgpt:"ChatGPT","claude-3":"Claude 3","code-llama":"Code Llama",flan:"Flan",gemini:"Gemini","gemini-advanced":"Gemini Advanced","gemini-pro":"Gemini 1.5 Pro",gemma:"Gemma","gpt-4":"GPT-4","grok-1":"Grok-1","kimi-k2.5":"Kimi K2.5",llama:"LLaMA","llama-3":"Llama 3","mistral-7b":"Mistral 7B","mistral-large":"Mistral Large",mixtral:"Mixtral","mixtral-8x22b":"Mixtral 8x22B",olmo:"OLMo","phi-2":"Phi-2",sora:"Sora",collection:"LLM Collection"}},{kind:"MdxPage",name:"chatgpt",route:"/models/chatgpt",locale:"en"},{kind:"MdxPage",name:"claude-3",route:"/models/claude-3",locale:"en"},{kind:"MdxPage",name:"code-llama",route:"/models/code-llama",locale:"en"},{kind:"MdxPage",name:"collection",route:"/models/collection",locale:"en"},{kind:"MdxPage",name:"flan",route:"/models/flan",locale:"en"},{kind:"MdxPage",name:"gemini-advanced",route:"/models/gemini-advanced",locale:"en"},{kind:"MdxPage",name:"gemini-pro",route:"/models/gemini-pro",locale:"en"},{kind:"MdxPage",name:"gemini",route:"/models/gemini",locale:"en"},{kind:"MdxPage",name:"gemma",route:"/models/gemma",locale:"en"},{kind:"MdxPage",name:"gpt-4",route:"/models/gpt-4",locale:"en"},{kind:"MdxPage",name:"grok-1",route:"/models/grok-1",locale:"en"},{kind:"MdxPage",name:"kimi-k2.5",route:"/models/kimi-k2.5",locale:"en"},{kind:"MdxPage",name:"llama-3",route:"/models/llama-3",locale:"en"},{kind:"MdxPage",name:"llama",route:"/models/llama",locale:"en"},{kind:"MdxPage",name:"mistral-7b",route:"/models/mistral-7b",locale:"en"},{kind:"MdxPage",name:"mistral-large",route:"/models/mistral-large",locale:"en"},{kind:"MdxPage",name:"mixtral-8x22b",route:"/models/mixtral-8x22b",locale:"en"},{kind:"MdxPage",name:"mixtral",route:"/models/mixtral",locale:"en"},{kind:"MdxPage",name:"olmo",route:"/models/olmo",locale:"en"},{kind:"MdxPage",name:"phi-2",route:"/models/phi-2",locale:"en"},{kind:"MdxPage",name:"sora",route:"/models/sora",locale:"en"}]},{kind:"MdxPage",name:"models",route:"/models",locale:"en"},{kind:"MdxPage",name:"notebooks",route:"/notebooks",locale:"en"},{kind:"MdxPage",name:"papers",route:"/papers",locale:"en"},{kind:"Folder",name:"prompts",route:"/prompts",children:[{kind:"Meta",locale:"en",data:{classification:"Classification",coding:"Coding",creativity:"Creativity",evaluation:"Evaluation","information-extraction":"Information Extraction","image-generation":"Image Generation",mathematics:"Mathematics","question-answering":"Question Answering",reasoning:"Reasoning","text-summarization":"Text Summarization",truthfulness:"Truthfulness","adversarial-prompting":"Adversarial Prompting"}},{kind:"Folder",name:"adversarial-prompting",route:"/prompts/adversarial-prompting",children:[{kind:"Meta",locale:"en",data:{"prompt-injection":"Prompt Injection","prompt-leaking":"Prompt Leaking","jailbreaking-llms":"Jailbreaking"}},{kind:"MdxPage",name:"jailbreaking-llms",route:"/prompts/adversarial-prompting/jailbreaking-llms",locale:"en"},{kind:"MdxPage",name:"prompt-injection",route:"/prompts/adversarial-prompting/prompt-injection",locale:"en"},{kind:"MdxPage",name:"prompt-leaking",route:"/prompts/adversarial-prompting/prompt-leaking",locale:"en"}]},{kind:"MdxPage",name:"adversarial-prompting",route:"/prompts/adversarial-prompting",locale:"en"},{kind:"Folder",name:"classification",route:"/prompts/classification",children:[{kind:"Meta",locale:"en",data:{sentiment:"Sentiment Classification","sentiment-fewshot":"Few-Shot Sentiment Classification"}}
1,{kind:"MdxPage",name:"sentiment-fewshot",route:"/prompts/classification/sentiment-fewshot",locale:"en"},{kind:"MdxPage",name:"sentiment",route:"/prompts/classification/sentiment",locale:"en"}]},{kind:"MdxPage",name:"classification",route:"/prompts/classification",locale:"en"},{kind:"Folder",name:"coding",route:"/prompts/coding",children:[{kind:"Meta",locale:"en",data:{"code-snippet":"Generate Code Snippet","mysql-query":"Generate MySQL Query",tikz:"Draw TiKZ Diagram"}},{kind:"MdxPage",name:"code-snippet",route:"/prompts/coding/code-snippet",locale:"en"},{kind:"MdxPage",name:"mysql-query",route:"/prompts/coding/mysql-query",locale:"en"},{kind:"MdxPage",name:"tikz",route:"/prompts/coding/tikz",locale:"en"}]},{kind:"MdxPage",name:"coding",route:"/prompts/coding",locale:"en"},{kind:"Folder",name:"creativity",route:"/prompts/creativity",children:[{kind:"Meta",locale:"en",data:{rhymes:"Rhymes","infinite-primes":"Infinite Primes",interdisciplinary:"Interdisciplinary","new-words":"Inventing New Words"}},{kind:"MdxPage",name:"infinite-primes",route:"/prompts/creativity/infinite-primes",locale:"en"},{kind:"MdxPage",name:"interdisciplinary",route:"/prompts/creativity/interdisciplinary",locale:"en"},{kind:"MdxPage",name:"new-words",route:"/prompts/creativity/new-words",locale:"en"},{kind:"MdxPage",name:"rhymes",route:"/prompts/creativity/rhymes",locale:"en"}]},{kind:"MdxPage",name:"creativity",route:"/prompts/creativity",locale:"en"},{kind:"Folder",name:"evaluation",route:"/prompts/evaluation",children:[{kind:"Meta",locale:"en",data:{"plato-dialogue":"Evaluate Plato's Dialogue"}},{kind:"MdxPage",name:"plato-dialogue",route:"/prompts/evaluation/plato-dialogue",locale:"en"}]},{kind:"MdxPage",name:"evaluation",route:"/prompts/evaluation",locale:"en"},{kind:"Folder",name:"image-generation",route:"/prompts/image-generation",children:[{kind:"Meta",locale:"en",data:{"alphabet-person":"Draw a Person Using Alphabet"}},{kind:"MdxPage",name:"alphabet-person",route:"/prompts/image-generation/alphabet-person",locale:"en"}]},{kind:"MdxPage",name:"image-generation",route:"/prompts/image-generation",locale:"en"},{kind:"Folder",name:"information-extraction",route:"/prompts/information-extraction",children:[{kind:"Meta",locale:"en",data:{"extract-models":"Extract Model Names"}},{kind:"MdxPage",name:"extract-models",route:"/prompts/information-extraction/extract-models",locale:"en"}]},{kind:"MdxPage",name:"information-extraction",route:"/prompts/information-extraction",locale:"en"},{kind:"Folder",name:"mathematics",route:"/prompts/mathematics",children:[{kind:"Meta",locale:"en",data:{"composite-functions":"Evaluating Composite Functions","odd-numbers":"Adding Odd Numbers"}},{kind:"MdxPage",name:"composite-functions",route:"/prompts/mathematics/composite-functions",locale:"en"},{kind:"MdxPage",name:"odd-numbers",route:"/prompts/mathematics/odd-numbers",locale:"en"}]},{kind:"MdxPage",name:"mathematics",route:"/prompts/mathematics",locale:"en"},{kind:"Folder",name:"question-answering",route:"/prompts/question-answering",children:[{kind:"Meta",locale:"en",data:{"closed-domain":"Closed Domain Question Answering","open-domain":"Open Domain Question Answering","science-qa":"Science Question Answering"}},{kind:"MdxPage",name:"closed-domain",route:"/prompts/question-answering/closed-domain",locale:"en"},{kind:"MdxPage",name:"open-domain",route:"/prompts/question-answering/open-domain",locale:"en"},{kind:"MdxPage",name:"science-qa",route:"/prompts/question-answering/science-qa",locale:"en"}]},{kind:"MdxPage",name:"question-answering",route:"/prompts/question-answering",locale:"en"},{kind:"Folder",name:"reasoning",route:"/prompts/reasoning",children:[{kind:"Meta",locale:"en",data:{"indirect-reasoning":"Indirect Reasoning","physical-reasoning":"Physical Reasoning"}},{kind:"MdxPage",name:"indirect-reasoning",route:"/prompts/reasoning/indirect-reasoning",locale:"en"},{kind:"MdxPage",name:"physical-reasoning",route:"/prompts/reasoning/physical-reasoning",locale:"en"}]},{kind:"MdxPage",name:"reasoning",route:"/prompts/reasoning",locale:"en"},{kind:"Folder",name:"text-summarization",route:"/prompts/text-summarization",children:[{kind:"Meta",locale:"en",data:{"explain-concept":"Explain A Concept"}},{kind:"MdxPage",name:"explain-concept",route:"/prompts/text-summarization/explain-concept",locale:"en"}]},{kind:"MdxPage",name:"text-summarization",route:"/prompts/text-summarization",locale:"en"},{kind:"Folder",name:"truthfulness",route:"/prompts/truthfulness",children:[{kind:"Meta",locale:"en",data:{"identify-hallucination":"Hallucination Identification"}},{kind:"MdxPage",name:"identify-hallucination",route:"/prompts/truthfulness/identify-hallucination",locale:"en"}]},{kind:"MdxPage",name:"truthfulness",route:"/prompts/truthfulness",locale:"en"}]},{kind:"MdxPage",name:"prompts",route:"/prompts",locale:"en"},{kind:"MdxPage",name:"readings",route:"/readings",locale:"en"},{kind:"Folder",name:"research",route:"/research",children:[{kind:"Meta",locale:"en",data:{"llm-agents":"LLM Agents",rag:"RAG for LLMs","llm-reasoning":"LLM Reasoning","rag-faithfulness":"RAG Faithfulness","llm-recall":"LLM In-Context Recall",rag_hallucinations:"RAG Reduces Hallucination",synthetic_data:"Synthetic Data",thoughtsculpt:"ThoughtSculpt","infini-attention":"Infini-Attention","guided-cot":"LM-Guided CoT","trustworthiness-in-llms":"Trustworthiness in LLMs","llm-tokenization":"LLM Tokenization",groq:"What is Groq?"}},{kind:"MdxPage",name:"groq",route:"/research/groq",locale:"en"},{kind:"MdxPage",name:"guided-cot",route:"/research/guided-cot",locale:"en"},{kind:"MdxPage",name:"infini-attention",route:"/research/infini-attention",locale:"en"},{kind:"MdxPage",name:"llm-agents",route:"/research/llm-agents",locale:"en"},{kind:"MdxPage",name:"llm-reasoning",route:"/research/llm-reasoning",locale:"en"},{kind:"MdxPage",name:"llm-recall",route:"/research/llm-recall",locale:"en"},{kind:"MdxPage",name:"llm-tokenization",route:"/research/llm-tokenization",locale:"en"},{kind:"MdxPage",name:"rag-faithfulness",route:"/research/rag-faithfulness",locale:"en"},{kind:"MdxPage",name:"rag",route:"/research/rag",locale:"en"},{kind:"MdxPage",name:"rag_hallucinations",route:"/research/rag_hallucinations",locale:"en"},{kind:"MdxPage",name:"synthetic_data",route:"/research/synthetic_data",locale:"en"},{kind:"MdxPage",name:"thoughtsculpt",route:"/research/thoughtsculpt",locale:"en"},{kind:"MdxPage",name:"trustworthiness-in-llms",route:"/research/trustworthiness-in-llms",locale:"en"}]},{kind:"MdxPage",name:"research",route:"/research",locale:"en"},{kind:"Folder",name:"risks",route:"/risks",children:[{kind:"Meta",locale:"en",data:{adversarial:"Adversarial Prompting",factuality:"Factuality",biases:"Biases"}},{kind:"MdxPage",name:"adversarial",route:"/risks/adversarial",locale:"en"},{kind:"MdxPage",name:"biases",route:"/risks/biases",locale:"en"},{kind:"MdxPage",name:"factuality",route:"/risks/factuality",locale:"en"}]},{kind:"MdxPage",name:"risks",route:"/risks",locale:"en"},{kind:"MdxPage",name:"services",route:"/services",locale:"en"},{kind:"Folder",name:"techniques",route:"/techniques",children:[{kind:"Meta",locale:"en",data:{zeroshot:"Zero-shot Prompting",fewshot:"Few-shot Prompting",cot:"Chain-of-Thought Prompting","meta-prompting":"Meta Prompting",consistency:"Self-Consistency",knowledge:"Generate Knowledge Prompting",prompt_chaining:"Prompt Chaining",tot:"Tree of Thoughts",rag:"Retrieval Augmented Generation",art:"Automatic Reasoning and Tool-use",ape:"Automatic Prompt Engineer",activeprompt:"Active-Prompt",dsp:"Directional Stimulus Prompting",pal:"Program-Aided Language Models",react:"ReAct",reflexion:"Reflexion",multimodalcot:"Multimodal CoT",graph:"Graph Prompting"}},{kind:"MdxPage",name:"activeprompt",route:"/techniques/activeprompt",locale:"en"},{kind:"MdxPage",name:"ape",route:"/techniques/ape",locale:"en"},{kind:"MdxPage",name:"art",route:"/techniques/art",locale:"en"},{kind:"MdxPage",name:"consistency",route:"/techniques/consistency",locale:"en"},{kind:"MdxPage",name:"cot",route:"/techniques/cot",locale:"en"},{kind:"MdxPage",name:"dsp",route:"/techniques/dsp",locale:"en"},{kind:"MdxPage",name:"fewshot",route:"/techniques/fewshot",locale:"en"},{kind:"MdxPage",name:"graph",route:"/techniques/graph",locale:"en"},{kind:"MdxPage",name:"knowledge",route:"/techniques/knowledge",locale:"en"},{kind:"MdxPage",name:"meta-prompting",route:"/techniques/meta-prompting",locale:"en"},{kind:"MdxPage",name:"multimodalcot",route:"/techniques/multimodalcot",locale:"en"},{kind:"MdxPage",name:"pal",route:"/techniques/pal",locale:"en"},{kind:"MdxPage",name:"prompt_chaining",route:"/techniques/prompt_chaining",locale:"en"},{kind:"MdxPage",name:"rag",route:"/techniques/rag",locale:"en"},{kind:"MdxPage",name:"react",route:"/techniques/react",locale:"en"},{kind:"MdxPage",name:"reflexion",route:"/techniques/reflexion",locale:"en"},{kind:"MdxPage",name:"tot",route:"/techniques/tot",locale:"en"},{kind:"MdxPage",name:"zeroshot",route:"/techniques/zeroshot",locale:"en"}]},{kind:"MdxPage",name:"techniques",route:"/techniques",locale:"en"},{kind:"MdxPage",name:"tools",route:"/tools",locale:"en"}],flexsearch:{codeblocks:!0},title:"Function Calling with LLMs",headings:d},pageNextRoute:"/applications/function_calling.en",nextraLayout:o.ZP,themeConfig:s.Z};n.default=(0,a.j)(h)}},function(e){e.O(0,[57914,26494,82658,49774,92888,40179],function(){return e(e.s=98295)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.