
Java inteligente (IntelliJava) es la mejor herramienta para integrarse con los últimos modelos de idiomas y los marcos de aprendizaje profundo que usan Java. La biblioteca proporciona funciones intuitivas para enviar información a modelos como ChatGPT y Dall, y recibir texto, habla o imágenes generados. Con solo unas pocas líneas de código, puede acceder fácilmente a la potencia de los modelos AI de vanguardia para mejorar sus proyectos.
Los modelos compatibles:
RemoteLanguageModel para los modelos de idiomas, RemoteImageModel para la generación de imágenes, RemoteSpeechModel para modelos de texto a discurso y Chatbot para chatgpt. El paquete lanzado a 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")
Descarga de jar: IntelliJava.jar.
Código de modelo de idioma (2 pasos):
// 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 ); Salida: 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 generación de imágenes (2 pasos):
// 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 ); Producción: 
Código de texto a voz (2 pasos):
// 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 ); Producción:
// save temporary audio file for testing
AudioHelper . saveTempAudio ( decodedAudio );Código de 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 ); Salida: The average distance between the Moon and the Earth is about 238,855 miles (384,400 kilometers).
Para ejemplos completos e integración lista, pruebe el sample_code.
Las únicas dependencias son GSON . Requerido para agregar manualmente cuando se usa el frasco IntelliJava. Sin embargo, si importó este repositorio a través de Maven, manejará las dependencias.
Para la descarga de jar: GSson Descargar Repo
Llame a los contribuyentes:
Licencia de apache
Copyright 2023 github.com/barqawiz/intellijava
Licenciado bajo la licencia Apache, versión 2.0 (la "licencia"); No puede usar este archivo, excepto de conformidad con la licencia. Puede obtener una copia de la licencia en
http://www.apache.org/licenses/LICENSE-2.0
A menos que la ley aplicable sea requerida o acordado por escrito, el software distribuido bajo la licencia se distribuye de manera "como es", sin garantías o condiciones de ningún tipo, ya sea expresas o implícitas. Consulte la licencia para los permisos y limitaciones de rigor de idioma específico bajo la licencia.