Skip to content

Commit

Permalink
Kotlin code conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
morisil committed Jan 8, 2025
1 parent 2c28a5d commit 285a939
Show file tree
Hide file tree
Showing 24 changed files with 1,890 additions and 1,854 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/build-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ jobs:
build_branch:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4.2.2
- name: Checkout sources
uses: actions/checkout@v4.2.2

- name: Setup Java
uses: actions/setup-java@v4.6.0
with:
distribution: 'temurin'
java-version: 23
- name: Setup Java
uses: actions/setup-java@v4.6.0
with:
distribution: 'temurin'
java-version: 23

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4.2.2
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4.2.2

- name: Build
run: ./gradlew build
- name: Build
run: ./gradlew build
28 changes: 14 additions & 14 deletions .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ jobs:
build_main:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4.2.2
- name: Checkout sources
uses: actions/checkout@v4.2.2

- name: Setup Java
uses: actions/setup-java@v4.6.0
with:
distribution: 'temurin'
java-version: 23
- name: Setup Java
uses: actions/setup-java@v4.6.0
with:
distribution: 'temurin'
java-version: 23

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4.2.2
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4.2.2

- name: Build
run: ./gradlew build sourcesJar dokkaGeneratePublicationHtml publish
env:
ORG_GRADLE_PROJECT_githubActor: ${{ secrets.GITHUBACTOR }}
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUBTOKEN }}
- name: Build
run: ./gradlew build sourcesJar dokkaGeneratePublicationHtml publish
env:
ORG_GRADLE_PROJECT_githubActor: ${{ secrets.GITHUBACTOR }}
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUBTOKEN }}
80 changes: 40 additions & 40 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build release
on:
release:
types: [published]
types: [ published ]
jobs:
build_release:
runs-on: ubuntu-latest
Expand All @@ -10,49 +10,49 @@ jobs:
# added or changed files to the repository.
contents: write
steps:
- name: Write release version
run: |
VERSION=${GITHUB_REF_NAME#v}
echo Version: $VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Write release version
run: |
VERSION=${GITHUB_REF_NAME#v}
echo Version: $VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Checkout sources
uses: actions/checkout@v4.2.2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Checkout sources
uses: actions/checkout@v4.2.2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v4.6.0
with:
distribution: 'temurin'
java-version: 23
- name: Setup Java
uses: actions/setup-java@v4.6.0
with:
distribution: 'temurin'
java-version: 23

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4.2.2
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4.2.2

- name: Build
env:
ORG_GRADLE_PROJECT_githubActor: ${{ secrets.GITHUBACTOR }}
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUBTOKEN }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUser: ${{ secrets.SONATYPE_USER }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: ./gradlew -Pversion=$VERSION build sourcesJar dokkaGeneratePublicationHtml publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Build
env:
ORG_GRADLE_PROJECT_githubActor: ${{ secrets.GITHUBACTOR }}
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUBTOKEN }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUser: ${{ secrets.SONATYPE_USER }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: ./gradlew -Pversion=$VERSION build sourcesJar dokkaGeneratePublicationHtml publishToSonatype closeAndReleaseSonatypeStagingRepository

- name: Checkout main branch
uses: actions/checkout@v4.2.2
with:
ref: main
fetch-depth: 0
- name: Checkout main branch
uses: actions/checkout@v4.2.2
with:
ref: main
fetch-depth: 0

- name: Update README
run: sh .github/scripts/update-readme-version.sh
- name: Update README
run: sh .github/scripts/update-readme-version.sh

- name: Commit README
uses: stefanzweifel/git-auto-commit-action@v5.0.1
with:
commit_message: Dependency version in README.md updated to ${{ env.VERSION }}
file_pattern: 'README.md'
- name: Commit README
uses: stefanzweifel/git-auto-commit-action@v5.0.1
with:
commit_message: Dependency version in README.md updated to ${{ env.VERSION }}
file_pattern: 'README.md'
2 changes: 1 addition & 1 deletion .github/workflows/updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: GitHub Actions Version Updater
on:
schedule:
# Automatically run on every Sunday
- cron: '0 0 * * 0'
- cron: '0 0 * * 0'

jobs:
build:
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This library was created to fulfill the need of agentic AI projects created by
[xemantic](https://xemantic.com/). In particular:

* [anthropic-sdk-kotlin](https://github.com/xemantic/anthropic-sdk-kotlin) - an unofficial Kotlin multiplatform variant
of [Anthropic SDK](https://docs.anthropic.com/en/api/client-sdks).
of [Anthropic SDK](https://docs.anthropic.com/en/api/client-sdks).
* [claudine](https://github.com/xemantic/claudine) - AI Agent build on top of this SDK.

These projects are heavily dependent on
Expand Down Expand Up @@ -58,13 +58,13 @@ In `build.gradle.kts` add:

```kotlin
plugins {
kotlin("multiplatform") version "2.1.0" // (or jvm for jvm-only project)
kotlin("plugin.serialization") version "2.1.0"
kotlin("multiplatform") version "2.1.0" // (or jvm for jvm-only project)
kotlin("plugin.serialization") version "2.1.0"
}

// ...
dependencies {
implementation("com.xemantic.ai:xemantic-ai-tool-schema:0.1.4")
implementation("com.xemantic.ai:xemantic-ai-tool-schema:0.1.4")
}
```

Expand All @@ -76,16 +76,16 @@ Then in your code you can define entities like this:
@Title("The full address")
@Description("An address of a person or an organization")
data class Address(
val street: String,
val city: String,
@Description("A postal code not limited to particular country")
@MinLength(3)
@MaxLength(10)
val postalCode: String,
@Pattern("[a-z]{2}")
val countryCode: String,
@Format(StringFormat.EMAIL)
val email: String? = null
val street: String,
val city: String,
@Description("A postal code not limited to particular country")
@MinLength(3)
@MaxLength(10)
val postalCode: String,
@Pattern("[a-z]{2}")
val countryCode: String,
@Format(StringFormat.EMAIL)
val email: String? = null
)
```

Expand Down Expand Up @@ -138,7 +138,7 @@ And this is the input accepted by Large Language Model APIs like
[OpenAI API](https://platform.openai.com/docs/api-reference/introduction)
and [Anthropic API](https://docs.anthropic.com/en/api/getting-started). When requesting a tool use, these LLMs
will send a JSON payload adhering to this schema, therefore
immediately deserializable as the original `@Serializable` Kotlin class.
immediately deserializable as the original `@Serializable` Kotlin class.

More details and use cases in the [JsonSchemaGeneratorTest](src/commonTest/kotlin/generator/JsonSchemaGeneratorTest.kt).

Expand Down Expand Up @@ -171,7 +171,7 @@ Clone this repo and then in the project dir:
./gradlew build
```

## Non-recommended usage
## Non-recommended usage

> [!WARNING]
> Even though this library provides basic serializable representation of a JSON Schema, it is not
Expand Down
Loading

0 comments on commit 285a939

Please sign in to comment.