|
1 | | -# IntelliJava-OpenaiAPI |
2 | | -*IntelliJava V0.3* |
| 1 | +# Intelligent Java |
| 2 | +*IntelliJava V0.6.0* |
3 | 3 |
|
4 | | -IntelliJava allows java developers to easily integrate with the latest language models and deep learning frameworks using few lines of java code. |
5 | | -The first version supports only Openai APIs. It provides a simple and intuitive API with convenient methods for sending text input to models like (GPT-3 and DALL·E) and receiving generated text or images in return. |
| 4 | +Intelligent java (IntelliJava) is the ultimate tool for Java developers looking to integrate with the latest language models and deep learning frameworks. The library provides a simple and intuitive API with convenient methods for sending text input to models like GPT-3 and DALL·E, and receiving generated text or images in return. With just a few lines of code, you can easily access the power of cutting-edge AI models to enhance your projects. |
6 | 5 |
|
| 6 | +The supported models: |
| 7 | +- **OpenAI**: Access GPT-3 to generate text and DALL·E to generate images. OpenAI is preferred when you want quality results without tuning. |
| 8 | +- **Cohere.ai**: Generate text; Cohere allows you to generate your language model to suit your specific needs. |
7 | 9 |
|
8 | 10 | # How to use |
9 | | -1. Import the core jar file to your project or add the maven package (check Integration section). |
10 | | -2. Add gson dependency using maven or the jar file (check dependencies section). |
11 | | -3. Call the ``RemoteLanguageModel`` for the language model and ``RemoateImageModel`` for image generation. |
| 11 | + |
| 12 | +1. Import the core jar file OR maven dependency (check the Integration section). |
| 13 | +2. Add Gson dependency if using the jar file; otherwise, it's handled by maven or Gradle. |
| 14 | +3. Call the ``RemoteLanguageModel`` for the language models and ``RemoateImageModel`` for image generation. |
12 | 15 |
|
13 | 16 | ## Integration |
| 17 | +The package released to [Maven Central Repository](https://central.sonatype.dev/artifact/io.github.barqawiz/intellijava.core/0.6.0). |
14 | 18 |
|
15 | | -For jar integration download: |
16 | | -[intellijava.jar](https://insta-answer-public.s3.amazonaws.com/opensource/IntelliJava/version0.3/com.intellijava.core-0.3.jar). |
| 19 | +Maven: |
| 20 | +```xml |
| 21 | +<dependency> |
| 22 | + <groupId>io.github.barqawiz</groupId> |
| 23 | + <artifactId>intellijava.core</artifactId> |
| 24 | + <version>0.6.0</version> |
| 25 | +</dependency> |
| 26 | +``` |
17 | 27 |
|
18 | | -For maven: |
19 | | -[Add github dependency package](https://github.com/Barqawiz/IntelliJava/packages/1767035). |
| 28 | +Gradle: |
| 29 | + |
| 30 | +``` |
| 31 | +implementation group: 'io.github.barqawiz', name: 'intellijava.core', version: '0.6.0' |
| 32 | +``` |
| 33 | + |
| 34 | +Gradle(Kotlin): |
| 35 | +``` |
| 36 | +implementation("io.github.barqawiz:intellijava.core:0.6.0") |
| 37 | +``` |
| 38 | + |
| 39 | +Jar download: |
| 40 | +[intellijava.jar](https://repo1.maven.org/maven2/io/github/barqawiz/intellijava.core/0.6.0/intellijava.core-0.6.0.jar). |
20 | 41 |
|
21 | 42 | For ready integration: try the sample_code. |
22 | 43 |
|
23 | 44 | ## Code Example |
24 | 45 | **Language model code** (2 steps): |
25 | | -``` |
26 | | -// 1- initiate the remote language model |
| 46 | +```java |
| 47 | +// 1- initiate the remote language model |
27 | 48 | String apiKey = "<add-openai-api-key>"; |
28 | 49 | RemoteLanguageModel langModel = new RemoteLanguageModel(apiKey, "openai"); |
29 | 50 |
|
30 | 51 | // 2- call generateText with any command ! |
31 | | -String command = "return a java code that says hello wrold"; |
32 | | -String resValue = langModel.generateText("text-davinci-002", command, 0.5F, 100); |
| 52 | +LanguageModelInput langInput = new LanguageModelInput.Builder("Summarize the plot of the 'Inception' movie in two sentences") |
| 53 | + .setModel("text-davinci-003").setTemperature(0.7f).setMaxTokens(50).build(); |
| 54 | +String resValue = langModel.generateText(langInput); |
33 | 55 | ``` |
34 | | -Output: |
35 | | -``` System.out.println("Hello, World!");```<br><br> |
| 56 | +Output:```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.``` |
| 57 | +<br><br> |
36 | 58 | **Image generation code** (2 steps): |
37 | | -``` |
38 | | -// 1- initiate the remote image model |
| 59 | +```java |
| 60 | +// 1- initiate the remote image model |
39 | 61 | RemoateImageModel imageModel = new RemoateImageModel(apiKey, "openai"); |
40 | 62 |
|
41 | 63 | // 2- call generateImages with any command ! |
42 | | -String prompt = "teddy writing a blog in times square"; |
43 | | -List<String> images = imageModel.generateImages(prompt, 2/*number of images*/, "1024x1024"); |
| 64 | +ImageModelInput imageInput = new ImageModelInput.Builder("teddy writing a blog in times square") |
| 65 | + .setNumberOfImages(2).setImageSize("1024x1024").build(); |
| 66 | +List<String> images = imageModel.generateImages(imageInput); |
44 | 67 | ``` |
45 | 68 | Output:<br> |
46 | | -<img src="images/response_image.png" height="250px"> |
| 69 | +<img src="images/response_image.png" height="220px"> |
47 | 70 |
|
48 | 71 | For full example check the code inside sample_code project. |
49 | 72 |
|
@@ -75,8 +98,10 @@ Call for contributors: |
75 | 98 | - [x] Add support to OpenAI Completion API. |
76 | 99 | - [x] Add support to OpenAI DALL·E 2. |
77 | 100 | - [ ] Add support to other OpenAI functions. |
| 101 | +- [x] Add support to cohere generate API. |
78 | 102 | - [ ] Add support to Google language models. |
79 | 103 | - [ ] Add support to Amazon language models. |
| 104 | +- [ ] Add support to Azure models. |
80 | 105 | - [ ] Add support to Midjourney image generation. |
81 | 106 |
|
82 | 107 |
|
|
0 commit comments