From 0cd448ab1ea6c8c4e0c0d611011b9014e496a5b3 Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Mon, 25 Dec 2023 11:55:37 +0200 Subject: [PATCH] Add GitHub workflow --- .github/workflows/build.yml | 22 +++++++++++++++++++ README.md | 2 +- .../com/stefanbratanov/chatjpt/ChatJPT.java | 12 +++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7e9e0f4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,22 @@ +name: build + +on: + push: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Build + run: ./gradlew spotlessCheck build + env: + OPENAI_API_KEY: {{ secrets.OPENAI_API_KEY }} \ No newline at end of file diff --git a/README.md b/README.md index 9a84125..d123a59 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,6 @@ ChatResponse response = chatClient.sendRequest(request); | [Models](https://platform.openai.com/docs/api-reference/models) | ✔️ | | [Moderations](https://platform.openai.com/docs/api-reference/moderations) | | -There are no plans to support the Beta APIs +There are no plans to support the Beta APIs. diff --git a/src/main/java/com/stefanbratanov/chatjpt/ChatJPT.java b/src/main/java/com/stefanbratanov/chatjpt/ChatJPT.java index 6d2a17c..5cdecfe 100644 --- a/src/main/java/com/stefanbratanov/chatjpt/ChatJPT.java +++ b/src/main/java/com/stefanbratanov/chatjpt/ChatJPT.java @@ -35,6 +35,9 @@ public ModelsClient newModelsClient() { return new ModelsClient(baseUrl, apiKey, organization, httpClient, objectMapper); } + /** + * @param apiKey the API key used for authentication + */ public static Builder newBuilder(String apiKey) { return new Builder(apiKey); } @@ -47,15 +50,22 @@ public static class Builder { private final String apiKey; private Optional organization = Optional.empty(); - public Builder(String apiKey) { + Builder(String apiKey) { this.apiKey = apiKey; } + /** + * @param baseUrl the url which exposes the OpenAI API + */ public Builder baseUrl(String baseUrl) { this.baseUrl = baseUrl; return this; } + /** + * @param organization for users who belong to multiple organizations specify which organization + * will be used for the API requests + */ public Builder organization(String organization) { this.organization = Optional.of(organization); return this;