diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml new file mode 100644 index 0000000..ccc3eaf --- /dev/null +++ b/.github/workflows/publish-sonatype.yml @@ -0,0 +1,39 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to Sonatype in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/OmniStack-sh/omnistack-kotlin/actions/workflows/publish-sonatype.yml +name: Publish Sonatype +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: | + 8 + 17 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Publish to Sonatype + run: | + ./gradlew --parallel --no-daemon publish + env: + SONATYPE_USERNAME: ${{ secrets.OMNISTACK_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.OMNISTACK_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + GPG_SIGNING_KEY_ID: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }} + GPG_SIGNING_KEY: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 0000000..fb9ce8a --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,25 @@ +name: Release Doctor +on: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'OmniStack-sh/omnistack-kotlin' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v4 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + SONATYPE_USERNAME: ${{ secrets.OMNISTACK_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.OMNISTACK_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + GPG_SIGNING_KEY_ID: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }} + GPG_SIGNING_KEY: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..c476280 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1-alpha.0" +} \ No newline at end of file diff --git a/README.md b/README.md index 0fb40b2..e9d142d 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ The REST API documentation can be foundĀ on [docs.omnistack.sh](https://docs.omn #### Gradle + + ```kotlin implementation("com.omnistack.api:omnistack-kotlin:0.0.1-alpha.0") ``` @@ -32,6 +34,8 @@ implementation("com.omnistack.api:omnistack-kotlin:0.0.1-alpha.0") ``` + + ### Configure the client Use `OmnistackOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()`: @@ -218,7 +222,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/omnistack-kotlin/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/OmniStack-sh/omnistack-kotlin/issues) with questions, bugs, or suggestions. ## Requirements diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 0000000..4c8289d --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${SONATYPE_USERNAME}" ]; then + errors+=("The OMNISTACK_SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${SONATYPE_PASSWORD}" ]; then + errors+=("The OMNISTACK_SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_KEY}" ]; then + errors+=("The OMNISTACK_SONATYPE_GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_PASSWORD}" ]; then + errors+=("The OMNISTACK_SONATYPE_GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/build.gradle.kts b/build.gradle.kts index 20f1dff..30069e7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { allprojects { group = "com.omnistack.api" - version = "0.0.1-alpha.0" + version = "0.0.1-alpha.0" // x-release-please-version } nexusPublishing { diff --git a/buildSrc/src/main/kotlin/omnistack.publish.gradle.kts b/buildSrc/src/main/kotlin/omnistack.publish.gradle.kts index 962da7a..11bcb64 100644 --- a/buildSrc/src/main/kotlin/omnistack.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/omnistack.publish.gradle.kts @@ -33,9 +33,9 @@ configure { } scm { - connection.set("scm:git:git://github.com/stainless-sdks/omnistack-kotlin.git") - developerConnection.set("scm:git:git://github.com/stainless-sdks/omnistack-kotlin.git") - url.set("https://github.com/stainless-sdks/omnistack-kotlin") + connection.set("scm:git:git://github.com/OmniStack-sh/omnistack-kotlin.git") + developerConnection.set("scm:git:git://github.com/OmniStack-sh/omnistack-kotlin.git") + url.set("https://github.com/OmniStack-sh/omnistack-kotlin") } versionMapping { diff --git a/omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/models/ChatCompletionCreateParams.kt b/omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/models/ChatCompletionCreateParams.kt index 19bc2d4..e76e34f 100644 --- a/omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/models/ChatCompletionCreateParams.kt +++ b/omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/models/ChatCompletionCreateParams.kt @@ -1153,7 +1153,7 @@ constructor( fun stop(string: String) = apply { this.stop = Stop.ofString(string) } /** Up to 4 sequences where the API will stop generating further tokens. */ - fun stop(strings: List) = apply { this.stop = Stop.ofStrings(strings) } + fun stopOfStrings(strings: List) = apply { this.stop = Stop.ofStrings(strings) } /** * If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as @@ -1726,8 +1726,8 @@ constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val string: String? = null, - private val chatCompletionRequestMessageContentPartTexts: + private val textContent: String? = null, + private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, @@ -1736,49 +1736,40 @@ constructor( private var validated: Boolean = false /** The contents of the system message. */ - fun string(): String? = string + fun textContent(): String? = textContent /** * An array of content parts with a defined type. For system messages, only type * `text` is supported. */ - fun chatCompletionRequestMessageContentPartTexts(): - List? = - chatCompletionRequestMessageContentPartTexts + fun arrayOfContentParts(): List? = + arrayOfContentParts - fun isString(): Boolean = string != null + fun isTextContent(): Boolean = textContent != null - fun isChatCompletionRequestMessageContentPartTexts(): Boolean = - chatCompletionRequestMessageContentPartTexts != null + fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null - fun asString(): String = string.getOrThrow("string") + fun asTextContent(): String = textContent.getOrThrow("textContent") - fun asChatCompletionRequestMessageContentPartTexts(): - List = - chatCompletionRequestMessageContentPartTexts.getOrThrow( - "chatCompletionRequestMessageContentPartTexts" - ) + fun asArrayOfContentParts(): List = + arrayOfContentParts.getOrThrow("arrayOfContentParts") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { return when { - string != null -> visitor.visitString(string) - chatCompletionRequestMessageContentPartTexts != null -> - visitor.visitChatCompletionRequestMessageContentPartTexts( - chatCompletionRequestMessageContentPartTexts - ) + textContent != null -> visitor.visitTextContent(textContent) + arrayOfContentParts != null -> + visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } } fun validate(): Content = apply { if (!validated) { - if ( - string == null && chatCompletionRequestMessageContentPartTexts == null - ) { + if (textContent == null && arrayOfContentParts == null) { throw OmnistackInvalidDataException("Unknown Content: $_json") } - chatCompletionRequestMessageContentPartTexts?.forEach { it.validate() } + arrayOfContentParts?.forEach { it.validate() } validated = true } } @@ -1788,18 +1779,18 @@ constructor( return true } - return /* spotless:off */ other is Content && this.string == other.string && this.chatCompletionRequestMessageContentPartTexts == other.chatCompletionRequestMessageContentPartTexts /* spotless:on */ + return /* spotless:off */ other is Content && this.textContent == other.textContent && this.arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, chatCompletionRequestMessageContentPartTexts) /* spotless:on */ + return /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ } override fun toString(): String { return when { - string != null -> "Content{string=$string}" - chatCompletionRequestMessageContentPartTexts != null -> - "Content{chatCompletionRequestMessageContentPartTexts=$chatCompletionRequestMessageContentPartTexts}" + textContent != null -> "Content{textContent=$textContent}" + arrayOfContentParts != null -> + "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -1807,25 +1798,19 @@ constructor( companion object { - fun ofString(string: String) = Content(string = string) + fun ofTextContent(textContent: String) = Content(textContent = textContent) - fun ofChatCompletionRequestMessageContentPartTexts( - chatCompletionRequestMessageContentPartTexts: - List - ) = - Content( - chatCompletionRequestMessageContentPartTexts = - chatCompletionRequestMessageContentPartTexts - ) + fun ofArrayOfContentParts( + arrayOfContentParts: List + ) = Content(arrayOfContentParts = arrayOfContentParts) } interface Visitor { - fun visitString(string: String): T + fun visitTextContent(textContent: String): T - fun visitChatCompletionRequestMessageContentPartTexts( - chatCompletionRequestMessageContentPartTexts: - List + fun visitArrayOfContentParts( + arrayOfContentParts: List ): T fun unknown(json: JsonValue?): T { @@ -1838,7 +1823,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Content { val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) + return Content(textContent = it, _json = json) } tryDeserialize( node, @@ -1847,10 +1832,7 @@ constructor( it.forEach { it.validate() } } ?.let { - return Content( - chatCompletionRequestMessageContentPartTexts = it, - _json = json - ) + return Content(arrayOfContentParts = it, _json = json) } return Content(_json = json) @@ -1865,11 +1847,9 @@ constructor( provider: SerializerProvider ) { when { - value.string != null -> generator.writeObject(value.string) - value.chatCompletionRequestMessageContentPartTexts != null -> - generator.writeObject( - value.chatCompletionRequestMessageContentPartTexts - ) + value.textContent != null -> generator.writeObject(value.textContent) + value.arrayOfContentParts != null -> + generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -2253,8 +2233,8 @@ constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val string: String? = null, - private val chatCompletionRequestUserMessageContentParts: + private val textContent: String? = null, + private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, @@ -2263,48 +2243,39 @@ constructor( private var validated: Boolean = false /** The text contents of the message. */ - fun string(): String? = string + fun textContent(): String? = textContent /** * An array of content parts with a defined type, each can be of type `text` or * `image_url` when passing in images. You can pass multiple images by adding * multiple `image_url` content parts. Image input is only supported when using the * `gpt-4o` model. */ - fun chatCompletionRequestUserMessageContentParts(): - List? = - chatCompletionRequestUserMessageContentParts + fun arrayOfContentParts(): List? = + arrayOfContentParts - fun isString(): Boolean = string != null + fun isTextContent(): Boolean = textContent != null - fun isChatCompletionRequestUserMessageContentParts(): Boolean = - chatCompletionRequestUserMessageContentParts != null + fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null - fun asString(): String = string.getOrThrow("string") + fun asTextContent(): String = textContent.getOrThrow("textContent") - fun asChatCompletionRequestUserMessageContentParts(): - List = - chatCompletionRequestUserMessageContentParts.getOrThrow( - "chatCompletionRequestUserMessageContentParts" - ) + fun asArrayOfContentParts(): List = + arrayOfContentParts.getOrThrow("arrayOfContentParts") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { return when { - string != null -> visitor.visitString(string) - chatCompletionRequestUserMessageContentParts != null -> - visitor.visitChatCompletionRequestUserMessageContentParts( - chatCompletionRequestUserMessageContentParts - ) + textContent != null -> visitor.visitTextContent(textContent) + arrayOfContentParts != null -> + visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } } fun validate(): Content = apply { if (!validated) { - if ( - string == null && chatCompletionRequestUserMessageContentParts == null - ) { + if (textContent == null && arrayOfContentParts == null) { throw OmnistackInvalidDataException("Unknown Content: $_json") } validated = true @@ -2316,18 +2287,18 @@ constructor( return true } - return /* spotless:off */ other is Content && this.string == other.string && this.chatCompletionRequestUserMessageContentParts == other.chatCompletionRequestUserMessageContentParts /* spotless:on */ + return /* spotless:off */ other is Content && this.textContent == other.textContent && this.arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, chatCompletionRequestUserMessageContentParts) /* spotless:on */ + return /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ } override fun toString(): String { return when { - string != null -> "Content{string=$string}" - chatCompletionRequestUserMessageContentParts != null -> - "Content{chatCompletionRequestUserMessageContentParts=$chatCompletionRequestUserMessageContentParts}" + textContent != null -> "Content{textContent=$textContent}" + arrayOfContentParts != null -> + "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -2335,25 +2306,19 @@ constructor( companion object { - fun ofString(string: String) = Content(string = string) + fun ofTextContent(textContent: String) = Content(textContent = textContent) - fun ofChatCompletionRequestUserMessageContentParts( - chatCompletionRequestUserMessageContentParts: - List - ) = - Content( - chatCompletionRequestUserMessageContentParts = - chatCompletionRequestUserMessageContentParts - ) + fun ofArrayOfContentParts( + arrayOfContentParts: List + ) = Content(arrayOfContentParts = arrayOfContentParts) } interface Visitor { - fun visitString(string: String): T + fun visitTextContent(textContent: String): T - fun visitChatCompletionRequestUserMessageContentParts( - chatCompletionRequestUserMessageContentParts: - List + fun visitArrayOfContentParts( + arrayOfContentParts: List ): T fun unknown(json: JsonValue?): T { @@ -2366,17 +2331,14 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Content { val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) + return Content(textContent = it, _json = json) } tryDeserialize( node, jacksonTypeRef>() ) ?.let { - return Content( - chatCompletionRequestUserMessageContentParts = it, - _json = json - ) + return Content(arrayOfContentParts = it, _json = json) } return Content(_json = json) @@ -2391,11 +2353,9 @@ constructor( provider: SerializerProvider ) { when { - value.string != null -> generator.writeObject(value.string) - value.chatCompletionRequestUserMessageContentParts != null -> - generator.writeObject( - value.chatCompletionRequestUserMessageContentParts - ) + value.textContent != null -> generator.writeObject(value.textContent) + value.arrayOfContentParts != null -> + generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -3501,8 +3461,8 @@ constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val string: String? = null, - private val chatCompletionRequestAssistantMessageContentParts: + private val textContent: String? = null, + private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, @@ -3511,47 +3471,38 @@ constructor( private var validated: Boolean = false /** The contents of the assistant message. */ - fun string(): String? = string + fun textContent(): String? = textContent /** * An array of content parts with a defined type. Can be one or more of type `text`, * or exactly one of type `refusal`. */ - fun chatCompletionRequestAssistantMessageContentParts(): - List? = - chatCompletionRequestAssistantMessageContentParts + fun arrayOfContentParts(): List? = + arrayOfContentParts - fun isString(): Boolean = string != null + fun isTextContent(): Boolean = textContent != null - fun isChatCompletionRequestAssistantMessageContentParts(): Boolean = - chatCompletionRequestAssistantMessageContentParts != null + fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null - fun asString(): String = string.getOrThrow("string") + fun asTextContent(): String = textContent.getOrThrow("textContent") - fun asChatCompletionRequestAssistantMessageContentParts(): + fun asArrayOfContentParts(): List = - chatCompletionRequestAssistantMessageContentParts.getOrThrow( - "chatCompletionRequestAssistantMessageContentParts" - ) + arrayOfContentParts.getOrThrow("arrayOfContentParts") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { return when { - string != null -> visitor.visitString(string) - chatCompletionRequestAssistantMessageContentParts != null -> - visitor.visitChatCompletionRequestAssistantMessageContentParts( - chatCompletionRequestAssistantMessageContentParts - ) + textContent != null -> visitor.visitTextContent(textContent) + arrayOfContentParts != null -> + visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } } fun validate(): Content = apply { if (!validated) { - if ( - string == null && - chatCompletionRequestAssistantMessageContentParts == null - ) { + if (textContent == null && arrayOfContentParts == null) { throw OmnistackInvalidDataException("Unknown Content: $_json") } validated = true @@ -3563,18 +3514,18 @@ constructor( return true } - return /* spotless:off */ other is Content && this.string == other.string && this.chatCompletionRequestAssistantMessageContentParts == other.chatCompletionRequestAssistantMessageContentParts /* spotless:on */ + return /* spotless:off */ other is Content && this.textContent == other.textContent && this.arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, chatCompletionRequestAssistantMessageContentParts) /* spotless:on */ + return /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ } override fun toString(): String { return when { - string != null -> "Content{string=$string}" - chatCompletionRequestAssistantMessageContentParts != null -> - "Content{chatCompletionRequestAssistantMessageContentParts=$chatCompletionRequestAssistantMessageContentParts}" + textContent != null -> "Content{textContent=$textContent}" + arrayOfContentParts != null -> + "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -3582,25 +3533,19 @@ constructor( companion object { - fun ofString(string: String) = Content(string = string) + fun ofTextContent(textContent: String) = Content(textContent = textContent) - fun ofChatCompletionRequestAssistantMessageContentParts( - chatCompletionRequestAssistantMessageContentParts: - List - ) = - Content( - chatCompletionRequestAssistantMessageContentParts = - chatCompletionRequestAssistantMessageContentParts - ) + fun ofArrayOfContentParts( + arrayOfContentParts: List + ) = Content(arrayOfContentParts = arrayOfContentParts) } interface Visitor { - fun visitString(string: String): T + fun visitTextContent(textContent: String): T - fun visitChatCompletionRequestAssistantMessageContentParts( - chatCompletionRequestAssistantMessageContentParts: - List + fun visitArrayOfContentParts( + arrayOfContentParts: List ): T fun unknown(json: JsonValue?): T { @@ -3613,7 +3558,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Content { val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) + return Content(textContent = it, _json = json) } tryDeserialize( node, @@ -3622,10 +3567,7 @@ constructor( >() ) ?.let { - return Content( - chatCompletionRequestAssistantMessageContentParts = it, - _json = json - ) + return Content(arrayOfContentParts = it, _json = json) } return Content(_json = json) @@ -3640,11 +3582,9 @@ constructor( provider: SerializerProvider ) { when { - value.string != null -> generator.writeObject(value.string) - value.chatCompletionRequestAssistantMessageContentParts != null -> - generator.writeObject( - value.chatCompletionRequestAssistantMessageContentParts - ) + value.textContent != null -> generator.writeObject(value.textContent) + value.arrayOfContentParts != null -> + generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -4821,8 +4761,8 @@ constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val string: String? = null, - private val chatCompletionRequestMessageContentPartTexts: + private val textContent: String? = null, + private val arrayOfContentParts: List? = null, private val _json: JsonValue? = null, @@ -4831,49 +4771,40 @@ constructor( private var validated: Boolean = false /** The contents of the tool message. */ - fun string(): String? = string + fun textContent(): String? = textContent /** * An array of content parts with a defined type. For tool messages, only type * `text` is supported. */ - fun chatCompletionRequestMessageContentPartTexts(): - List? = - chatCompletionRequestMessageContentPartTexts + fun arrayOfContentParts(): List? = + arrayOfContentParts - fun isString(): Boolean = string != null + fun isTextContent(): Boolean = textContent != null - fun isChatCompletionRequestMessageContentPartTexts(): Boolean = - chatCompletionRequestMessageContentPartTexts != null + fun isArrayOfContentParts(): Boolean = arrayOfContentParts != null - fun asString(): String = string.getOrThrow("string") + fun asTextContent(): String = textContent.getOrThrow("textContent") - fun asChatCompletionRequestMessageContentPartTexts(): - List = - chatCompletionRequestMessageContentPartTexts.getOrThrow( - "chatCompletionRequestMessageContentPartTexts" - ) + fun asArrayOfContentParts(): List = + arrayOfContentParts.getOrThrow("arrayOfContentParts") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { return when { - string != null -> visitor.visitString(string) - chatCompletionRequestMessageContentPartTexts != null -> - visitor.visitChatCompletionRequestMessageContentPartTexts( - chatCompletionRequestMessageContentPartTexts - ) + textContent != null -> visitor.visitTextContent(textContent) + arrayOfContentParts != null -> + visitor.visitArrayOfContentParts(arrayOfContentParts) else -> visitor.unknown(_json) } } fun validate(): Content = apply { if (!validated) { - if ( - string == null && chatCompletionRequestMessageContentPartTexts == null - ) { + if (textContent == null && arrayOfContentParts == null) { throw OmnistackInvalidDataException("Unknown Content: $_json") } - chatCompletionRequestMessageContentPartTexts?.forEach { it.validate() } + arrayOfContentParts?.forEach { it.validate() } validated = true } } @@ -4883,18 +4814,18 @@ constructor( return true } - return /* spotless:off */ other is Content && this.string == other.string && this.chatCompletionRequestMessageContentPartTexts == other.chatCompletionRequestMessageContentPartTexts /* spotless:on */ + return /* spotless:off */ other is Content && this.textContent == other.textContent && this.arrayOfContentParts == other.arrayOfContentParts /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, chatCompletionRequestMessageContentPartTexts) /* spotless:on */ + return /* spotless:off */ Objects.hash(textContent, arrayOfContentParts) /* spotless:on */ } override fun toString(): String { return when { - string != null -> "Content{string=$string}" - chatCompletionRequestMessageContentPartTexts != null -> - "Content{chatCompletionRequestMessageContentPartTexts=$chatCompletionRequestMessageContentPartTexts}" + textContent != null -> "Content{textContent=$textContent}" + arrayOfContentParts != null -> + "Content{arrayOfContentParts=$arrayOfContentParts}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -4902,25 +4833,19 @@ constructor( companion object { - fun ofString(string: String) = Content(string = string) + fun ofTextContent(textContent: String) = Content(textContent = textContent) - fun ofChatCompletionRequestMessageContentPartTexts( - chatCompletionRequestMessageContentPartTexts: - List - ) = - Content( - chatCompletionRequestMessageContentPartTexts = - chatCompletionRequestMessageContentPartTexts - ) + fun ofArrayOfContentParts( + arrayOfContentParts: List + ) = Content(arrayOfContentParts = arrayOfContentParts) } interface Visitor { - fun visitString(string: String): T + fun visitTextContent(textContent: String): T - fun visitChatCompletionRequestMessageContentPartTexts( - chatCompletionRequestMessageContentPartTexts: - List + fun visitArrayOfContentParts( + arrayOfContentParts: List ): T fun unknown(json: JsonValue?): T { @@ -4933,7 +4858,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Content { val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) + return Content(textContent = it, _json = json) } tryDeserialize( node, @@ -4942,10 +4867,7 @@ constructor( it.forEach { it.validate() } } ?.let { - return Content( - chatCompletionRequestMessageContentPartTexts = it, - _json = json - ) + return Content(arrayOfContentParts = it, _json = json) } return Content(_json = json) @@ -4960,11 +4882,9 @@ constructor( provider: SerializerProvider ) { when { - value.string != null -> generator.writeObject(value.string) - value.chatCompletionRequestMessageContentPartTexts != null -> - generator.writeObject( - value.chatCompletionRequestMessageContentPartTexts - ) + value.textContent != null -> generator.writeObject(value.textContent) + value.arrayOfContentParts != null -> + generator.writeObject(value.arrayOfContentParts) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } diff --git a/omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/models/CompletionCreateParams.kt b/omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/models/CompletionCreateParams.kt index 5796060..143c6fb 100644 --- a/omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/models/CompletionCreateParams.kt +++ b/omnistack-kotlin-core/src/main/kotlin/com/omnistack/api/models/CompletionCreateParams.kt @@ -705,7 +705,9 @@ constructor( * if a prompt is not specified the model will generate as if from the beginning of a new * document. */ - fun prompt(strings: List) = apply { this.prompt = Prompt.ofStrings(strings) } + fun promptOfStrings(strings: List) = apply { + this.prompt = Prompt.ofStrings(strings) + } /** * The prompt(s) to generate completions for, encoded as a string, array of strings, array @@ -715,7 +717,7 @@ constructor( * if a prompt is not specified the model will generate as if from the beginning of a new * document. */ - fun prompt(longs: List) = apply { this.prompt = Prompt.ofLongs(longs) } + fun promptOfLongs(longs: List) = apply { this.prompt = Prompt.ofLongs(longs) } /** * The prompt(s) to generate completions for, encoded as a string, array of strings, array @@ -725,7 +727,7 @@ constructor( * if a prompt is not specified the model will generate as if from the beginning of a new * document. */ - fun prompt(longs: List>) = apply { this.prompt = Prompt.ofLongs(longs) } + fun promptOfLists(lists: List>) = apply { this.prompt = Prompt.ofLists(lists) } /** * Generates `best_of` completions server-side and returns the "best" (the one with the @@ -836,7 +838,7 @@ constructor( * Up to 4 sequences where the API will stop generating further tokens. The returned text * will not contain the stop sequence. */ - fun stop(strings: List) = apply { this.stop = Stop.ofStrings(strings) } + fun stopOfStrings(strings: List) = apply { this.stop = Stop.ofStrings(strings) } /** * Whether to stream back partial progress. If set, tokens will be sent as data-only @@ -1145,7 +1147,7 @@ constructor( private val string: String? = null, private val strings: List? = null, private val longs: List? = null, - private val longs: List>? = null, + private val lists: List>? = null, private val _json: JsonValue? = null, ) { @@ -1157,7 +1159,7 @@ constructor( fun longs(): List? = longs - fun longs(): List>? = longs + fun lists(): List>? = lists fun isString(): Boolean = string != null @@ -1165,7 +1167,7 @@ constructor( fun isLongs(): Boolean = longs != null - fun isLongs(): Boolean = longs != null + fun isLists(): Boolean = lists != null fun asString(): String = string.getOrThrow("string") @@ -1173,7 +1175,7 @@ constructor( fun asLongs(): List = longs.getOrThrow("longs") - fun asLongs(): List> = longs.getOrThrow("longs") + fun asLists(): List> = lists.getOrThrow("lists") fun _json(): JsonValue? = _json @@ -1182,14 +1184,14 @@ constructor( string != null -> visitor.visitString(string) strings != null -> visitor.visitStrings(strings) longs != null -> visitor.visitLongs(longs) - longs != null -> visitor.visitLongs(longs) + lists != null -> visitor.visitLists(lists) else -> visitor.unknown(_json) } } fun validate(): Prompt = apply { if (!validated) { - if (string == null && strings == null && longs == null && longs == null) { + if (string == null && strings == null && longs == null && lists == null) { throw OmnistackInvalidDataException("Unknown Prompt: $_json") } validated = true @@ -1201,11 +1203,11 @@ constructor( return true } - return /* spotless:off */ other is Prompt && this.string == other.string && this.strings == other.strings && this.longs == other.longs && this.longs == other.longs /* spotless:on */ + return /* spotless:off */ other is Prompt && this.string == other.string && this.strings == other.strings && this.longs == other.longs && this.lists == other.lists /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings, longs, longs) /* spotless:on */ + return /* spotless:off */ Objects.hash(string, strings, longs, lists) /* spotless:on */ } override fun toString(): String { @@ -1213,7 +1215,7 @@ constructor( string != null -> "Prompt{string=$string}" strings != null -> "Prompt{strings=$strings}" longs != null -> "Prompt{longs=$longs}" - longs != null -> "Prompt{longs=$longs}" + lists != null -> "Prompt{lists=$lists}" _json != null -> "Prompt{_unknown=$_json}" else -> throw IllegalStateException("Invalid Prompt") } @@ -1227,7 +1229,7 @@ constructor( fun ofLongs(longs: List) = Prompt(longs = longs) - fun ofLongs(longs: List>) = Prompt(longs = longs) + fun ofLists(lists: List>) = Prompt(lists = lists) } interface Visitor { @@ -1238,7 +1240,7 @@ constructor( fun visitLongs(longs: List): T - fun visitLongs(longs: List>): T + fun visitLists(lists: List>): T fun unknown(json: JsonValue?): T { throw OmnistackInvalidDataException("Unknown Prompt: $json") @@ -1259,7 +1261,7 @@ constructor( return Prompt(longs = it, _json = json) } tryDeserialize(node, jacksonTypeRef>>())?.let { - return Prompt(longs = it, _json = json) + return Prompt(lists = it, _json = json) } return Prompt(_json = json) @@ -1277,7 +1279,7 @@ constructor( value.string != null -> generator.writeObject(value.string) value.strings != null -> generator.writeObject(value.strings) value.longs != null -> generator.writeObject(value.longs) - value.longs != null -> generator.writeObject(value.longs) + value.lists != null -> generator.writeObject(value.lists) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Prompt") } diff --git a/omnistack-kotlin-core/src/test/kotlin/com/omnistack/api/models/ChatCompletionCreateParamsTest.kt b/omnistack-kotlin-core/src/test/kotlin/com/omnistack/api/models/ChatCompletionCreateParamsTest.kt index 229bacf..0e2a293 100644 --- a/omnistack-kotlin-core/src/test/kotlin/com/omnistack/api/models/ChatCompletionCreateParamsTest.kt +++ b/omnistack-kotlin-core/src/test/kotlin/com/omnistack/api/models/ChatCompletionCreateParamsTest.kt @@ -20,7 +20,7 @@ class ChatCompletionCreateParamsTest { ChatCompletionCreateParams.Message .ChatCompletionRequestSystemMessage .Content - .ofString("string") + .ofTextContent("string") ) .role( ChatCompletionCreateParams.Message @@ -117,7 +117,7 @@ class ChatCompletionCreateParamsTest { ChatCompletionCreateParams.Message .ChatCompletionRequestSystemMessage .Content - .ofString("string") + .ofTextContent("string") ) .role( ChatCompletionCreateParams.Message @@ -213,7 +213,7 @@ class ChatCompletionCreateParamsTest { ChatCompletionCreateParams.Message .ChatCompletionRequestSystemMessage .Content - .ofString("string") + .ofTextContent("string") ) .role( ChatCompletionCreateParams.Message @@ -316,7 +316,7 @@ class ChatCompletionCreateParamsTest { ChatCompletionCreateParams.Message .ChatCompletionRequestSystemMessage .Content - .ofString("string") + .ofTextContent("string") ) .role( ChatCompletionCreateParams.Message @@ -342,7 +342,7 @@ class ChatCompletionCreateParamsTest { ChatCompletionCreateParams.Message .ChatCompletionRequestSystemMessage .Content - .ofString("string") + .ofTextContent("string") ) .role( ChatCompletionCreateParams.Message diff --git a/omnistack-kotlin-core/src/test/kotlin/com/omnistack/api/services/blocking/chats/CompletionServiceTest.kt b/omnistack-kotlin-core/src/test/kotlin/com/omnistack/api/services/blocking/chats/CompletionServiceTest.kt index 02a6233..c63eeac 100644 --- a/omnistack-kotlin-core/src/test/kotlin/com/omnistack/api/services/blocking/chats/CompletionServiceTest.kt +++ b/omnistack-kotlin-core/src/test/kotlin/com/omnistack/api/services/blocking/chats/CompletionServiceTest.kt @@ -32,7 +32,7 @@ class CompletionServiceTest { ChatCompletionCreateParams.Message .ChatCompletionRequestSystemMessage .Content - .ofString("string") + .ofTextContent("string") ) .role( ChatCompletionCreateParams.Message diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..8f98719 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,67 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "simple", + "extra-files": [ + "README.md", + "build.gradle.kts" + ] +} \ No newline at end of file