Skip to content

Commit f4eff2f

Browse files
committed
updates comments, maven deployment details, update version format
- add comments to all functions. - update the project to prepare for maven repo deployment. - update the version format from x.x to x.x.x
1 parent b456b96 commit f4eff2f

File tree

13 files changed

+466
-75
lines changed

13 files changed

+466
-75
lines changed

core/com.intellijava.core/pom.xml

Lines changed: 90 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,53 @@
66

77
<groupId>com.intellijava</groupId>
88
<artifactId>com.intellijava.core</artifactId>
9-
<version>0.3</version>
9+
<version>0.3.1</version>
1010

11-
<name>com.intellijava.core</name>
11+
<name>Intellijava</name>
12+
<description>IntelliJava allows java developers to easily integrate with the latest language models, image generation, and deep learning frameworks.</description>
1213
<url>https://github.com/Barqawiz/IntelliJava</url>
1314

15+
<licenses>
16+
<license>
17+
<name>The Apache License, Version 2.0</name>
18+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
19+
</license>
20+
</licenses>
21+
22+
<developers>
23+
<developer>
24+
<name>Ahmad Albarqawi</name>
25+
<email>iamspacecome@gmail.com</email>
26+
<organization>AhmadAI labs</organization>
27+
<organizationUrl>http://www.ahmadai.com</organizationUrl>
28+
</developer>
29+
</developers>
30+
31+
<scm>
32+
<connection>scm:git:git://github.com/Barqawiz/IntelliJava.git</connection>
33+
<developerConnection>scm:git:ssh://github.com:Barqawiz/IntelliJava.git</developerConnection>
34+
<url>https://github.com/Barqawiz/IntelliJava</url>
35+
</scm>
36+
1437
<properties>
1538
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1639
<maven.compiler.source>11</maven.compiler.source>
1740
<maven.compiler.target>11</maven.compiler.target>
1841
</properties>
1942

2043
<distributionManagement>
21-
<repository>
44+
<!--<repository>
2245
<id>github</id>
2346
<name>GitHub Apache Maven Packages</name>
2447
<url>https://maven.pkg.github.com/Barqawiz/IntelliJava</url>
48+
</repository>-->
49+
<snapshotRepository>
50+
<id>ossrh</id>
51+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
52+
</snapshotRepository>
53+
<repository>
54+
<id>ossrh</id>
55+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
2556
</repository>
2657
</distributionManagement>
2758

@@ -81,7 +112,62 @@
81112
<artifactId>maven-project-info-reports-plugin</artifactId>
82113
<version>3.0.0</version>
83114
</plugin>
84-
115+
<!-- maven publish plugin -->
116+
<plugin>
117+
<groupId>org.sonatype.plugins</groupId>
118+
<artifactId>nexus-staging-maven-plugin</artifactId>
119+
<version>1.6.7</version>
120+
<extensions>true</extensions>
121+
<configuration>
122+
<serverId>ossrh</serverId>
123+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
124+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
125+
</configuration>
126+
</plugin>
127+
<!-- java doc generation -->
128+
<plugin>
129+
<groupId>org.apache.maven.plugins</groupId>
130+
<artifactId>maven-source-plugin</artifactId>
131+
<version>2.2.1</version>
132+
<executions>
133+
<execution>
134+
<id>attach-sources</id>
135+
<goals>
136+
<goal>jar-no-fork</goal>
137+
</goals>
138+
</execution>
139+
</executions>
140+
</plugin>
141+
<plugin>
142+
<groupId>org.apache.maven.plugins</groupId>
143+
<artifactId>maven-javadoc-plugin</artifactId>
144+
<version>2.9.1</version>
145+
<executions>
146+
<execution>
147+
<id>attach-javadocs</id>
148+
<goals>
149+
<goal>jar</goal>
150+
</goals>
151+
</execution>
152+
</executions>
153+
</plugin>
154+
<!-- GPG Signed Components -->
155+
<!-- TODO: generate GPG keys and back to: https://central.sonatype.org/publish/publish-maven/ -->
156+
<!-- https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key -->
157+
<plugin>
158+
<groupId>org.apache.maven.plugins</groupId>
159+
<artifactId>maven-gpg-plugin</artifactId>
160+
<version>1.5</version>
161+
<executions>
162+
<execution>
163+
<id>sign-artifacts</id>
164+
<phase>verify</phase>
165+
<goals>
166+
<goal>sign</goal>
167+
</goals>
168+
</execution>
169+
</executions>
170+
</plugin>
85171
</plugins>
86172
</pluginManagement>
87173
</build>

core/com.intellijava.core/src/main/java/com/intellijava/com/intellijava/core/controller/RemoateImageModel.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,28 @@
2626

2727
/**
2828
*
29-
* @author github.com/Barqawiz
30-
*
31-
* A class to call the most sophisticated remote image models.
32-
*
33-
* This version support Openai GPT model only, with a plan to add more models in the future.
29+
* The RemoteImageModel class is used to generate images from text descriptions using an API key.
30+
* It currently supports OpenAI only.
31+
* The class uses the OpenAIWrapper to generate the images and returns a list of URLs for the generated images.
3432
*
33+
* @author github.com/Barqawiz
3534
*/
3635
public class RemoateImageModel {
3736

3837
private String keyType;
3938
private OpenAIWrapper openaiWrapper;
4039

4140
/**
41+
*
42+
* Constructor for creating a new RemoteImageModel object.
43+
*
44+
* Creates an instance of the class and sets up the API key and the key type.
4245
*
4346
* @param keyValue the API key.
4447
* @param keyType support openai only.
48+
*
49+
* @throws IllegalArgumentException if the keyType passed is not "openai".
50+
*
4551
*/
4652
public RemoateImageModel(String keyValue, String keyType) {
4753

@@ -56,13 +62,14 @@ public RemoateImageModel(String keyValue, String keyType) {
5662

5763
/**
5864
*
59-
* Generate images from any text description.
65+
* Generates images from a given text description.
6066
*
6167
* @param prompt text of the required action or the question.
6268
* @param numberOfImages number of the generated images.
63-
* @param imageSize 256x256, 512x512, or 1024x1024.
64-
* @return List of images URL.
65-
* @throws IOException
69+
* @param imageSize size of the generated images, options are: 256x256, 512x512, or 1024x1024.
70+
* @return list of URLs of the generated images
71+
* @throws IOException if there is a problem with the API connection
72+
*
6673
*/
6774
public List<String> generateImages(String prompt, int numberOfImages, String imageSize) throws IOException {
6875

@@ -75,12 +82,14 @@ public List<String> generateImages(String prompt, int numberOfImages, String ima
7582
}
7683

7784
/**
85+
*
86+
* Generates images from a given text description using OpenAI service.
7887
*
7988
* @param prompt text of the required action or the question.
8089
* @param numberOfImages number of the generated images.
81-
* @param imageSize 256x256, 512x512, or 1024x1024.
82-
* @return List of images URL.
83-
* @throws IOException
90+
* @param imageSize size of the generated images, options are: 256x256, 512x512, or 1024x1024.
91+
* @return list of URLs of the generated images
92+
* @throws IOException if there is a problem with the API connection
8493
*/
8594
private List<String> generateOpenaiImage(String prompt, int numberOfImages, String imageSize) throws IOException {
8695

core/com.intellijava.core/src/main/java/com/intellijava/com/intellijava/core/controller/RemoteLanguageModel.java

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,31 @@
2323
import com.intellijava.com.intellijava.core.wrappers.OpenAIWrapper;
2424

2525
/**
26-
*
27-
* @author github.com/Barqawiz
28-
*
2926
* A class to call the most sophisticated remote language models.
30-
*
31-
* This version support Openai GPT model only, with a plan to add more models in the future.
3227
*
28+
* This class provides an API for interacting with OpenAI's GPT-3 language model. It is designed to be easily extensible
29+
* to support other models in the future.
30+
*
31+
* @author github.com/Barqawiz
32+
*
3333
*/
3434
public class RemoteLanguageModel {
3535

3636
private String keyType;
3737
private OpenAIWrapper openaiWrapper;
3838

3939
/**
40-
*
41-
* @param keyValue the API key.
42-
* @param keyType support openai only.
43-
*/
40+
* Constructor for the RemoteLanguageModel class.
41+
*
42+
* Creates an instance of the class and sets up the API key and the key type.
43+
* Currently, only the "openai" key type is supported.
44+
*
45+
* @param keyValue the API key.
46+
* @param keyType support openai only.
47+
*
48+
* @throws IllegalArgumentException if the keyType passed is not "openai".
49+
*
50+
*/
4451
public RemoteLanguageModel(String keyValue, String keyType) {
4552

4653
if (keyType == "" || keyType == "openai") {
@@ -53,15 +60,19 @@ public RemoteLanguageModel(String keyValue, String keyType) {
5360

5461

5562
/**
56-
* Call a remote large model to generate any text based on the received prompt.
57-
*
58-
* @param model the model name. the largest openai model is text-davinci-002
59-
* @param prompt text of the required action or the question.
60-
* @param temperature higher values means more risks and creativity.
61-
* @param maxTokens maximum size of the model input and output.
62-
* @return string model response
63-
* @throws IOException
64-
*/
63+
* Call a remote large model to generate any text based on the received prompt.
64+
*
65+
* This method takes in a model name, prompt, temperature and maxTokens and generates text using the OpenAI GPT-3 model.
66+
*
67+
* @param model the model name. The largest OpenAI model is text-davinci-002
68+
* @param prompt text of the required action or the question.
69+
* @param temperature higher values means more risks and creativity.
70+
* @param maxTokens maximum size of the model input and output.
71+
* @return string model response.
72+
* @throws IOException if there is an error when connecting to the OpenAI API.
73+
* @throws IllegalArgumentException if the keyType passed in the constructor is not "openai".
74+
*
75+
*/
6576
public String generateText(String model, String prompt, float temperature, int maxTokens) throws IOException {
6677

6778
if (this.keyType == "openai") {
@@ -73,14 +84,16 @@ public String generateText(String model, String prompt, float temperature, int m
7384
}
7485

7586
/**
76-
*
77-
* @param model the model name, example: text-davinci-002. For more details about GPT3 models: https://beta.openai.com/docs/models/gpt-3
78-
* @param prompt text of the required action or the question.
79-
* @param temperature higher values means more risks and creativity.
80-
* @param maxTokens maximum size of the model input and output.
81-
* @return string model response.
82-
* @throws IOException
83-
*/
87+
* Private helper method for generating text from OpenAI GPT-3 model.
88+
*
89+
* @param model the model name, example: text-davinci-002. For more details about GPT-3 models, see: https://beta.openai.com/docs/models/gpt-3
90+
* @param prompt text of the required action or the question.
91+
* @param temperature higher values means more risks and creativity.
92+
* @param maxTokens maximum size of the model input and output.
93+
* @return string model response.
94+
* @throws IOException if there is an error when connecting to the OpenAI API.
95+
*
96+
*/
8497
private String generateOpenaiText(String model, String prompt, float temperature, int maxTokens) throws IOException {
8598

8699
Map<String, Object> params = new HashMap<>();

core/com.intellijava.core/src/main/java/com/intellijava/com/intellijava/core/model/BaseRemoteModel.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,30 @@
1515
*/
1616
package com.intellijava.com.intellijava.core.model;
1717

18+
19+
/**
20+
* BaseRemoteModel is an abstract class that represents a common model with a basic parameter, id.
21+
*
22+
* @author github.com/Barqawiz
23+
*/
1824
public abstract class BaseRemoteModel {
1925
private String id;
2026

27+
/**
28+
* Get the id of the model
29+
*
30+
* @return the id
31+
*/
2132
public String getId() {
2233
return id;
2334
}
2435

36+
37+
/**
38+
* Sets the id of the model
39+
*
40+
* @param id the id
41+
*/
2542
public void setId(String id) {
2643
this.id = id;
2744
}

core/com.intellijava.core/src/main/java/com/intellijava/com/intellijava/core/model/OpenaiImageResponse.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
import java.util.List;
44
import com.google.gson.annotations.SerializedName;
55

6+
/**
7+
* OpenaiImageResponse is a model class used to parse the response from the OpenAI image API.
8+
*
9+
* The class contains a nested call Data
10+
*
11+
* @author barqawi
12+
*/
613
public class OpenaiImageResponse extends BaseRemoteModel {
714

815

@@ -11,18 +18,37 @@ public class OpenaiImageResponse extends BaseRemoteModel {
1118

1219
private List<Data> data;
1320

21+
/**
22+
* A nested class that represents an image object returned in the API response.
23+
*/
1424
public static class Data {
1525
private String url;
1626

27+
/**
28+
* Gets the URL of the image
29+
*
30+
* @return the URL of the image
31+
*/
1732
public String getUrl() {
1833
return url;
1934
}
2035
}
2136

37+
38+
/**
39+
* Get the timestamp when the response was created
40+
*
41+
* @return the timestamp when the response was created
42+
*/
2243
public long getCreated() {
2344
return created;
2445
}
2546

47+
/**
48+
* Get the list of data objects contained in the API response
49+
*
50+
* @return the list of data objects contained in the API response
51+
*/
2652
public List<Data> getData() {
2753
return data;
2854
}

0 commit comments

Comments
 (0)