Intelligent Controller for Your Dumb Functions: OpenAI's New Function Calling Makes Everything Easier
Until recently, the secret sauce behind the choice of plugins in these systems has been a closely guarded secret.
Only those fortunate enough to have access to OpenAI’s Plugins could gain a glimpse. Anyone who’s used OpenAI endpoints like chat completions quickly realizes that freeform text isn’t the most efficient way to communicate with computers.
The dread of writing the following is gone.
Use the provided context delimited by triple quotes to answer question. If the answer cannot be found in the context, write “Sorry, I could not find an answer”. Provide answer in JSON format “{answer:”Your answer”}
OpenAI is yet again levelling the playing field.
Function calling now allows us to communicate using the?JSON format, creating a bridge between human language and machine capabilities.
Forget the whole concept of control flow.
Who needs IF or switch statements anymore?
You can now outsource intelligence to the AI, allowing it to determine what functions to run and when.
Say hello to the Intelligence Controller.
This update will have a significant impact on the following areas:
There are definitely more things that I cannot think of now
1) Enhanced Chatbot Capabilities
As chatbots become more prevalent in customer service, the ability for these bots to call functions based on natural language inputs could significantly improve their efficiency and user experience.
In their example, they show how easy is to convert natural language questions into a function call.
What’s the weather in London?
translates to:
get_weather(location="London")
How cool is that? Chat completion will be now able to pick correct functions and pass the correct params from the text.
Let’s look at a couple of business use cases.
Accounting Scenario
An accountant could ask an internal chatbot:
Can you fetch all the invoiced orders from Xero for the last quarter?
The chatbot, leveraging the function calling capability, could interpret this request, convert it to a function call like
get_invoiced_orders(platform: 'Xero', period: 'last_quarter')
This could retrieve the necessary data, and then present it in a user-friendly format to the accountant. Or send it to her email in PDF automatically putting CEO in CC.
Sales Scenario
A sales rep might want to focus on customers who haven’t placed any orders in the last three months. They could ask their Pipedrive-integrated chatbot:
“Show me all customers who haven’t placed an order in the last three months.”
Who needs to create another filter that will clog the UI in HubSpot when you can just ask?
The chatbot could translate this to a function call to query the CRM for the relevant data, and then display a list of these customers to the sales rep.
get_inactive_customers(platform: 'Pipedrive', period: '3_months')
It can come in handy for preparing for monthly sales meetings in a rush.
领英推荐
Marketing Scenario
A marketer could ask their chatbot:
“Can you compile a list of readers who clicked on the CTA in the last two newsletters?”
The chatbot, using function calls, could interpret this request and convert it to a function call. The function could retrieve the data from the newsletter tool, compile the list, and then provide it to the marketer.
get_engaged_readers(source: 'newsletter', action: 'cta_click', count: 'last_2')
Saving your ass in a pinch by providing highly sophisticated graphs to show off at your marketing meeting.
2) Natural Language Interface for Databases
Imagine querying your business database just by asking a question in plain English. Function calling enables this by converting natural language into SQL queries. This could bring business intelligence capabilities to non-technical personnel, opening up data-driven insights to a wider array of people within an organization.
Additionally, when function calling is integrated with a chatbot, it creates an incredibly potent combination. Users can engage in a dialogue with their structured database as if it were a conversational partner. There’s no need for them to comprehend SQL or wrestle with join operations to extract data. Instead, they can access and query their data as easily as sending a text message — the chatbot and function calling do the heavy lifting, making database interaction more accessible and intuitive than ever before.
Healthcare Data
A healthcare professional could query a medical database, “How many patients over the age of 60 have been diagnosed with the condition “broken_rib” (yikes ??) in the past year?” The chatbot, using function calls, would process this natural language input into a SQL query to extract the necessary information.
SELECT COUNT(DISTINCT patients.patient_id)
FROM patients
JOIN diagnoses
ON patients.patient_id = diagnoses.patient_id
WHERE TIMESTAMPDIFF(YEAR, patients.birthdate, CURDATE()) > 60
AND diagnoses.condition = 'broken_rib'
AND YEAR(diagnoses.diagnosis_date) = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 YEAR));
No need to rely on and beg your “more technical” colleague to provide the data export.
3) Efficient Data Extraction
Who doesn’t hate finding elusive CSS selectors, or worse XPath to extract information from a web page?
The ability to define functions to extract structured data from the text will streamline data gathering and processing.
Scraping
With function calling, you could define functions that intelligently pull out information from product listings like product names, prices, and reviews from the raw data.
No information is safe!
Resume Screening
HR departments and recruitment agencies can use structured data extraction to pull out relevant information from CVs and resumes, such as candidate names, contact information, education history, and skills. This can significantly speed up the initial screening process.
The options are limitless really. If there is an annoying task that requires menial computer work there is a good chance that this would help resolve it.
4) Streamlined Development Processes
Perhaps not the most sexy-sounding benefit but it makes things a lot easier for developers.
All ambiguity with prompting is eliminated.
There is no worse feeling than you finally getting correct JSON responses before doing the final test and seeing a lovely printed-out response in a poem form followed by an unhandled exception.
Devs can be now sure that the response will follow a predetermined format thus eliminating any kind of unexpected errors.
Traditional methods of getting a JSON response, even when following best practices from the OpenAI documentation, can sometimes fall short. This might force developers to use workarounds or “hacky” solutions, such as regex matching, to retrieve the data they need. This can add extra layers of complexity and uncertainty to the development process, potentially causing delays and lowering productivity.
In conclusion, we are one step closer to reliving the script of Eagle Eye (2008).
My agency, we hate copy pasting , specializes in integrating AI into real businesses to optimize workflows. We offer comprehensive support, from conceptualization and implementation to maintenance of AI-based solutions. You can explore our work?here?or reach out to me directly at?[email protected].
Thanks for reading!
P.S. Read more about Function Calling from the official press release here.
NB: The function calling functionality is the real game-changer here. It’s available in specific static models, so it’s important to use the June 13th version.