diff --git a/.github/workflows/release_and_push.yml b/.github/workflows/release_and_push.yml index c522762..10cf493 100644 --- a/.github/workflows/release_and_push.yml +++ b/.github/workflows/release_and_push.yml @@ -60,13 +60,6 @@ jobs: - name: Build artifact run: mvn clean package -DskipTests - - - name: Create Release - uses: ncipollo/release-action@v1.12.0 - with: - allowUpdates: true - artifacts: ${{ github.workspace }}/target/*.jar - token: ${{ secrets.GITHUB_TOKEN }} - name: Publish to the Maven Central Repository run: mvn --no-transfer-progress deploy diff --git a/README.md b/README.md index c8cfc51..3cf9603 100644 --- a/README.md +++ b/README.md @@ -14,28 +14,38 @@ ### Integration -#### Maven: - -```xml - - - io.github.artemnefedov - javaai - 0.3.4 - -``` - -#### Gradle: - -```groovy -implementation group: 'io.github.artemnefedov', name: 'javaai', version: '0.3.4' -``` +>#### _Maven_ +> +>```xml +> +> io.github.artemnefedov +> javaai +> 0.3.5 +> +>``` +> ___ +>#### _Gradle_ +> +>```groovy +>implementation 'io.github.artemnefedov:javaai:0.3.5' +>``` ### Initialize JavaAI -```java -JavaAI javaAI = javaAiBuilder("YOUR_API-KEY"); -``` +> You can pass your API-Key in java code +>```java +>JavaAI javaAI = javaAiBuilder("YOUR_API-KEY"); +>``` +> ___ +> +> Or paste it into the api-key field in the _**javaai.yaml**_, everyone loves yaml +>```yaml +>openai: +> api-key: "YOUR_API-KEY" +>``` +>```java +>JavaAI javaAI = javaAiBuilder(); +>``` ## Java AI example @@ -45,51 +55,64 @@ JavaAI javaAI = javaAiBuilder("YOUR_API-KEY"); You can make a first request using List to set the context and get a response, and after that use a string.
Both options retain the message history.
The "**assistant**" role is used by default for answers, be careful. - -```java -var messages=List.of( - new ChatMessage("user","Hello!"), - new ChatMessage("assistant","Hello! How can I assist you today?")); - -String chatResponse = javaAI.chat(messages); -``` -#### _OR_ -```java -javaAI.chat("What's 2 2?"); // answer: 2 + 2 equals 4. -javaAI.chat("What did I ask in the last question?"); //answer: In your last question, you asked "What's 2 2?" -``` - -### Completions -```java -//Text generation, the model will return the response as a String -String response = javaAI.generateText("Say this is a test"); -``` - +>```java +>var messages = List.of( +> new ChatMessage("user","Hello!"), +> new ChatMessage("assistant","Hello! How can I assist you today?")); +> +>String chatResponse = javaAI.chat(messages); +>``` +>#### _OR_ +>```java +>javaAI.chat("What's 2 2?"); +>javaAI.chat("What did I ask in the last question?"); +>``` +> > **user:** What's 2 2?
+> > **assistant:** 2 + 2 equals 4
+> > **user**: What did I ask in the last question?
+> > **assistant**: In your last question, you asked "What's 2 2?"
+--- ### DALLĀ·E 2 -```java -//Image generation, the model will return a URL/ to the result, as a List of String -String imgUrl=javaAI.generateImage("A cute baby sea otter"); -``` - +>Image generation, the model will return a URL to the result, as a List of String +>```java +>String imgUrl = javaAI.generateImage("cat sitting next to a cup of coffee"); +>``` +> ![cat_image](https://github.com/artemnefedov/JavaAI/blob/resource/img/cat_%20of_coffee.png?raw=true) +--- +### Completions +>Text generation, the model will return the response as a String +>```java +>String response = javaAI.generateText("Say this is a test"); +>``` --- - **Notice:** > You can always set your parameters for the models Example for Chat: - -```java -javaAI.setChat( - Chat.builder() - .messages(new ArrayList<>()) - .model("gpt-3.5-turbo") - .maxTokens(2000) - .n(1) - .build() - ); -``` - +> _In java code_ +>```java +>javaAI.setChat( +> Chat.builder() +> .messages(new ArrayList<>()) +> .model("gpt-3.5-turbo") +> .maxTokens(2000) +> .n(1) +> .build() +> ); +>``` +> _or in **javaai.yaml**_ +> ```yaml +> chat: +> model: gpt-3.5-turbo +> temperature: 0.9 +> top_p: 1 +> n: 1 +> stream: false +> stop: \n +> max_tokens: 2000 +> user: +> ``` --- ## Models that JavaAI works with: @@ -99,14 +122,6 @@ javaAI.setChat( 3. [x] [Create image](https://platform.openai.com/docs/api-reference/images/create) --- - -## Outside Dependencies. - -* [Gson](https://github.com/google/gson) -* [lombok](https://github.com/projectlombok/lombok) -* [junit](https://github.com/junit-team/junit5) -* [logback-classic](https://mvnrepository.com/artifact/ch.qos.logback/logback-classic) - ## License #### Distributed under the [MIT License](./LICENSE)