November 4, 2024
This article originally appeared on LinkedIn.
Title: Using ChatGPT Chat Function Calls from Java
Original Publication Date: July 9, 2023
Using ChatGPT Chat Function Calls from Java
Introduction
As artificial intelligence and chatbots become more popular, it is increasingly important to integrate functions into chat conversations. Functions are small pieces of code that can be reused and embedded into larger programs to perform a specific task. In this blog post, we will discuss how to implement and integrate functions into ChatGPT conversations using JAI, a Java OpenAI API client. This guide will cover how to define a function, handle function callbacks, and mix function results with the content and context returned from the function. We will also provide an example of a weather-related function and its integration into a larger program using a function map.
This developer notebook guides you through implementing and integrating functions into a ChatGPT conversation with JAI, a Java OpenAI API client. It covers everything from defining a function to handling function callbacks and mixing the results with the content and context returned. In addition, the guide includes an example implementation of a weather-related function and its integration into a larger program using a function map.
The latest models (gpt-3.5-turbo-0613 and gpt-4-0613) have been fine-tuned to detect when a function should be called based on the input and to respond with JSON that follows the function signature. However, this power also comes with great responsibility due to potential risks. Users must build in some user confirmation before taking actions on behalf of users that could impact the world (such as sending an email, posting political views online, or buying something).
The notebook begins by explaining how to define a function by creating a dictionary that maps function names to their respective implementations. It then covers how to handle function callbacks, which occur when ChatGPT calls a function and returns a “function call” object containing the function’s name and its arguments. The guide also explains how to call ChatGPT again by appending the function response as a new message and returning the updated chat request to the ChatGPT model.
The model will intelligently select and output a JSON object, called a functionCall
, which contains the names of the functions and the arguments to call those functions. Note that the Chat Completions API does not call the function. Instead, it generates JSON that the user can use to call the function in their code.
Why it is important
This is a powerful concept that allows you to combine up-to-date data from your business domain with ChatGPT.
Function callbacks are used a lot by ChatGPT plugins.
Function calling allows you to add more context to the output from ChatGPT and allows you to get structured data from a model from ChatGPT. This can be used to:
- Create chatbots that answer questions by calling external APIs (e.g., ChatGPT Plugins).
- For example, you can define functions like
send_email(to: string, body: string)
orget_current_weather(location: string, unit: 'celsius' | 'fahrenheit')
.
- For example, you can define functions like
- Convert natural language into function calls.
- For example, you can convert “Who are my top followers on IG?” to
get_top_IG_followers(min_revenue: int, created_before: string, limit: int)
and call an internal function that could hit an internal service.
- For example, you can convert “Who are my top followers on IG?” to
- Extract structured data from text.
- For example, you can define a function called
extract_data(name: string, birthday: string)
orsql_query(query: string)
.
- For example, you can define a function called
Basic steps
The basic steps for function calls are:
- Call the ChatGPT chat with the user query and a set of functions defined in the
functions
parameter. - ChatGPT can choose to call a function. ChatGPT selects this function by returning a
functionCall
from a message (from a choice). ThefunctionCall
arguments are in a JSON object that you must deserialize. - From the
functionCall
, you call a function in your code with the provided arguments and get a function response. - Call ChatGPT again by appending the function response as a new message, and let the model summarize the results back to the user.
Code breakdown
Let’s look at some example code.
Here is the complete code listing of our example
package com.cloudurable.jai.examples;
import com.cloudurable.jai.OpenAIClient;
import com.cloudurable.jai.model.text.completion.chat.ChatRequest;
import com.cloudurable.jai.model.text.completion.chat.ChatResponse;
import com.cloudurable.jai.model.text.completion.chat.Message;
import com.cloudurable.jai.model.text.completion.chat.Role;
import com.cloudurable.jai.model.text.completion.chat.function.*;
import com.cloudurable.jai.util.JsonSerializer;
import io.nats.jparse.node.ObjectNode;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
public class WeatherFunctionCallExample {
private final OpenAIClient client;
/**
* Holds the function mappings.
*/
private final Map<String, Function<ObjectNode, String>> functionMap = new HashMap<>();
public WeatherFunctionCallExample(OpenAIClient client) {
this.client = client;
functionMap.put("get_current_weather", this::getCurrentWeather);
}
/**
* Example dummy function hard-coded to return the same weather for two cities and a default for other cities.
* In production, this could be your backend API or an external API.
* @param objectNode arguments from ChatGPT.
* @return JSON string
*/
public String getCurrentWeather(final ObjectNode objectNode) {
final String location = objectNode.getString("location");
final String unit = Optional.ofNullable(objectNode.get("unit"))
.map(node -> node.asScalar().stringValue()).orElse("fahrenheit");
final JsonSerializer json = new JsonSerializer();
json.startObject();
json.addAttribute("location", location);
json.addAttribute("unit", unit);
switch (location) {
case "Austin, TX":
json.addAttribute("temperature", 92);
json.endObject();
return json.toString();
case "Boston, MA":
json.addAttribute("temperature", 72);
json.endObject();
return json.toString();
default:
json.addAttribute("temperature", 70);
json.endObject();
return json.toString();
}
}
public static void main(final String... args) {
try {
final var client = OpenAIClient.builder().setApiKey(System.getenv("OPENAI_API_KEY")).build();
new WeatherFunctionCallExample(client).runConversation();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void runConversation() {
final var getCurrentWeatherFunc = getFunctionDefinition();
final var message = Message.builder().role(Role.USER)
.content("What's the weather like in Boston in fahrenheit?").build();
final var chatBuilder = ChatRequest.builder()
.model("gpt-3.5-turbo-0613")
.addMessage(message)
.addFunction(getCurrentWeatherFunc)
.functionalCall(ChatRequest.AUTO);
final var chatRequest = chatBuilder.build();
final var chatResponse = client.chat(chatRequest);
chatResponse.getResponse().ifPresent(
response -> handleFunctionCallback(chatBuilder, response));
System.out.println(chatResponse.getStatusCode().orElse(666));
System.out.println(chatResponse.getStatusMessage().orElse(""));
chatResponse.getException().ifPresent(e -> e.printStackTrace());
}
private void handleFunctionCallback(final ChatRequest.Builder chatBuilder, final ChatResponse chatResponse) {
var responseMessage = chatResponse.getChoices().get(0).getMessage();
var functionCall = responseMessage.getFunctionCall();
var functionResponse = getFunctionResponse(functionCall);
chatBuilder.addMessage(Message.builder().name(functionCall.getName()).role(Role.FUNCTION)
.content(functionResponse)
.build());
var response = client.chat(chatBuilder.build());
response.getResponse().ifPresent(chatResponse1 ->
System.out.println(chatResponse1.getChoices().get(0).getMessage().getContent()));
if (response.getStatusMessage().isPresent()) {
System.out.println(response.getStatusMessage().orElse(""));
}
}
private String getFunctionResponse(FunctionalCall functionCall) {
String functionResponse = "";
if (functionCall != null && functionMap.containsKey(functionCall.getName())) {
functionResponse = functionMap
.get(functionCall.getName())
.apply(functionCall.getArguments());
}
return functionResponse;
}
private static FunctionDef getFunctionDefinition() {
return FunctionDef.builder().name("get_current_weather")
.description("Get the current weather in a given location")
.setParameters(
ObjectParameter.objectParamBuilder()
.addParameter(Parameter.builder().name("location")
.description("The city and state, e.g. Austin, TX").build())
.addParameter(
EnumParameter.enumBuilder()
.name("unit").enumValues("celsius", "fahrenheit").build())
.required("location")
.build()
).build();
}
}
If that is unclear, let me break it down based on our defined steps. Then we will show the messages flying across the wire between the client application and ChatGPT.
1.1 Call the ChatGPT chat with the user query
public void runConversation() {
// Call the ChatGPT chat with the user query.
final var message = Message.builder().role(Role.USER)
.content("What's the weather like in Boston in fahrenheit?").build();
final var chatBuilder = ChatRequest.builder()
.model("gpt-3.5-turbo-0613")
.addMessage(message) // user query
// ...
.functionalCall(ChatRequest.AUTO);
}
The runConversation()
method establishes a conversation with the ChatGPT model by providing a user query and configuring the chat request. Next, it prepares the conversation to handle functional calls, allowing the model to invoke specific functions as needed during the conversation.
This runConversation()
method demonstrates how to use the ChatGPT model to run a conversation and make a function call. Let’s break it down step by step:
- The
runConversation()
method is the entry point for executing the conversation. - The code begins by creating a user query message using the
Message.builder()
method. The query is set to “What’s the weather like in Boston in Fahrenheit?” and is assigned the user’s role. - A
ChatRequest
builder object,chatBuilder
, is created to configure the chat request to be sent to the ChatGPT model. - The model for the chat is specified as “gpt-3.5-turbo-0613” using the
model()
method on thechatBuilder
. - The user query message is added to the
chatBuilder
using theaddMessage()
method. This message represents the initial user input for the conversation. - Additional configuration and functionality can be added to the
chatBuilder
, although the snippet provided does not show these details. - Finally, the
functionalCall()
method is called on thechatBuilder
with the parameterChatRequest.AUTO
. This indicates that the ChatGPT model should automatically handle any functional calls made during the conversation.
1.2 And include the set of functions defined in the functions
parameter.
private static FunctionDef getFunctionDefinition() {
return FunctionDef.builder().name("get_current_weather")
.description("Get the current weather in a given location")
.setParameters(
ObjectParameter.objectParamBuilder()
.addParameter(Parameter.builder().name("location")
.description("The city and state, e.g. Austin, TX")
.build())
.addParameter(
EnumParameter.enumBuilder()
.name("unit")
.enumValues("celsius", "fahrenheit")
.build())
.required("location")
.build()
).build();
}
public void runConversation() {
// ...
// And include the set of functions defined in the functions parameter.
final var getCurrentWeatherFunc = getFunctionDefinition(); // defined above
final var chatBuilder = ChatRequest.builder()
.model("gpt-3.5-turbo-0613")
.addMessage(message)
.addFunction(getCurrentWeatherFunc) // function definitions
.functionalCall(ChatRequest.AUTO);
}
The runConversation()
method serves as an entry point for executing a conversation with the ChatGPT model.
- The
runConversation
method creates aMessage
object representing a user query. The query is set to “What’s the weather like in Boston in Fahrenheit?” and is assigned the role of the user. - The code defines a function called
getCurrentWeatherFunc
(not shown in the provided code) and retrieves its definition. - A
ChatRequest
builder object,chatBuilder
, is created. It specifies the model to be used as “gpt-3.5-turbo-0613”. - The user query message is added to the
chatBuilder
using theaddMessage()
method. - The
getCurrentWeatherFunc
function definition is added to thechatBuilder
using theaddFunction()
method. - Finally, the
functionalCall()
method is called on thechatBuilder
with the parameterChatRequest.AUTO
. Specifyingauto
means you want ChatGPT to decide the best method to call based on the message.
1.2 And include the set of functions defined in getFunctionDefinition
breakdown
private static FunctionDef getFunctionDefinition() {
return FunctionDef.builder().name("get_current_weather")
.description("Get the current weather in a given location")
.setParameters(
ObjectParameter.objectParamBuilder()
.addParameter(Parameter.builder().name("location")
.description("The city and state, e.g. Austin, TX")
.build())
.addParameter(
EnumParameter.enumBuilder()
.name("unit")
.enumValues("celsius", "fahrenheit")
.build())
.required("location")
.build()
).build();
}
The method getFunctionDefinition()
returns a FunctionDef
object. This is a function definition for use in the ChatGPT conversation when we pass the menu of functions it can call.
Here’s a breakdown of what the code does:
- The
getFunctionDefinition()
method returns an instance of theFunctionDef
class. - The
FunctionDef
builder is used to construct theFunctionDef
object. - The
name
property of the function is set to “get_current_weather”. This defines the function’s name that can be invoked during the conversation. - The
description
property describes the function, which retrieves the current weather in a given location. - The
setParameters()
method is called to specify the parameters for the function. - Inside
setParameters()
, two parameters are defined:- The first parameter, “location”, represents the city and state for which the weather is requested. It has a description explaining its purpose.
- The second parameter is an
EnumParameter
named “unit”. It represents the unit in which the weather should be returned (either “celsius” or “fahrenheit”). It is defined as an enumeration with two possible values.
- The
required()
method is called on theObjectParameter
to specify that the “location” parameter is required for the function. - The
build()
method is called to finalize the construction of theFunctionDef
object.
This getFunctionDefinition
method defines a function named “get_current_weather” that takes two parameters: “location” and “unit”. It represents a function that retrieves the current weather for a given location in Celsius or Fahrenheit. This function can be used in the ChatGPT conversation to provide weather information based on user queries.
2.1 ChatGPT can choose to call a function.
public void runConversation() {
final var chatRequest = // ...
final var chatResponse = client.chat(chatRequest);
chatResponse.getResponse().ifPresent(
response -> handleFunctionCallback(chatBuilder, response));
// ...
}
private void handleFunctionCallback(final ChatRequest.Builder chatBuilder, final ChatResponse chatResponse) {
var responseMessage = chatResponse.getChoices().get(0).getMessage();
var functionCall = responseMessage.getFunctionCall();
var functionResponse = getFunctionResponse(functionCall);
// ...
}
The above code demonstrates how to handle a function callback within the runConversation()
method. Let’s break it down:
final var chatRequest = ...
: This line represents the creation of thechatRequest
object, which contains the necessary configuration for the chat request to be sent to the ChatGPT model, including the function definition that we defined earlier.final var chatResponse = client.chat(chatRequest)
: This line sends thechatRequest
to the ChatGPT model using thechat()
method of theclient
. It returns achatResponse
object that contains the response generated by the model.chatResponse.getResponse().ifPresent(response -> handleFunctionCallback(chatBuilder, response))
: This line checks if thechatResponse
contains a response by using thegetResponse()
method. If a response is present, it invokes thehandleFunctionCallback()
method and passes thechatBuilder
andresponse
as arguments. This is done to handle any function callbacks received from the ChatGPT model during the conversation.handleFunctionCallback(final ChatRequest.Builder chatBuilder, final ChatResponse chatResponse)
: This method receives thechatBuilder
andchatResponse
as parameters. It handles the function callback received from the ChatGPT model.var responseMessage = chatResponse.getChoices().get(0).getMessage()
: This line retrieves the first message choice from thechatResponse
. It assumes that the model provides multiple response choices and focuses on the first one.var functionCall = responseMessage.getFunctionCall()
: This line extracts theFunctionCall
object from theresponseMessage
. It represents a function call made by the ChatGPT model during the conversation.var functionResponse = getFunctionResponse(functionCall)
: This line invokes thegetFunctionResponse()
method, passing thefunctionCall
object as an argument, to retrieve the response generated by the function call.
This code demonstrates how to handle function callbacks within the runConversation()
method. It sends a chat request to the ChatGPT model, receives the response, and if a response is present, it invokes the handleFunctionCallback()
method to handle the function callback. The function callback is extracted from the response message, and the getFunctionResponse()
method is called to retrieve the function’s response.
2.2 ChatGPT selects this function by returning a functionCall
from a message
private final Map<String, Function<ObjectNode, String>> functionMap = new HashMap<>();
/**
* Example dummy function hard-coded to return the same weather for two cities and a default for other cities.
* In production, this could be your backend API or an external API.
* @param objectNode arguments from ChatGPT.
* @return JSON string
*/
public String getCurrentWeather(final ObjectNode objectNode) {
final String location = objectNode.getString("location");
final String unit = Optional.ofNullable(objectNode.get("unit"))
.map(node -> node.asScalar().stringValue()).orElse("fahrenheit");
final JsonSerializer json = new JsonSerializer();
json.startObject();
json.addAttribute("location", location);
json.addAttribute("unit", unit);
switch (location) {
case "Austin, TX":
json.addAttribute("temperature", 92);
json.endObject();
return json.toString();
case "Boston, MA":
json.addAttribute("temperature", 72);
json.endObject();
return json.toString();
default:
json.addAttribute("temperature", 70);
json.endObject();
return json.toString();
}
}
public WeatherFunctionCallExample(OpenAIClient client) {
this.client = client;
functionMap.put("get_current_weather", this::getCurrentWeather); // register
}
private String getFunctionResponse(FunctionalCall functionCall) {
String functionResponse = "";
if (functionCall != null && functionMap.containsKey(functionCall.getName())) {
functionResponse = functionMap
.get(functionCall.getName())
.apply(functionCall.getArguments());
}
return functionResponse;
}
The provided code snippet is an example of a weather-related function implementation within a larger ChatGPT conversation. Let’s break it down:
functionMap = new HashMap<>()
: This line declares and initializes aMap
namedfunctionMap
that maps function names (as strings) to functions that accept anObjectNode
parameter and return aString
. This map is used to associate function names with their respective implementations. TheObjectNode
contains the arguments for the function call that ChatGPT decided to make.getCurrentWeather(final ObjectNode objectNode)
: This method implements theget_current_weather
function. It takes anObjectNode
as input, which contains the arguments passed from the ChatGPT model. It retrieves thelocation
andunit
values from theObjectNode
and generates a JSON response based on the specified location. The temperature values for “Austin, TX”, “Boston, MA”, and the default location are hard-coded. The JSON response is constructed using theJsonSerializer
class, and the function returns the generated JSON as a string.WeatherFunctionCallExample(OpenAIClient client)
: This is the constructor for theWeatherFunctionCallExample
class. It takes anOpenAIClient
object as a parameter, initializes theclient
field, and registers thegetCurrentWeather
function by adding it to thefunctionMap
with the key “get_current_weather”.getFunctionResponse(FunctionalCall functionCall)
: This method retrieves the function response based on aFunctionalCall
object. It first checks if thefunctionCall
object is not null and if thefunctionMap
contains the function name specified in thefunctionCall
. If both conditions are met, it invokes the associated function from thefunctionMap
using the function name as the key and passes the function call arguments to it. The result is then returned as the function response. This is how we map the function that ChatGPT requested to call and the results to a message for our next chat.
Overall, this code demonstrates an example implementation of a weather-related function and its integration into a larger program using a functionMap
to associate function names with their respective implementations for easy access in a ChatGPT conversation.
3. Call ChatGPT again by appending the function response as a new message, and let the model summarize the results to the user.
private void handleFunctionCallback(final ChatRequest.Builder chatBuilder,
final ChatResponse chatResponse) {
var responseMessage = chatResponse.getChoices().get(0).getMessage();
var functionCall = responseMessage.getFunctionCall();
var functionResponse = getFunctionResponse(functionCall);
chatBuilder.addMessage(Message.builder().name(functionCall.getName()).role(Role.FUNCTION)
.content(functionResponse)
.build());
var response = client.chat(chatBuilder.build());
response.getResponse().ifPresent(chatResponse1 ->
System.out.println(chatResponse1.getChoices().get(0).getMessage().getContent()));
}
The handleFunctionCallback
method handles the function callback response received from the ChatGPT model. It retrieves the function call from the response, invokes the appropriate function to generate a response, adds the function response as a message in the chatBuilder
, sends the updated chatBuilder
back to the model, and prints the subsequent response generated by the model to the console.
Here’s a breakdown of what the code does:
var responseMessage = chatResponse.getChoices().get(0).getMessage()
: This line retrieves the first message from the choices available in thechatResponse
object. ThechatResponse
likely contains multiple possible responses generated by the ChatGPT model, and here we are focusing on the first one.var functionCall = responseMessage.getFunctionCall()
: This line retrieves theFunctionCall
object from theresponseMessage
. TheFunctionCall
represents a function call made by the ChatGPT model during the conversation.var functionResponse = getFunctionResponse(functionCall)
: This line invokes thegetFunctionResponse()
method, passing thefunctionCall
object as an argument, to retrieve the response generated by the function call.chatBuilder.addMessage(Message.builder().name(functionCall.getName()).role(Role.FUNCTION).content(functionResponse).build())
: This line creates a newMessage
object representing the response from the function call. It sets the name of the message to the name of the function, assigns the role asRole.FUNCTION
, and sets the content of the message as thefunctionResponse
. The message is then added to thechatBuilder
. This enables the ChatGPT model to mix in the response from our message.var response = client.chat(chatBuilder.build())
: This line sends the updatedchatBuilder
with the function response message to the ChatGPT model by invoking thechat()
method of theclient
. It likely initiates the next iteration of the conversation, including the function response.response.getResponse().ifPresent(chatResponse1 -> System.out.println(chatResponse1.getChoices().get(0).getMessage().getContent()))
: This line retrieves the response generated by the ChatGPT model in theresponse
object. It then extracts the first message choice from the response and prints its content to the console.
JSON TO/FROM
Let’s look at the messages going to and from ChatGPT to fully understand this example.
Call the ChatGPT chat with the user query and a set of functions defined in the functions
parameter.
Here is the initial message that we send to ChatGPT:
{
"model":"gpt-3.5-turbo-0613",
"messages":[
{
"role":"user",
"content":"What's the weather like in Boston in fahrenheit?"
}
],
"function_call":"auto",
"functions":[
{
"name":"get_current_weather",
"parameters":{
"type":"object",
"properties":{
"location":{
"type":"string"
},
"unit":{
"type":"string",
"enum":[
"celsius",
"fahrenheit"
]
}
},
"required":[
"location"
]
}
}
]
}
- ChatGPT can choose to call a function. ChatGPT selects this function by returning a
functionCall
from a message (from a choice). ThefunctionCall
arguments are in a JSON object that you must deserialize.
Here is the response from ChatGPT:
{
"id": "chatcmpl-7aWQG4KfBi7zLXkQXkGv0lp7YHGuu",
"object": "chat.completion",
"created": 1688938796,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"function_call": {
"name": "get_current_weather",
"arguments": "{\n \"location\": \"Boston\",\n \"unit\": \"fahrenheit\"\n}"
}
},
"finish_reason": "function_call"
}
],
"usage": {
"prompt_tokens": 61,
"completion_tokens": 24,
"total_tokens": 85
}
}
Notice that ChatGPT returned a message that has a function_call
defined. This means it wants you to invoke your function called get_current_weather
.
From the functionCall
, you call a function in your code with the provided arguments and get a function response.
Call ChatGPT again by appending the function response as a new message, and let the model summarize the results back to the user.
Here is the original request with the function response mixed in:
{
"model":"gpt-3.5-turbo-0613",
"messages":[
{
"role":"user",
"content":"What's the weather like in Boston in fahrenheit?"
},
{
"role":"function",
"content":"{\"location\":\"Boston\",\"unit\":\"fahrenheit\",\"temperature\":70}",
"name":"get_current_weather"
}
]
}
Then lastly, ChatGPT mixes the results with the content/context returned from your weather function.
The final response from ChatGPT mixes our get_current_weather
response:
{
"id": "chatcmpl-7aWQIWMzyaPDNtxJtmBQ43PYfEueh",
"object": "chat.completion",
"created": 1688938798,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The weather in Boston is currently 70 degrees Fahrenheit."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 81,
"completion_tokens": 12,
"total_tokens": 93
}
}
This developer notebook provides a comprehensive guide on how to implement and integrate functions into a ChatGPT conversation with JAI. The first step is to define a function. This can be done by creating a dictionary that maps function names to their respective implementations. The implementation can be a simple function with arguments or a more complex function, such as one that makes API calls to retrieve data.
Next, we covered how to handle function callbacks. When ChatGPT calls a function, it returns a “function call” object containing the function’s name and its arguments. The function call is extracted from the response message, and the appropriate function is invoked with the provided arguments. The function then generates a response, which is sent back to ChatGPT.
Once the function generates the response, we explain how to call ChatGPT again by appending the function response as a new message. This allows ChatGPT to mix the results with the content and context returned from the function. The updated chat request is then sent back to the ChatGPT model, and the process continues until a final response is generated.
We also included an example implementation of a weather-related function and its integration into a larger program using a function map. The function map associates function names with their respective implementations for easy access in a ChatGPT conversation.
Overall, this developer notebook explains how to implement and integrate functions into a ChatGPT conversation, from defining a function to handling function callbacks and mixing the results with the content and context returned.
As artificial intelligence and chatbots continue to gain popularity, it is increasingly important to integrate functions into chat conversations. Functions are essentially small units of code that can be reused and embedded into larger programs to perform a specific task. In this blog post, we will discuss how to implement and integrate functions into ChatGPT conversations using JAI, a Java OpenAI API client. This guide will define a function, handle function callbacks, and mix function results with the content and context returned from the function. We will also provide an example of a weather-related function and its integration into a larger program using a function map.
Related content:
- Java Open AI Client
- Using ChatGpt embeddings and HyDE to improve search results
- Anthropics Claude Chatbot Gets Upgrade
- Elon Musks XAi’s new frontier for artificial intelligence
- Using Mockito to test JAI Java Open AI Client
- Fine-tuning journey with Open AI API
- Using Open AI to create callback functions, the basis for plugins
- Using Java Open AI Client Async
- Fastest Java JSON Parser
- Java Open AI API Client on Github
- Medium: Introducing Java Open AI Client
- Medium: Using ChatGPT, Embeddings, and HyDE to Improve Search Results
Author Bio
Rick Hightower is a renowned software engineer, author, and AI enthusiast with over two decades of experience in the tech industry. As the creator of JAI (Java AI Open API Client), Rick has been at the forefront of integrating AI technologies with Java applications.
With a passion for open-source development and a deep understanding of artificial intelligence, Rick frequently contributes to the developer community through his insightful blog posts, technical articles, and open-source projects. His work focuses on making AI technologies more accessible to Java developers and exploring innovative ways to leverage AI in software development.
Rick is also a frequent speaker at technology conferences and has authored several books on Java and software engineering. His expertise spans across various domains, including AI integration, high-performance computing, and scalable system architectures.
When not coding or writing about the latest in AI and Java, Rick enjoys mentoring young developers and participating in hackathons to stay connected with emerging trends in the tech world.
TweetApache Spark Training
Kafka Tutorial
Akka Consulting
Cassandra Training
AWS Cassandra Database Support
Kafka Support Pricing
Cassandra Database Support Pricing
Non-stop Cassandra
Watchdog
Advantages of using Cloudurable™
Cassandra Consulting
Cloudurable™| Guide to AWS Cassandra Deploy
Cloudurable™| AWS Cassandra Guidelines and Notes
Free guide to deploying Cassandra on AWS
Kafka Training
Kafka Consulting
DynamoDB Training
DynamoDB Consulting
Kinesis Training
Kinesis Consulting
Kafka Tutorial PDF
Kubernetes Security Training
Redis Consulting
Redis Training
ElasticSearch / ELK Consulting
ElasticSearch Training
InfluxDB/TICK Training TICK Consulting