simple-openai
A Java library to use the OpenAI Api in the simplest possible way.
Stars: 65
Simple-OpenAI is a Java library that provides a simple way to interact with the OpenAI API. It offers consistent interfaces for various OpenAI services like Audio, Chat Completion, Image Generation, and more. The library uses CleverClient for HTTP communication, Jackson for JSON parsing, and Lombok to reduce boilerplate code. It supports asynchronous requests and provides methods for synchronous calls as well. Users can easily create objects to communicate with the OpenAI API and perform tasks like text-to-speech, transcription, image generation, and chat completions.
README:
A Java library to use the OpenAI Api in the simplest possible way.
- Description
- Supported Services
- Installation
- Usage
- Support for Additional OpenAI Providers
- Run Examples
- Contributing
- License
- Show Us Your Love
Simple-OpenAI is a Java http client library for sending requests to and receiving responses from the OpenAI API. It exposes a consistent interface across all the services, yet as simple as you can find in other languages like Python or NodeJs. It's an unofficial library.
Simple-OpenAI uses the CleverClient library for http communication, Jackson for Json parsing, and Lombok to minimize boilerplate code, among others libraries.
Simple-OpenAI seeks to stay up to date with the most recent changes in OpenAI. Currently, it supports all existing features until Jun 6th, 2024 and will continue to update with future changes.
Full support for all of the OpenAI services:
- Audio (Speech, Transcription, Translation)
- Batch (Batches of Chat Completion)
- Chat Completion (Text Generation, Streaming, Function Calling, Vision)
- Completion (Legacy Text Generation)
- Embedding (Vectoring Text)
- Files (Upload Files)
- Fine Tuning (Customize Models)
- Image (Generate, Edit, Variation)
- Models (List)
- Moderation (Check Harmful Text)
- Assistants Beta v2 (Assistants, Threads, Messages, Runs, Steps, Vector Stores, Streaming, Function Calling, Vision)
NOTES:
- The methods's responses are
CompletableFuture<ResponseObject>
, which means they are asynchronous, but you can call the join() method to return the result value when complete. - Exceptions for the above point are the methods whose names end with the suffix
AndPoll()
. These methods are synchronous and block until a Predicate function that you provide returns false.
You can install Simple-OpenAI by adding the following dependency to your Maven project:
<dependency>
<groupId>io.github.sashirestela</groupId>
<artifactId>simple-openai</artifactId>
<version>[latest version]</version>
</dependency>
Or alternatively using Gradle:
dependencies {
implementation 'io.github.sashirestela:simple-openai:[latest version]'
}
This is the first step you need to do before to use the services. You must provide at least your OpenAI Api Key (See here for more details). In the following example we are getting the Api Key from an environment variable called OPENAI_API_KEY
which we have created to keep it:
var openAI = SimpleOpenAI.builder()
.apiKey(System.getenv("OPENAI_API_KEY"))
.build();
Optionally you could pass your OpenAI Organization Id in case you have multiple organizations and you want to identify usage by organization and/or you could pass your OpenAI Project Id in case you want to provides access to a single project. In the following example we are using environment variable for those Ids:
var openAI = SimpleOpenAI.builder()
.apiKey(System.getenv("OPENAI_API_KEY"))
.organizationId(System.getenv("OPENAI_ORGANIZATION_ID"))
.projectId(System.getenv("OPENAI_PROJECT_ID"))
.build();
Optionally, as well, you could provide a custom Java HttpClient object if you want to have more options for the http connection, such as executors, proxy, timeout, cookies, etc. (See here for more details). In the following example we are providing a custom HttpClient:
var httpClient = HttpClient.newBuilder()
.version(Version.HTTP_1_1)
.followRedirects(Redirect.NORMAL)
.connectTimeout(Duration.ofSeconds(20))
.executor(Executors.newFixedThreadPool(3))
.proxy(ProxySelector.of(new InetSocketAddress("proxy.example.com", 80)))
.build();
var openAI = SimpleOpenAI.builder()
.apiKey(System.getenv("OPENAI_API_KEY"))
.httpClient(httpClient)
.build();
After you have created a SimpleOpenAI object, you are ready to call its services in order to communicate to OpenAI API. Let's see some examples.
Example to call the Audio service to transform text to audio. We are requesting to receive the audio in binary format (InputStream):
var speechRequest = SpeechRequest.builder()
.model("tts-1")
.input("Hello world, welcome to the AI universe!")
.voice(Voice.ALLOY)
.responseFormat(SpeechResponseFormat.MP3)
.speed(1.0)
.build();
var futureSpeech = openAI.audios().speak(speechRequest);
var speechResponse = futureSpeech.join();
try {
var audioFile = new FileOutputStream(speechFileName);
audioFile.write(speechResponse.readAllBytes());
System.out.println(audioFile.getChannel().size() + " bytes");
audioFile.close();
} catch (Exception e) {
e.printStackTrace();
}
Example to call the Audio service to transcribe an audio to text. We are requesting to receive the transcription in plain text format (see the name of the method):
var audioRequest = TranscriptionRequest.builder()
.file(Paths.get("hello_audio.mp3"))
.model("whisper-1")
.responseFormat(AudioResponseFormat.VERBOSE_JSON)
.temperature(0.2)
.timestampGranularity(TimestampGranularity.WORD)
.timestampGranularity(TimestampGranularity.SEGMENT)
.build();
var futureAudio = openAI.audios().transcribe(audioRequest);
var audioResponse = futureAudio.join();
System.out.println(audioResponse);
Example to call the Image service to generate two images in response to our prompt. We are requesting to receive the images' urls and we are printing out them in the console:
var imageRequest = ImageRequest.builder()
.prompt("A cartoon of a hummingbird that is flying around a flower.")
.n(2)
.size(Size.X256)
.responseFormat(ImageResponseFormat.URL)
.model("dall-e-2")
.build();
var futureImage = openAI.images().create(imageRequest);
var imageResponse = futureImage.join();
imageResponse.stream().forEach(img -> System.out.println("\n" + img.getUrl()));
Example to call the Chat Completion service to ask a question and wait for a full answer. We are printing out it in the console:
var chatRequest = ChatRequest.builder()
.model("gpt-3.5-turbo-1106")
.message(SystemMessage.of("You are an expert in AI."))
.message(UserMessage.of("Write a technical article about ChatGPT, no more than 100 words."))
.temperature(0.0)
.maxTokens(300)
.build();
var futureChat = openAI.chatCompletions().create(chatRequest);
var chatResponse = futureChat.join();
System.out.println(chatResponse.firstContent());
Example to call the Chat Completion service to ask a question and wait for an answer in partial message deltas. We are printing out it in the console as soon as each delta is arriving:
var chatRequest = ChatRequest.builder()
.model("gpt-3.5-turbo-1106")
.message(SystemMessage.of("You are an expert in AI."))
.message(UserMessage.of("Write a technical article about ChatGPT, no more than 100 words."))
.temperature(0.0)
.maxTokens(300)
.build();
var futureChat = openAI.chatCompletions().createStream(chatRequest);
var chatResponse = futureChat.join();
chatResponse.filter(chatResp -> chatResp.firstContent() != null)
.map(Chat::firstContent)
.forEach(System.out::print);
System.out.println();
This functionality empowers the Chat Completion service to solve specific problems to our context. In this example we are setting three functions and we are entering a prompt that will require to call one of them (the function product
). For setting functions we are using additional classes which implements the interface Functional
. Those classes define a field by each function argument, annotating them to describe them and each class must override the execute
method with the function's logic. Note that we are using the FunctionExecutor
utility class to enroll the functions and to execute the function selected by the openai.chatCompletions()
calling:
public void demoCallChatWithFunctions() {
var functionExecutor = new FunctionExecutor();
functionExecutor.enrollFunction(
FunctionDef.builder()
.name("get_weather")
.description("Get the current weather of a location")
.functionalClass(Weather.class)
.build());
functionExecutor.enrollFunction(
FunctionDef.builder()
.name("product")
.description("Get the product of two numbers")
.functionalClass(Product.class)
.build());
functionExecutor.enrollFunction(
FunctionDef.builder()
.name("run_alarm")
.description("Run an alarm")
.functionalClass(RunAlarm.class)
.build());
var messages = new ArrayList<ChatMessage>();
messages.add(UserMessage.of("What is the product of 123 and 456?"));
chatRequest = ChatRequest.builder()
.model(modelIdToUse)
.messages(messages)
.tools(functionExecutor.getToolFunctions())
.build();
var futureChat = openAI.chatCompletions().create(chatRequest);
var chatResponse = futureChat.join();
var chatMessage = chatResponse.firstMessage();
var chatToolCall = chatMessage.getToolCalls().get(0);
var result = functionExecutor.execute(chatToolCall.getFunction());
messages.add(chatMessage);
messages.add(ToolMessage.of(result.toString(), chatToolCall.getId()));
chatRequest = ChatRequest.builder()
.model(modelIdToUse)
.messages(messages)
.tools(functionExecutor.getToolFunctions())
.build();
futureChat = openAI.chatCompletions().create(chatRequest);
chatResponse = futureChat.join();
System.out.println(chatResponse.firstContent());
}
public static class Weather implements Functional {
@JsonPropertyDescription("City and state, for example: LeΓ³n, Guanajuato")
public String location;
@JsonPropertyDescription("The temperature unit, can be 'celsius' or 'fahrenheit'")
@JsonProperty(required = true)
public String unit;
@Override
public Object execute() {
return Math.random() * 45;
}
}
public static class Product implements Functional {
@JsonPropertyDescription("The multiplicand part of a product")
@JsonProperty(required = true)
public double multiplicand;
@JsonPropertyDescription("The multiplier part of a product")
@JsonProperty(required = true)
public double multiplier;
@Override
public Object execute() {
return multiplicand * multiplier;
}
}
public static class RunAlarm implements Functional {
@Override
public Object execute() {
return "DONE";
}
}
Example to call the Chat Completion service to allow the model to take in external images and answer questions about them:
var chatRequest = ChatRequest.builder()
.model("gpt-4-vision-preview")
.messages(List.of(
UserMessage.of(List.of(
ContentPartText.of(
"What do you see in the image? Give in details in no more than 100 words."),
ContentPartImageUrl.of(ImageUrl.of(
"https://upload.wikimedia.org/wikipedia/commons/e/eb/Machu_Picchu%2C_Peru.jpg"))))))
.temperature(0.0)
.maxTokens(500)
.build();
var chatResponse = openAI.chatCompletions().createStream(chatRequest).join();
chatResponse.forEach(ChatDemo::processResponseChunk);
System.out.println();
Example to call the Chat Completion service to allow the model to take in local images and answer questions about them:
var chatRequest = ChatRequest.builder()
.model("gpt-4-vision-preview")
.messages(List.of(
UserMessage.of(List.of(
ContentPartText.of(
"What do you see in the image? Give in details in no more than 100 words."),
ContentPartImageUrl.of(loadImageAsBase64("src/demo/resources/machupicchu.jpg"))))))
.temperature(0.0)
.maxTokens(500)
.build();
var chatResponse = openAI.chatCompletions().createStream(chatRequest).join();
chatResponse.forEach(ChatDemo::processResponseChunk);
System.out.println();
private static ImageUrl loadImageAsBase64(String imagePath) {
try {
Path path = Paths.get(imagePath);
byte[] imageBytes = Files.readAllBytes(path);
String base64String = Base64.getEncoder().encodeToString(imageBytes);
var extension = imagePath.substring(imagePath.lastIndexOf('.') + 1);
var prefix = "data:image/" + extension + ";base64,";
return ImageUrl.of(prefix + base64String);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
This example simulates a conversation chat by the command console and demonstrates the usage of ChatCompletion with streaming and call functions.
You can see the full demo code as well as the results from running the demo code:
Demo Code
package io.github.sashirestela.openai.demo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import io.github.sashirestela.openai.SimpleOpenAI;
import io.github.sashirestela.openai.common.function.FunctionDef;
import io.github.sashirestela.openai.common.function.FunctionExecutor;
import io.github.sashirestela.openai.common.function.Functional;
import io.github.sashirestela.openai.common.tool.ToolCall;
import io.github.sashirestela.openai.domain.chat.Chat;
import io.github.sashirestela.openai.domain.chat.Chat.Choice;
import io.github.sashirestela.openai.domain.chat.ChatMessage;
import io.github.sashirestela.openai.domain.chat.ChatMessage.AssistantMessage;
import io.github.sashirestela.openai.domain.chat.ChatMessage.ResponseMessage;
import io.github.sashirestela.openai.domain.chat.ChatMessage.ToolMessage;
import io.github.sashirestela.openai.domain.chat.ChatMessage.UserMessage;
import io.github.sashirestela.openai.domain.chat.ChatRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
public class ConversationDemo {
private SimpleOpenAI openAI;
private FunctionExecutor functionExecutor;
private int indexTool;
private StringBuilder content;
private StringBuilder functionArgs;
public ConversationDemo() {
openAI = SimpleOpenAI.builder().apiKey(System.getenv("OPENAI_API_KEY")).build();
}
public void prepareConversation() {
List<FunctionDef> functionList = new ArrayList<>();
functionList.add(FunctionDef.builder()
.name("getCurrentTemperature")
.description("Get the current temperature for a specific location")
.functionalClass(CurrentTemperature.class)
.build());
functionList.add(FunctionDef.builder()
.name("getRainProbability")
.description("Get the probability of rain for a specific location")
.functionalClass(RainProbability.class)
.build());
functionExecutor = new FunctionExecutor(functionList);
}
public void runConversation() {
List<ChatMessage> messages = new ArrayList<>();
var myMessage = System.console().readLine("\nWelcome! Write any message: ");
messages.add(UserMessage.of(myMessage));
while (!myMessage.toLowerCase().equals("exit")) {
var chatStream = openAI.chatCompletions()
.createStream(ChatRequest.builder()
.model("gpt-4o")
.messages(messages)
.tools(functionExecutor.getToolFunctions())
.temperature(0.2)
.stream(true)
.build())
.join();
indexTool = -1;
content = new StringBuilder();
functionArgs = new StringBuilder();
var response = getResponse(chatStream);
if (response.getMessage().getContent() != null) {
messages.add(AssistantMessage.of(response.getMessage().getContent()));
}
if (response.getFinishReason().equals("tool_calls")) {
messages.add(response.getMessage());
var toolCalls = response.getMessage().getToolCalls();
var toolMessages = functionExecutor.executeAll(toolCalls,
(toolCallId, result) -> ToolMessage.of(result, toolCallId));
messages.addAll(toolMessages);
} else {
myMessage = System.console().readLine("\n\nWrite any message (or write 'exit' to finish): ");
messages.add(UserMessage.of(myMessage));
}
}
}
private Choice getResponse(Stream<Chat> chatStream) {
var choice = new Choice();
choice.setIndex(0);
var chatMsgResponse = new ResponseMessage();
List<ToolCall> toolCalls = new ArrayList<>();
chatStream.forEach(responseChunk -> {
var choices = responseChunk.getChoices();
if (choices.size() > 0) {
var innerChoice = choices.get(0);
var delta = innerChoice.getMessage();
if (delta.getRole() != null) {
chatMsgResponse.setRole(delta.getRole());
} else if (delta.getContent() != null && !delta.getContent().isEmpty()) {
content.append(delta.getContent());
System.out.print(delta.getContent());
} else if (delta.getToolCalls() != null) {
var toolCall = delta.getToolCalls().get(0);
if (toolCall.getIndex() != indexTool) {
if (toolCalls.size() > 0) {
toolCalls.get(toolCalls.size() - 1).getFunction().setArguments(functionArgs.toString());
functionArgs = new StringBuilder();
}
toolCalls.add(toolCall);
indexTool++;
} else {
functionArgs.append(toolCall.getFunction().getArguments());
}
} else {
if (content.length() > 0) {
chatMsgResponse.setContent(content.toString());
}
if (toolCalls.size() > 0) {
toolCalls.get(toolCalls.size() - 1).getFunction().setArguments(functionArgs.toString());
chatMsgResponse.setToolCalls(toolCalls);
}
choice.setMessage(chatMsgResponse);
choice.setFinishReason(innerChoice.getFinishReason());
}
}
});
return choice;
}
public static void main(String[] args) {
var demo = new ConversationDemo();
demo.prepareConversation();
demo.runConversation();
}
public static class CurrentTemperature implements Functional {
@JsonPropertyDescription("The city and state, e.g., San Francisco, CA")
@JsonProperty(required = true)
public String location;
@JsonPropertyDescription("The temperature unit to use. Infer this from the user's location.")
@JsonProperty(required = true)
public String unit;
@Override
public Object execute() {
double centigrades = Math.random() * (40.0 - 10.0) + 10.0;
double fahrenheit = centigrades * 9.0 / 5.0 + 32.0;
String shortUnit = unit.substring(0, 1).toUpperCase();
return shortUnit.equals("C") ? centigrades : (shortUnit.equals("F") ? fahrenheit : 0.0);
}
}
public static class RainProbability implements Functional {
@JsonPropertyDescription("The city and state, e.g., San Francisco, CA")
@JsonProperty(required = true)
public String location;
@Override
public Object execute() {
return Math.random() * 100;
}
}
}
Demo Results
Welcome! Write any message: Hi, can you help me with some quetions about Lima, Peru?
Of course! What would you like to know about Lima, Peru?
Write any message (or write 'exit' to finish): Tell me something brief about Lima Peru, then tell me how's the weather there right now. Finally give me three tips to travel there.
### Brief About Lima, Peru
Lima, the capital city of Peru, is a bustling metropolis that blends modernity with rich historical heritage. Founded by Spanish conquistador Francisco Pizarro in 1535, Lima is known for its colonial architecture, vibrant culture, and delicious cuisine, particularly its world-renowned ceviche. The city is also a gateway to exploring Peru's diverse landscapes, from the coastal deserts to the Andean highlands and the Amazon rainforest.
### Current Weather in Lima, Peru
I'll check the current temperature and the probability of rain in Lima for you.### Current Weather in Lima, Peru
- **Temperature:** Approximately 11.8Β°C
- **Probability of Rain:** Approximately 97.8%
### Three Tips for Traveling to Lima, Peru
1. **Explore the Historic Center:**
- Visit the Plaza Mayor, the Government Palace, and the Cathedral of Lima. These landmarks offer a glimpse into Lima's colonial past and are UNESCO World Heritage Sites.
2. **Savor the Local Cuisine:**
- Don't miss out on trying ceviche, a traditional Peruvian dish made from fresh raw fish marinated in citrus juices. Also, explore the local markets and try other Peruvian delicacies.
3. **Visit the Coastal Districts:**
- Head to Miraflores and Barranco for stunning ocean views, vibrant nightlife, and cultural experiences. These districts are known for their beautiful parks, cliffs, and bohemian atmosphere.
Enjoy your trip to Lima! If you have any more questions, feel free to ask.
Write any message (or write 'exit' to finish): exit
This example simulates a conversation chat by the command console and demonstrates the usage of the latest Assistants API v2 features:
- Vector Stores to upload files and incorporate it as new knowledge base.
- Function Tools to use internal bussiness services to answer questions.
- File Search Tools to use vectorized files to do semantic search.
- Thread Run Streaming to answer with chunks of tokens in real time.
You can see the full demo code as well as the results from running the demo code:
Demo Code
package io.github.sashirestela.openai.demo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import io.github.sashirestela.cleverclient.Event;
import io.github.sashirestela.openai.SimpleOpenAI;
import io.github.sashirestela.openai.common.content.ContentPart.ContentPartTextAnnotation;
import io.github.sashirestela.openai.common.function.FunctionDef;
import io.github.sashirestela.openai.common.function.FunctionExecutor;
import io.github.sashirestela.openai.common.function.Functional;
import io.github.sashirestela.openai.domain.assistant.AssistantRequest;
import io.github.sashirestela.openai.domain.assistant.AssistantTool;
import io.github.sashirestela.openai.domain.assistant.ThreadMessageDelta;
import io.github.sashirestela.openai.domain.assistant.ThreadMessageRequest;
import io.github.sashirestela.openai.domain.assistant.ThreadMessageRole;
import io.github.sashirestela.openai.domain.assistant.ThreadRequest;
import io.github.sashirestela.openai.domain.assistant.ThreadRun;
import io.github.sashirestela.openai.domain.assistant.ThreadRun.RunStatus;
import io.github.sashirestela.openai.domain.assistant.ThreadRunRequest;
import io.github.sashirestela.openai.domain.assistant.ThreadRunSubmitOutputRequest;
import io.github.sashirestela.openai.domain.assistant.ThreadRunSubmitOutputRequest.ToolOutput;
import io.github.sashirestela.openai.domain.assistant.ToolResourceFull;
import io.github.sashirestela.openai.domain.assistant.ToolResourceFull.FileSearch;
import io.github.sashirestela.openai.domain.assistant.VectorStoreRequest;
import io.github.sashirestela.openai.domain.assistant.events.EventName;
import io.github.sashirestela.openai.domain.file.FileRequest;
import io.github.sashirestela.openai.domain.file.FileRequest.PurposeType;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
public class ConversationV2Demo {
private SimpleOpenAI openAI;
private String fileId;
private String vectorStoreId;
private FunctionExecutor functionExecutor;
private String assistantId;
private String threadId;
public ConversationV2Demo() {
openAI = SimpleOpenAI.builder().apiKey(System.getenv("OPENAI_API_KEY")).build();
}
public void prepareConversation() {
List<FunctionDef> functionList = new ArrayList<>();
functionList.add(FunctionDef.builder()
.name("getCurrentTemperature")
.description("Get the current temperature for a specific location")
.functionalClass(CurrentTemperature.class)
.build());
functionList.add(FunctionDef.builder()
.name("getRainProbability")
.description("Get the probability of rain for a specific location")
.functionalClass(RainProbability.class)
.build());
functionExecutor = new FunctionExecutor(functionList);
var file = openAI.files()
.create(FileRequest.builder()
.file(Paths.get("src/demo/resources/mistral-ai.txt"))
.purpose(PurposeType.ASSISTANTS)
.build())
.join();
fileId = file.getId();
System.out.println("File was created with id: " + fileId);
var vectorStore = openAI.vectorStores()
.createAndPoll(VectorStoreRequest.builder()
.fileId(fileId)
.build());
vectorStoreId = vectorStore.getId();
System.out.println("Vector Store was created with id: " + vectorStoreId);
var assistant = openAI.assistants()
.create(AssistantRequest.builder()
.name("World Assistant")
.model("gpt-4o")
.instructions("You are a skilled tutor on geo-politic topics.")
.tools(functionExecutor.getToolFunctions())
.tool(AssistantTool.fileSearch())
.toolResources(ToolResourceFull.builder()
.fileSearch(FileSearch.builder()
.vectorStoreId(vectorStoreId)
.build())
.build())
.temperature(0.2)
.build())
.join();
assistantId = assistant.getId();
System.out.println("Assistant was created with id: " + assistantId);
var thread = openAI.threads().create(ThreadRequest.builder().build()).join();
threadId = thread.getId();
System.out.println("Thread was created with id: " + threadId);
System.out.println();
}
public void runConversation() {
var myMessage = System.console().readLine("\nWelcome! Write any message: ");
while (!myMessage.toLowerCase().equals("exit")) {
openAI.threadMessages()
.create(threadId, ThreadMessageRequest.builder()
.role(ThreadMessageRole.USER)
.content(myMessage)
.build())
.join();
var runStream = openAI.threadRuns()
.createStream(threadId, ThreadRunRequest.builder()
.assistantId(assistantId)
.build())
.join();
handleRunEvents(runStream);
myMessage = System.console().readLine("\nWrite any message (or write 'exit' to finish): ");
}
}
private void handleRunEvents(Stream<Event> runStream) {
runStream.forEach(event -> {
switch (event.getName()) {
case EventName.THREAD_RUN_CREATED:
case EventName.THREAD_RUN_COMPLETED:
case EventName.THREAD_RUN_REQUIRES_ACTION:
var run = (ThreadRun) event.getData();
System.out.println("=====>> Thread Run: id=" + run.getId() + ", status=" + run.getStatus());
if (run.getStatus().equals(RunStatus.REQUIRES_ACTION)) {
var toolCalls = run.getRequiredAction().getSubmitToolOutputs().getToolCalls();
var toolOutputs = functionExecutor.executeAll(toolCalls,
(toolCallId, result) -> ToolOutput.builder()
.toolCallId(toolCallId)
.output(result)
.build());
var runSubmitToolStream = openAI.threadRuns()
.submitToolOutputStream(threadId, run.getId(), ThreadRunSubmitOutputRequest.builder()
.toolOutputs(toolOutputs)
.stream(true)
.build())
.join();
handleRunEvents(runSubmitToolStream);
}
break;
case EventName.THREAD_MESSAGE_DELTA:
var msgDelta = (ThreadMessageDelta) event.getData();
var content = msgDelta.getDelta().getContent().get(0);
if (content instanceof ContentPartTextAnnotation) {
var textContent = (ContentPartTextAnnotation) content;
System.out.print(textContent.getText().getValue());
}
break;
case EventName.THREAD_MESSAGE_COMPLETED:
System.out.println();
break;
default:
break;
}
});
}
public void cleanConversation() {
var deletedFile = openAI.files().delete(fileId).join();
var deletedVectorStore = openAI.vectorStores().delete(vectorStoreId).join();
var deletedAssistant = openAI.assistants().delete(assistantId).join();
var deletedThread = openAI.threads().delete(threadId).join();
System.out.println("File was deleted: " + deletedFile.getDeleted());
System.out.println("Vector Store was deleted: " + deletedVectorStore.getDeleted());
System.out.println("Assistant was deleted: " + deletedAssistant.getDeleted());
System.out.println("Thread was deleted: " + deletedThread.getDeleted());
}
public static void main(String[] args) {
var demo = new ConversationV2Demo();
demo.prepareConversation();
demo.runConversation();
demo.cleanConversation();
}
public static class CurrentTemperature implements Functional {
@JsonPropertyDescription("The city and state, e.g., San Francisco, CA")
@JsonProperty(required = true)
public String location;
@JsonPropertyDescription("The temperature unit to use. Infer this from the user's location.")
@JsonProperty(required = true)
public String unit;
@Override
public Object execute() {
double centigrades = Math.random() * (40.0 - 10.0) + 10.0;
double fahrenheit = centigrades * 9.0 / 5.0 + 32.0;
String shortUnit = unit.substring(0, 1).toUpperCase();
return shortUnit.equals("C") ? centigrades : (shortUnit.equals("F") ? fahrenheit : 0.0);
}
}
public static class RainProbability implements Functional {
@JsonPropertyDescription("The city and state, e.g., San Francisco, CA")
@JsonProperty(required = true)
public String location;
@Override
public Object execute() {
return Math.random() * 100;
}
}
}
Demo Results
File was created with id: file-oDFIF7o4SwuhpwBNnFIILhMK
Vector Store was created with id: vs_lG1oJmF2s5wLhqHUSeJpELMr
Assistant was created with id: asst_TYS5cZ05697tyn3yuhDrCCIv
Thread was created with id: thread_33n258gFVhZVIp88sQKuqMvg
Welcome! Write any message: Hello
=====>> Thread Run: id=run_nihN6dY0uyudsORg4xyUvQ5l, status=QUEUED
Hello! How can I assist you today?
=====>> Thread Run: id=run_nihN6dY0uyudsORg4xyUvQ5l, status=COMPLETED
Write any message (or write 'exit' to finish): Tell me something brief about Lima Peru, then tell me how's the weather there right now. Finally give me three tips to travel there.
=====>> Thread Run: id=run_QheimPyP5UK6FtmH5obon0fB, status=QUEUED
Lima, the capital city of Peru, is located on the country's arid Pacific coast. It's known for its vibrant culinary scene, rich history, and as a cultural hub with numerous museums, colonial architecture, and remnants of pre-Columbian civilizations. This bustling metropolis serves as a key gateway to visiting Peruβs more famous attractions, such as Machu Picchu and the Amazon rainforest.
Let me find the current weather conditions in Lima for you, and then I'll provide three travel tips.
=====>> Thread Run: id=run_QheimPyP5UK6FtmH5obon0fB, status=REQUIRES_ACTION
### Current Weather in Lima, Peru:
- **Temperature:** 12.8Β°C
- **Rain Probability:** 82.7%
### Three Travel Tips for Lima, Peru:
1. **Best Time to Visit:** Plan your trip during the dry season, from May to September, which offers clearer skies and milder temperatures. This period is particularly suitable for outdoor activities and exploring the city comfortably.
2. **Local Cuisine:** Don't miss out on tasting the local Peruvian dishes, particularly the ceviche, which is renowned worldwide. Lima is also known as the gastronomic capital of South America, so indulge in the wide variety of dishes available.
3. **Cultural Attractions:** Allocate enough time to visit Lima's rich array of museums, such as the Larco Museum, which showcases pre-Columbian art, and the historical center which is a UNESCO World Heritage Site. Moreover, exploring districts like Miraflores and Barranco can provide insights into the modern and bohemian sides of the city.
Enjoy planning your trip to Lima! If you need more information or help, feel free to ask.
=====>> Thread Run: id=run_QheimPyP5UK6FtmH5obon0fB, status=COMPLETED
Write any message (or write 'exit' to finish): Tell me something about the Mistral company
=====>> Thread Run: id=run_5u0t8kDQy87p5ouaTRXsCG8m, status=QUEUED
Mistral AI is a French company that specializes in selling artificial intelligence products. It was established in April 2023 by former employees of Meta Platforms and Google DeepMind. Notably, the company secured a significant amount of funding, raising β¬385 million in October 2023, and achieved a valuation exceeding $2 billion by December of the same year.
The prime focus of Mistral AI is on developing and producing open-source large language models. This approach underscores the foundational role of open-source software as a counter to proprietary models. As of March 2024, Mistral AI has published two models, which are available in terms of weights, while three more modelsβcategorized as Small, Medium, and Largeβare accessible only through an API[1].
=====>> Thread Run: id=run_5u0t8kDQy87p5ouaTRXsCG8m, status=COMPLETED
Write any message (or write 'exit' to finish): exit
File was deleted: true
Vector Store was deleted: true
Assistant was deleted: true
Thread was deleted: true
Simple-OpenAI can be used with additional providers that are compatible with the OpenAI API. At this moment, there is support for the following additional providers:
Azure OpenIA is supported by Simple-OpenAI. We can use the class SimpleOpenAIAzure
, which extends the class BaseSimpleOpenAI
, to start using this provider.
var openai = SimpleOpenAIAzure.builder()
.apiKey(System.getenv("AZURE_OPENAI_API_KEY"))
.baseUrl(System.getenv("AZURE_OPENAI_BASE_URL")) // Including resourceName and deploymentId
.apiVersion(System.getenv("AZURE_OPENAI_API_VERSION"))
//.httpClient(customHttpClient) Optionally you could pass a custom HttpClient
.build();
Currently we are supporting the following services only:
-
chatCompletionService
(streaming mode is not supported) fileService
Anyscale is suported by Simple-OpenAI. We can use the class SimpleOpenAIAnyscale
, which extends the class BaseSimpleOpenAI
, to start using this provider.
var openai = SimpleOpenAIAnyscale.builder()
.apiKey(System.getenv("ANYSCALE_API_KEY"))
//.baseUrl(customUrl) Optionally you could pass a custom baseUrl
//.httpClient(customHttpClient) Optionally you could pass a custom HttpClient
.build();
Currently we are supporting the chatCompletionService
service only. It was tested with the Mistral model.
Examples for each OpenAI service have been created in the folder demo and you can follow the next steps to execute them:
-
Clone this repository:
git clone https://github.com/sashirestela/simple-openai.git cd simple-openai
-
Build the project:
mvn clean install
-
Create an environment variable for your OpenAI Api Key:
export OPENAI_API_KEY=<here goes your api key>
-
Grant execution permission to the script file:
chmod +x rundemo.sh
-
Run examples:
./rundemo.sh <demo> [debug]
Where:
-
<demo>
Is mandatory and must be one of the values:- Audio
- Batch
- Chat
- Completion
- Embedding
- File
- Finetuning
- Image
- Model
- Moderation
- Conversation
- AssistantV2
- ThreadV2
- ThreadMessageV2
- ThreadRunV2
- ThreadRunStepV2
- VectorStoreV2
- VectorStoreFileV2
- VectorStoreFileBatchV2
- ConversationV2
- ChatAnyscale
- ChatAzure
-
[debug]
Is optional and creates thedemo.log
file where you can see log details for each execution. -
For example, to run the chat demo with a log file:
./rundemo.sh Chat debug
-
-
Indications for Azure OpenAI demos
Azure OpenAI requires a separate deployment for each model. The Azure OpenAI demos require two models.
-
gpt-4-turbo (or similar) that supports:
- /chat/completions (including tool calls)
- /files
-
gpt-4-vision-preview that supports:
- /chat/completions (including images).
See the Azure OpenAI docs for more details: Azure OpenAI documentation. Once you have the deployment URLs and the API keys, set the following environment variables:
export AZURE_OPENAI_BASE_URL=<your gpt-4-turbo deployment endpoint URL> export AZURE_OPENAI_API_KEY=<here goes your regional API key> export AZURE_OPENAI_BASE_URL_VISION=<your gpt-4 vision preview deployment endpoint URL> export AZURE_OPENAI_API_KEY_VISION=<here goes your regional API key> export AZURE_OPENAI_API_VERSION=2024-02-15-preview
Note that some models may not be available in all regions. If you have trouble finding a model, try a different region. The API keys are regional (per cognitive account). If you provision multiple models in the same region they will share the same API key (actually there are two keys per region to support alternate key rotation).
-
Kindly read our Contributing guide to learn and understand how to contribute to this project.
Simple-OpenAI is licensed under the MIT License. See the LICENSE file for more information.
Thanks for using simple-openai. If you find this project valuable there are a few ways you can show us your love, preferably all of them π:
- Letting your friends know about this project π£π’.
- Writing a brief review on your social networks βπ.
- Giving us a star on Github β.
For Tasks:
Click tags to check more tools for each tasksFor Jobs:
Alternative AI tools for simple-openai
Similar Open Source Tools
simple-openai
Simple-OpenAI is a Java library that provides a simple way to interact with the OpenAI API. It offers consistent interfaces for various OpenAI services like Audio, Chat Completion, Image Generation, and more. The library uses CleverClient for HTTP communication, Jackson for JSON parsing, and Lombok to reduce boilerplate code. It supports asynchronous requests and provides methods for synchronous calls as well. Users can easily create objects to communicate with the OpenAI API and perform tasks like text-to-speech, transcription, image generation, and chat completions.
cl-waffe2
cl-waffe2 is an experimental deep learning framework in Common Lisp, providing fast, systematic, and customizable matrix operations, reverse mode tape-based Automatic Differentiation, and neural network model building and training features accelerated by a JIT Compiler. It offers abstraction layers, extensibility, inlining, graph-level optimization, visualization, debugging, systematic nodes, and symbolic differentiation. Users can easily write extensions and optimize their networks without overheads. The framework is designed to eliminate barriers between users and developers, allowing for easy customization and extension.
matmulfreellm
MatMul-Free LM is a language model architecture that eliminates the need for Matrix Multiplication (MatMul) operations. This repository provides an implementation of MatMul-Free LM that is compatible with the π€ Transformers library. It evaluates how the scaling law fits to different parameter models and compares the efficiency of the architecture in leveraging additional compute to improve performance. The repo includes pre-trained models, model implementations compatible with π€ Transformers library, and generation examples for text using the π€ text generation APIs.
KULLM
KULLM (ꡬλ¦) is a Korean Large Language Model developed by Korea University NLP & AI Lab and HIAI Research Institute. It is based on the upstage/SOLAR-10.7B-v1.0 model and has been fine-tuned for instruction. The model has been trained on 8ΓA100 GPUs and is capable of generating responses in Korean language. KULLM exhibits hallucination and repetition phenomena due to its decoding strategy. Users should be cautious as the model may produce inaccurate or harmful results. Performance may vary in benchmarks without a fixed system prompt.
MarkLLM
MarkLLM is an open-source toolkit designed for watermarking technologies within large language models (LLMs). It simplifies access, understanding, and assessment of watermarking technologies, supporting various algorithms, visualization tools, and evaluation modules. The toolkit aids researchers and the community in ensuring the authenticity and origin of machine-generated text.
Torch-Pruning
Torch-Pruning (TP) is a library for structural pruning that enables pruning for a wide range of deep neural networks. It uses an algorithm called DepGraph to physically remove parameters. The library supports pruning off-the-shelf models from various frameworks and provides benchmarks for reproducing results. It offers high-level pruners, dependency graph for automatic pruning, low-level pruning functions, and supports various importance criteria and modules. Torch-Pruning is compatible with both PyTorch 1.x and 2.x versions.
Phi-3CookBook
Phi-3CookBook is a manual on how to use the Microsoft Phi-3 family, which consists of open AI models developed by Microsoft. The Phi-3 models are highly capable and cost-effective small language models, outperforming models of similar and larger sizes across various language, reasoning, coding, and math benchmarks. The repository provides detailed information on different Phi-3 models, their performance, availability, and usage scenarios across different platforms like Azure AI Studio, Hugging Face, and Ollama. It also covers topics such as fine-tuning, evaluation, and end-to-end samples for Phi-3-mini and Phi-3-vision models, along with labs, workshops, and contributing guidelines.
awesome-production-llm
This repository is a curated list of open-source libraries for production large language models. It includes tools for data preprocessing, training/finetuning, evaluation/benchmarking, serving/inference, application/RAG, testing/monitoring, and guardrails/security. The repository also provides a new category called LLM Cookbook/Examples for showcasing examples and guides on using various LLM APIs.
imodelsX
imodelsX is a Scikit-learn friendly library that provides tools for explaining, predicting, and steering text models/data. It also includes a collection of utilities for getting started with text data. **Explainable modeling/steering** | Model | Reference | Output | Description | |---|---|---|---| | Tree-Prompt | [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/tree_prompt) | Explanation + Steering | Generates a tree of prompts to steer an LLM (_Official_) | | iPrompt | [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/iprompt) | Explanation + Steering | Generates a prompt that explains patterns in data (_Official_) | | AutoPrompt | [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/autoprompt) | Explanation + Steering | Find a natural-language prompt using input-gradients (β In progress)| | D3 | [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/d3) | Explanation | Explain the difference between two distributions | | SASC | [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/sasc) | Explanation | Explain a black-box text module using an LLM (_Official_) | | Aug-Linear | [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/aug_linear) | Linear model | Fit better linear model using an LLM to extract embeddings (_Official_) | | Aug-Tree | [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/aug_tree) | Decision tree | Fit better decision tree using an LLM to expand features (_Official_) | **General utilities** | Model | Reference | |---|---| | LLM wrapper| [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/llm) | Easily call different LLMs | | | Dataset wrapper| [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/data) | Download minimially processed huggingface datasets | | | Bag of Ngrams | [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/bag_of_ngrams) | Learn a linear model of ngrams | | | Linear Finetune | [Reference](https://github.com/microsoft/AugML/tree/main/imodelsX/linear_finetune) | Finetune a single linear layer on top of LLM embeddings | | **Related work** * [imodels package](https://github.com/microsoft/interpretml/tree/main/imodels) (JOSS 2021) - interpretable ML package for concise, transparent, and accurate predictive modeling (sklearn-compatible). * [Adaptive wavelet distillation](https://arxiv.org/abs/2111.06185) (NeurIPS 2021) - distilling a neural network into a concise wavelet model * [Transformation importance](https://arxiv.org/abs/1912.04938) (ICLR 2020 workshop) - using simple reparameterizations, allows for calculating disentangled importances to transformations of the input (e.g. assigning importances to different frequencies) * [Hierarchical interpretations](https://arxiv.org/abs/1807.03343) (ICLR 2019) - extends CD to CNNs / arbitrary DNNs, and aggregates explanations into a hierarchy * [Interpretation regularization](https://arxiv.org/abs/2006.14340) (ICML 2020) - penalizes CD / ACD scores during training to make models generalize better * [PDR interpretability framework](https://www.pnas.org/doi/10.1073/pnas.1814225116) (PNAS 2019) - an overarching framewwork for guiding and framing interpretable machine learning
dom-to-semantic-markdown
DOM to Semantic Markdown is a tool that converts HTML DOM to Semantic Markdown for use in Large Language Models (LLMs). It maximizes semantic information, token efficiency, and preserves metadata to enhance LLMs' processing capabilities. The tool captures rich web content structure, including semantic tags, image metadata, table structures, and link destinations. It offers customizable conversion options and supports both browser and Node.js environments.
educhain
Educhain is a powerful Python package that leverages Generative AI to create engaging and personalized educational content. It enables users to generate multiple-choice questions, create lesson plans, and support various LLM models. Users can export questions to JSON, PDF, and CSV formats, customize prompt templates, and generate questions from text, PDF, URL files, youtube videos, and images. Educhain outperforms traditional methods in content generation speed and quality. It offers advanced configuration options and has a roadmap for future enhancements, including integration with popular Learning Management Systems and a mobile app for content generation on-the-go.
mlp-mixer-pytorch
MLP Mixer - Pytorch is an all-MLP solution for vision tasks, developed by Google AI, implemented in Pytorch. It provides an architecture that does not require convolutions or attention mechanisms, offering an alternative approach for image and video processing. The tool is designed to handle tasks related to image classification and video recognition, utilizing multi-layer perceptrons (MLPs) for feature extraction and classification. Users can easily install the tool using pip and integrate it into their Pytorch projects to experiment with MLP-based vision models.
docling
Docling is a tool that bundles PDF document conversion to JSON and Markdown in an easy, self-contained package. It can convert any PDF document to JSON or Markdown format, understand detailed page layout, reading order, recover table structures, extract metadata such as title, authors, references, and language, and optionally apply OCR for scanned PDFs. The tool is designed to be stable, lightning fast, and suitable for macOS and Linux environments.
VinAI_Translate
VinAI_Translate is a Vietnamese-English Neural Machine Translation System offering state-of-the-art text-to-text translation models for Vietnamese-to-English and English-to-Vietnamese. The system includes pre-trained models with different configurations and parameters, allowing for further fine-tuning. Users can interact with the models through the VinAI Translate system website or the HuggingFace space 'VinAI Translate'. Evaluation scripts are available for assessing the translation quality. The tool can be used in the 'transformers' library for Vietnamese-to-English and English-to-Vietnamese translations, supporting both GPU-based batch translation and CPU-based sequence translation examples.
LLM4Decompile
LLM4Decompile is an open-source large language model dedicated to decompilation of Linux x86_64 binaries, supporting GCC's O0 to O3 optimization levels. It focuses on assessing re-executability of decompiled code through HumanEval-Decompile benchmark. The tool includes models with sizes ranging from 1.3 billion to 33 billion parameters, available on Hugging Face. Users can preprocess C code into binary and assembly instructions, then decompile assembly instructions into C using LLM4Decompile. Ongoing efforts aim to expand capabilities to support more architectures and configurations, integrate with decompilation tools like Ghidra and Rizin, and enhance performance with larger training datasets.
pixeltable
Pixeltable is a Python library designed for ML Engineers and Data Scientists to focus on exploration, modeling, and app development without the need to handle data plumbing. It provides a declarative interface for working with text, images, embeddings, and video, enabling users to store, transform, index, and iterate on data within a single table interface. Pixeltable is persistent, acting as a database unlike in-memory Python libraries such as Pandas. It offers features like data storage and versioning, combined data and model lineage, indexing, orchestration of multimodal workloads, incremental updates, and automatic production-ready code generation. The tool emphasizes transparency, reproducibility, cost-saving through incremental data changes, and seamless integration with existing Python code and libraries.
For similar tasks
fastllm
A collection of LLM services you can self host via docker or modal labs to support your applications development. The goal is to provide docker containers or modal labs deployments of common patterns when using LLMs and endpoints to integrate easily with existing codebases using the openai api. It supports GPT4all's embedding api, JSONFormer api for chat completion, Cross Encoders based on sentence transformers, and provides documentation using MkDocs.
llm-apps-java-spring-ai
The 'LLM Applications with Java and Spring AI' repository provides samples demonstrating how to build Java applications powered by Generative AI and Large Language Models (LLMs) using Spring AI. It includes projects for question answering, chat completion models, prompts, templates, multimodality, output converters, embedding models, document ETL pipeline, function calling, image models, and audio models. The repository also lists prerequisites such as Java 21, Docker/Podman, Mistral AI API Key, OpenAI API Key, and Ollama. Users can explore various use cases and projects to leverage LLMs for text generation, vector transformation, document processing, and more.
simple-openai
Simple-OpenAI is a Java library that provides a simple way to interact with the OpenAI API. It offers consistent interfaces for various OpenAI services like Audio, Chat Completion, Image Generation, and more. The library uses CleverClient for HTTP communication, Jackson for JSON parsing, and Lombok to reduce boilerplate code. It supports asynchronous requests and provides methods for synchronous calls as well. Users can easily create objects to communicate with the OpenAI API and perform tasks like text-to-speech, transcription, image generation, and chat completions.
generative-ai
This repository contains notebooks, code samples, sample apps, and other resources that demonstrate how to use, develop and manage generative AI workflows using Generative AI on Google Cloud, powered by Vertex AI. For more Vertex AI samples, please visit the Vertex AI samples Github repository.
AISuperDomain
Aila Desktop Application is a powerful tool that integrates multiple leading AI models into a single desktop application. It allows users to interact with various AI models simultaneously, providing diverse responses and insights to their inquiries. With its user-friendly interface and customizable features, Aila empowers users to engage with AI seamlessly and efficiently. Whether you're a researcher, student, or professional, Aila can enhance your AI interactions and streamline your workflow.
generative-ai-for-beginners
This course has 18 lessons. Each lesson covers its own topic so start wherever you like! Lessons are labeled either "Learn" lessons explaining a Generative AI concept or "Build" lessons that explain a concept and code examples in both **Python** and **TypeScript** when possible. Each lesson also includes a "Keep Learning" section with additional learning tools. **What You Need** * Access to the Azure OpenAI Service **OR** OpenAI API - _Only required to complete coding lessons_ * Basic knowledge of Python or Typescript is helpful - *For absolute beginners check out these Python and TypeScript courses. * A Github account to fork this entire repo to your own GitHub account We have created a **Course Setup** lesson to help you with setting up your development environment. Don't forget to star (π) this repo to find it easier later. ## π§ Ready to Deploy? If you are looking for more advanced code samples, check out our collection of Generative AI Code Samples in both **Python** and **TypeScript**. ## π£οΈ Meet Other Learners, Get Support Join our official AI Discord server to meet and network with other learners taking this course and get support. ## π Building a Startup? Sign up for Microsoft for Startups Founders Hub to receive **free OpenAI credits** and up to **$150k towards Azure credits to access OpenAI models through Azure OpenAI Services**. ## π Want to help? Do you have suggestions or found spelling or code errors? Raise an issue or Create a pull request ## π Each lesson includes: * A short video introduction to the topic * A written lesson located in the README * Python and TypeScript code samples supporting Azure OpenAI and OpenAI API * Links to extra resources to continue your learning ## ποΈ Lessons | | Lesson Link | Description | Additional Learning | | :-: | :------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------: | ------------------------------------------------------------------------------ | | 00 | Course Setup | **Learn:** How to Setup Your Development Environment | Learn More | | 01 | Introduction to Generative AI and LLMs | **Learn:** Understanding what Generative AI is and how Large Language Models (LLMs) work. | Learn More | | 02 | Exploring and comparing different LLMs | **Learn:** How to select the right model for your use case | Learn More | | 03 | Using Generative AI Responsibly | **Learn:** How to build Generative AI Applications responsibly | Learn More | | 04 | Understanding Prompt Engineering Fundamentals | **Learn:** Hands-on Prompt Engineering Best Practices | Learn More | | 05 | Creating Advanced Prompts | **Learn:** How to apply prompt engineering techniques that improve the outcome of your prompts. | Learn More | | 06 | Building Text Generation Applications | **Build:** A text generation app using Azure OpenAI | Learn More | | 07 | Building Chat Applications | **Build:** Techniques for efficiently building and integrating chat applications. | Learn More | | 08 | Building Search Apps Vector Databases | **Build:** A search application that uses Embeddings to search for data. | Learn More | | 09 | Building Image Generation Applications | **Build:** A image generation application | Learn More | | 10 | Building Low Code AI Applications | **Build:** A Generative AI application using Low Code tools | Learn More | | 11 | Integrating External Applications with Function Calling | **Build:** What is function calling and its use cases for applications | Learn More | | 12 | Designing UX for AI Applications | **Learn:** How to apply UX design principles when developing Generative AI Applications | Learn More | | 13 | Securing Your Generative AI Applications | **Learn:** The threats and risks to AI systems and methods to secure these systems. | Learn More | | 14 | The Generative AI Application Lifecycle | **Learn:** The tools and metrics to manage the LLM Lifecycle and LLMOps | Learn More | | 15 | Retrieval Augmented Generation (RAG) and Vector Databases | **Build:** An application using a RAG Framework to retrieve embeddings from a Vector Databases | Learn More | | 16 | Open Source Models and Hugging Face | **Build:** An application using open source models available on Hugging Face | Learn More | | 17 | AI Agents | **Build:** An application using an AI Agent Framework | Learn More | | 18 | Fine-Tuning LLMs | **Learn:** The what, why and how of fine-tuning LLMs | Learn More |
cog-comfyui
Cog-comfyui allows users to run ComfyUI workflows on Replicate. ComfyUI is a visual programming tool for creating and sharing generative art workflows. With cog-comfyui, users can access a variety of pre-trained models and custom nodes to create their own unique artworks. The tool is easy to use and does not require any coding experience. Users simply need to upload their API JSON file and any necessary input files, and then click the "Run" button. Cog-comfyui will then generate the output image or video file.
ai-notes
Notes on AI state of the art, with a focus on generative and large language models. These are the "raw materials" for the https://lspace.swyx.io/ newsletter. This repo used to be called https://github.com/sw-yx/prompt-eng, but was renamed because Prompt Engineering is Overhyped. This is now an AI Engineering notes repo.
For similar jobs
sweep
Sweep is an AI junior developer that turns bugs and feature requests into code changes. It automatically handles developer experience improvements like adding type hints and improving test coverage.
teams-ai
The Teams AI Library is a software development kit (SDK) that helps developers create bots that can interact with Teams and Microsoft 365 applications. It is built on top of the Bot Framework SDK and simplifies the process of developing bots that interact with Teams' artificial intelligence capabilities. The SDK is available for JavaScript/TypeScript, .NET, and Python.
ai-guide
This guide is dedicated to Large Language Models (LLMs) that you can run on your home computer. It assumes your PC is a lower-end, non-gaming setup.
classifai
Supercharge WordPress Content Workflows and Engagement with Artificial Intelligence. Tap into leading cloud-based services like OpenAI, Microsoft Azure AI, Google Gemini and IBM Watson to augment your WordPress-powered websites. Publish content faster while improving SEO performance and increasing audience engagement. ClassifAI integrates Artificial Intelligence and Machine Learning technologies to lighten your workload and eliminate tedious tasks, giving you more time to create original content that matters.
chatbot-ui
Chatbot UI is an open-source AI chat app that allows users to create and deploy their own AI chatbots. It is easy to use and can be customized to fit any need. Chatbot UI is perfect for businesses, developers, and anyone who wants to create a chatbot.
BricksLLM
BricksLLM is a cloud native AI gateway written in Go. Currently, it provides native support for OpenAI, Anthropic, Azure OpenAI and vLLM. BricksLLM aims to provide enterprise level infrastructure that can power any LLM production use cases. Here are some use cases for BricksLLM: * Set LLM usage limits for users on different pricing tiers * Track LLM usage on a per user and per organization basis * Block or redact requests containing PIIs * Improve LLM reliability with failovers, retries and caching * Distribute API keys with rate limits and cost limits for internal development/production use cases * Distribute API keys with rate limits and cost limits for students
uAgents
uAgents is a Python library developed by Fetch.ai that allows for the creation of autonomous AI agents. These agents can perform various tasks on a schedule or take action on various events. uAgents are easy to create and manage, and they are connected to a fast-growing network of other uAgents. They are also secure, with cryptographically secured messages and wallets.
griptape
Griptape is a modular Python framework for building AI-powered applications that securely connect to your enterprise data and APIs. It offers developers the ability to maintain control and flexibility at every step. Griptape's core components include Structures (Agents, Pipelines, and Workflows), Tasks, Tools, Memory (Conversation Memory, Task Memory, and Meta Memory), Drivers (Prompt and Embedding Drivers, Vector Store Drivers, Image Generation Drivers, Image Query Drivers, SQL Drivers, Web Scraper Drivers, and Conversation Memory Drivers), Engines (Query Engines, Extraction Engines, Summary Engines, Image Generation Engines, and Image Query Engines), and additional components (Rulesets, Loaders, Artifacts, Chunkers, and Tokenizers). Griptape enables developers to create AI-powered applications with ease and efficiency.