
O Intelligent Java (Intellijava) é a ferramenta final para se integrar aos modelos de idiomas mais recentes e estruturas de aprendizado profundo usando Java. A biblioteca fornece funções intuitivas para enviar informações para modelos como ChatGPT e Dall · e e receber texto gerado, fala ou imagens. Com apenas algumas linhas de código, você pode acessar facilmente o poder dos modelos de IA de ponta para aprimorar seus projetos.
Os modelos suportados:
RemoteLanguageModel para os modelos de idiomas, RemoteImageModel para geração de imagens, RemoteSpeechModel para modelos de texto para modelos de fala e Chatbot para chatgpt. O pacote lançado para o Maven Central Repository:
Maven:
< dependency >
< groupId >io.github.barqawiz</ groupId >
< artifactId >intellijava.core</ artifactId >
< version >0.8.2</ version >
</ dependency >Gradle:
implementation 'io.github.barqawiz:intellijava.core:0.8.2'
Gradle (Kotlin):
implementation("io.github.barqawiz:intellijava.core:0.8.2")
JAR Download: Intellijava.jar.
Código do modelo de idioma (2 etapas):
// 1- initiate the remote language model
String apiKey = "<add-openai-api-key>" ;
RemoteLanguageModel langModel = new RemoteLanguageModel ( apiKey , "openai" );
// 2- call generateText with any command !
LanguageModelInput langInput = new LanguageModelInput . Builder ( "Summarize the plot of the 'Inception' movie in two sentences" )
. setModel ( "text-davinci-003" ). setTemperature ( 0.7f ). setMaxTokens ( 50 ). build ();
String resValue = langModel . generateText ( langInput ); Saída: Inception follows Dom Cobb, a professional thief, who is offered a chance at redemption in exchange for planting an idea in a target's mind. He must navigate a dangerous landscape of dream-sharing technology and battle his inner demons in order to complete the mission and find his way back to reality.
Código de geração de imagem (2 etapas):
// 1- initiate the remote image model
RemoteImageModel imageModel = new RemoteImageModel ( apiKey , "openai" );
// 2- call generateImages with any command !
ImageModelInput imageInput = new ImageModelInput . Builder ( "teddy writing a blog in times square" )
. setNumberOfImages ( 2 ). setImageSize ( "1024x1024" ). build ();
List < String > images = imageModel . generateImages ( imageInput ); Saída: 
Texto para o código de fala (2 etapas):
// 1- initiate the remote speech model
RemoteSpeechModel model = new RemoteSpeechModel ( apiKey , SpeechModels . google );
// 2- call generateEnglishText with any text
Text2SpeechInput input = new Text2SpeechInput . Builder ( "Hi, I am Intelligent Java." ). build ();
byte [] decodedAudio = model . generateEnglishText ( input ); Saída:
// save temporary audio file for testing
AudioHelper . saveTempAudio ( decodedAudio );Código ChatGPT :
// 1- initiate the chat model.
Chatbot bot = new Chatbot ( apiKey , SupportedChatModels . openai );
// 2- prepare the chat history by calling addMessage.
String mode = "You are a helpful astronomy assistant." ;
ChatModelInput input = new ChatGPTInput . Builder ( mode )
. addUserMessage ( "what is the space between moon and earth" ). build ();
// 3- call chat!
List < String > resValues = bot . chat ( input ); SAÍDA: The average distance between the Moon and the Earth is about 238,855 miles (384,400 kilometers).
Para exemplos completos e integração pronta, experimente o sample_code.
As únicas dependências são GSON . Necessário para adicionar manualmente ao usar o Jar Intellijava. No entanto, se você importou esse repositório através do Maven, ele lidará com as dependências.
Para download de jar: download do GSON Repo
Ligue para os colaboradores:
Licença Apache
Copyright 2023 github.com/barqawiz/intellijava
Licenciado sob a licença Apache, versão 2.0 (a "licença"); Você não pode usar esse arquivo, exceto em conformidade com a licença. Você pode obter uma cópia da licença em
http://www.apache.org/licenses/LICENSE-2.0
A menos que exigido pela lei aplicável ou acordada por escrito, o software distribuído pela licença é distribuído "como está", sem garantias ou condições de qualquer tipo, expressa ou implícita. Consulte a licença para o idioma específico que rege as permissões e limitações sob a licença.