Hello and welcome! My name is Doug Fink, and I will be your host as we explore how to call functions with chat models. This new feature, released by OpenAI, allows us to connect GPT’s capabilities with external tools and APIs. In this article, I will show you how to use this feature to make function calls and demonstrate its benefits.
Before we dive in, let me introduce myself. I am Doug Fink, a Powershell MVP for Microsoft with 15 years of experience. I am excited to explore this new feature with you today.
To begin, let’s understand what chat models are and how they work. OpenAI provides different models, such as GPT-3 and DPT3-3540, each with its own characteristics. Function calling is a new way to connect GPT’s capabilities with external tools and APIs. It allows us to work with GPT and leverage its functionality to interact with various APIs, whether internal or external.
Function calling offers several benefits. It enhances code organization, expands AI’s functionality range, and provides performance optimizations. By using specialized functions, we can improve efficiency and simplify code maintenance. Additionally, function calling enables dynamic real-time dialogues and facilitates updates without disrupting the system.
To demonstrate how function calling works, I have created a Powershell function called ‘Get Current Weather.’ This function retrieves the current weather information for a specified location. You can pass parameters such as the location and unit (Celsius or Fahrenheit) to customize the weather data you receive.
To use this function, you need to set up the necessary environment. You can find the complete code and instructions in the provided URL. Once you have the environment set up and the API key, you can execute the code and retrieve weather information for any location.
Now, let’s see how we can interact with the chat models. I have created a function called ‘New Chat Message’ that allows us to send messages to the chat model. By passing the desired question or prompt, we can receive responses from the model.
In the example, I asked the chat model, ‘What is the weather like today in Greenland?’ The chat model responded with a function call to ‘Get Current Weather’ and provided the necessary arguments, such as the location and unit. By executing the function call, we can retrieve the weather information for Greenland in Celsius.
You can also interact with the chat model by asking questions like, ‘What is the weather like today in New York City?’ The chat model will generate a function call with the appropriate arguments, allowing us to retrieve the weather information for New York City in either Celsius or Fahrenheit.
In conclusion, calling functions with chat models is a powerful feature that enhances the capabilities of GPT and allows us to integrate external tools and APIs seamlessly. By leveraging this feature, we can create dynamic and interactive applications that provide real-time information and perform various tasks.
Thank you for joining me in this exploration of calling functions with chat models. If you found this article helpful, please subscribe to my channel for more informative content on Powershell, OpenAI, and other technology topics. Have a great day!