
Openai’s “function call” could be the most groundbreaking feature under the most groundbreaking feature released by any software company.
Functions allow you Convert unstructured data into structured data. This may sound like groundbreaking everything, but considering that there is 90% of data processing and data entry jobs around the world for this exact reason, it was rather unnoticed. It is a function.
Have you ever found yourself? Things gginging GPT (3.5 or 4) spit out the answer you want, and else absolutely nothing? “It’s true, here’s you…” or no other useless fluff surrounding the core answer. The GPT function is the solution you are looking for.
How is the feature intended to work?
Openai documentation on feature calls is very limited. You’ll find yourself digging into the developer forum for examples of how to use them. I’ve digged around the forum for you, and many examples are approaching.
This is one of the only examples you can find in the documentation.
functions = [
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters":
"type": "object",
"properties":
"location":
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
,
"unit": "type": "string", "enum": ["celsius", "fahrenheit"],
,
"required": ["location"],
,
]
Function definitions are in rigid JSON format that define function names, descriptions, and parameters. In this case, this feature is intended to get the current weather. Obviously, GPT cannot call this real API (because it does not exist), but using this structured response allows you to hypothetically connect the real API.
However, at high levels, the function provides two-layer inference.
Select the function itself:
You may notice that functions are passed as arrays to OpenAI API calls. The reason for providing a name and description for each function is that GPT can determine what to use based on a particular prompt. Providing multiple features in an API call is like giving GPT a Swiss Army knife and asking them to cut a piece of wood in half. Even if you have a pair of pliers, scissors and knife, you know you need to use a saw!
Function definitions contribute to token counting. Passing hundreds of features not only makes up a large part of the token limit, but also reduces response quality. I often don’t use this feature and just pass one function that forces me to use. However, I’m very happy that it’s a specific use case.
Select the parameter value based on the prompt.
This is, in my opinion, true magic. GPT is amazing to be able to select tools in the toolkit and is undoubtedly the focus of feature announcements, but I think this applies to more use cases.
You can imagine a function like passing a gpt.. It uses its inference, context of the situation, and field name/description to determine how each field is filled in. Designing forms and additional information you pass is where you can become creative.
One of the most common things I use works to extract certain values from a large amount of text. The sender’s address from the email, the founder’s name of the blog post, and the phone number of the landing page.
I like to imagine LLM burning haystacks and only leaving the needles behind, and looking for needles.
Use Case: Handles thousands of contest submissions
We have built automation that has repeated submissions of thousands of contests. Before I saved these to Google Sheets, I wanted to extract the emails associated with the submission. Here is the function call I used to extract their emails.
"name":"update_email",
"description":"Updates email based on the content of their submission.",
"parameters":
"type":"object",
"properties":
"email":
"type":"string",
"description":"The email provided in the submission"
,
"required":[
"email"
]
Unstructured data allocation scores based on dynamic natural language criteria are a great use case for functionality. You can earn comments during sentiment analysis. Essays based on custom grading rubrics are risk loan applications based on key factors. The most recent use case I applied scoring was a 0-100 sales lead score based on its feasibility.
Use Case: Scoring Sales Lead
A few months ago, I had hundreds of future leads in one Google Sheet and wanted to tackle from the most important to the most important. Each lead contained information such as the size of the company, contact name, location, industry, and more.
I used the following function to score each lead from 0-100 based on my needs and sort them from the best to the worst.
"name":"update_sales_lead_value_score",
"description":"Updates the score of a sales lead and provides a justification",
"parameters":
"type":"object",
"properties":
"sales_lead_value_score":
"type":"number",
"description":"An integer value ranging from 0 to 100 that represents the quality of a sales lead based on these criteria. 100 is a perfect lead, 0 is terrible. Ideal Lead Criteria:n- Medium sized companies (300-500 employees is the best range)n- Companies in primary resource heavy industries are best, ex. manufacturing, agriculture, etc. (this is the most important criteria)n- The higher up the contact position, the better. VP or Executive level is preferred."
,
"score_justification":
"type":"string",
"description":"A clear and conscise justification for the score provided based on the custom criteria"
,
"required":[
"sales_lead_value_score",
"score_justification"
]
Define a custom bucket, consider each data that gave it to the GPT and put it in the correct bucket. This can be used for individual scoring tasks such as labeling tasks such as selecting categories for YouTube videos, or assigning letter grades to homework assignments.
Use Case: Labeling News Articles.
A very common first step in a data processing workflow is to separate incoming data into different streams. The recent automation I built did exactly this with news articles that were scrapped from the web. I wanted to sort them based on the topics in the article and again include justification for the decision. Here is the function I used:
"name":"categorize",
"description":"Categorize the input data into user defined buckets.",
"parameters":
"type":"object",
"properties":
"category":
"type":"string",
"enum":[
"US Politics",
"Pandemic",
"Economy",
"Pop culture",
"Other"
],
"description":"US Politics: Related to US politics or US politicians, Pandemic: Related to the Coronavirus Pandemix, Economy: Related to the economy of a specific country or the world. , Pop culture: Related to pop culture, celebrity media or entertainment., Other: Doesn't fit in any of the defined categories. "
,
"justification":
"type":"string",
"description":"A short justification explaining why the input data was categorized into the selected category."
,
"required":[
"category",
"justification"
]
Often, when processing data, I want to give GPT many possible options and choose the best option based on my needs. I only want the value it has chosen, the surrounding fluff and additional thoughts. The feature is perfect for this.
Use Case: Find the “Most Interesting AI News Stories” from Hacker News
Here I wrote another media article on how I automate my entire Twitter account with GPT. Part of that process involves selecting the most relevant post from the Hacker News front page. This post selection step takes advantage of features!
To summarise the functional portion of your use case, we ask GPT to rub the first n pages of hacker news and select the posts that are most relevant to “AI News or Technology News.” GPT returns only the selected headings and links via the function, allowing you to rub that website and generate tweets from it.
Pass a user-defined query as part of the message and use the following function definition:
"name":"find_best_post",
"description":"Determine the best post that most closely reflects the query.",
"parameters":
"type":"object",
"properties":
"best_post_title":
"type":"string",
"description":"The title of the post that most closely reflects the query, stated exactly as it appears in the list of titles."
,
"required":[
"best_post_title"
]
Filtering is a subset of classifications that classify items as true or false based on their natural language state. Conditions like “IS Spanish” can exclude all Spanish comments, articles, etc. Immediately after using simple functions and conditional statements.
Use Case: Submitting a Filtering Contest
The same automation mentioned in the “Data Extraction” section used AI-driven filtering to weed contest submissions that did not meet the criteria for transaction violations. Things like “You need to use TypeScript” were absolutely essential for the coding contest at hand. I used the function to exclude submissions and trim the total set that handled 90%. This is the function definition used.
"name":"apply_condition",
"description":"Used to decide whether the input meets the user provided condition.",
"parameters":
"type":"object",
"properties":
"decision":
"type":"string",
"enum":[
"True",
"False"
],
"description":"True if the input meets this condition 'Does submission meet the ALL these requirements (uses typescript, uses tailwindcss, functional demo)', False otherwise."
,
"required":[
"decision"
]
If you’re interested in why I love the features so much, or what I’ve built with them, you should check out AgentHub!
AgentHub is Y Combinator Support Startup It was co-founded to allow AI to automate repetitive or complex workflows via a simple drag-and-drop no-code platform.
“Imagine Zapier. – yourself
Automation is built on individual nodes called “operators” and is linked to create power AI pipelines. There is a catalog of AI electric operators that take advantage of functionality under the hood.
Check out these templates to see examples of Agenthub feature use cases: scoring, classification, option selection,
If you want Building AgeentHub to be available live! We are extremely active in discordant communities and are happy to help you build automation when needed.
Feel free to follow me Official Agent Hub Twitter For updates and For AI-related content.