The video critiques the term “function calling,” arguing that it misleadingly suggests the model can directly call functions, when in reality, it’s the user’s program that does so based on the model’s output, which must be parsed. The presenter compares implementations in OpenAI and Ollama, highlighting the latter’s more descriptive “format JSON” approach, while emphasizing the importance of providing schemas to improve output consistency and reliability.
The video begins with a critique of the term “function calling,” which the presenter believes is misleading and poorly named for the feature it describes. The presenter argues that the name implies the model can call functions, when in reality, it is the user’s program that calls functions based on the model’s output. The process involves the model outputting a string that must be parsed into a structured format, which then allows the user to call a function. The presenter emphasizes that while the feature is useful, a more accurate name would better reflect its functionality.
Next, the video delves into how function calling is implemented in the OpenAI API. The presenter explains the process of informing OpenAI about the functions through a schema, which outlines the expected output format. The example demonstrates how to use the chat API to ask the model a question, parse the response into JSON, and then call the desired function based on that structured data. The presenter showcases this process with a straightforward question about the capital of Germany, highlighting the simplicity of the API’s functionality.
The discussion then shifts to the alternative approach in Ollama, where the feature is referred to as “format JSON,” which the presenter finds more descriptive. The video illustrates how to achieve similar functionality using Python, demonstrating the steps required to send a request to the Ollama chat endpoint. The presenter walks through creating a payload, handling the response, and iterating over the streaming data to extract meaningful information, emphasizing the ease of use compared to OpenAI’s method.
To enhance the interaction with the model, the presenter introduces the idea of adding a system prompt that instructs the model to respond in JSON format. This adjustment improves the consistency of the output, but the presenter notes that variations in key names can still occur. To further refine the interaction, the presenter advises providing a schema to the model, which helps ensure that the output aligns with the expected format. The video demonstrates how to leverage this schema effectively to retrieve latitude and longitude coordinates.
Finally, the presenter reflects on the reliability of the results obtained from both the OpenAI and Ollama approaches, noting that while function calling (or format JSON) is a valuable feature, it may still yield inconsistent results, especially when querying geographical data. The video concludes by inviting viewers to share their thoughts on function calling and its utility, along with suggestions for future content. The presenter expresses gratitude for the engagement and interest shown by the audience, emphasizing the importance of their feedback in shaping upcoming videos.