Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.1.0-alpha.5 #39

Merged
merged 7 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# syntax=docker/dockerfile:1
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y \
RUN apt-get update && apt-get install -y --no-install-recommends \
libxkbcommon0 \
ca-certificates \
ca-certificates-java \
make \
curl \
git \
openjdk-17-jdk \
openjdk-17-jdk-headless \
unzip \
libc++1 \
vim \
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.4"
".": "0.1.0-alpha.5"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 13
configured_endpoints: 14
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 0.1.0-alpha.5 (2024-11-11)

Full Changelog: [v0.1.0-alpha.4...v0.1.0-alpha.5](https://github.com/openlayer-ai/openlayer-java/compare/v0.1.0-alpha.4...v0.1.0-alpha.5)

### Features

* **api:** manual updates ([#42](https://github.com/openlayer-ai/openlayer-java/issues/42)) ([90b8621](https://github.com/openlayer-ai/openlayer-java/commit/90b8621b2a9cd61dac108272689fd0ac91892e98))
* **api:** manual updates ([#43](https://github.com/openlayer-ai/openlayer-java/issues/43)) ([197d1e4](https://github.com/openlayer-ai/openlayer-java/commit/197d1e408bb880f11dde24d4af04b0b6102a05cd))
* **api:** update via SDK Studio ([#40](https://github.com/openlayer-ai/openlayer-java/issues/40)) ([d739c0c](https://github.com/openlayer-ai/openlayer-java/commit/d739c0cf10da747b6116db07064f4211e138fbca))
* **api:** update via SDK Studio ([#41](https://github.com/openlayer-ai/openlayer-java/issues/41)) ([115a8bb](https://github.com/openlayer-ai/openlayer-java/commit/115a8bb76b4cc1deb9abccd7ff9341c9e7507db2))


### Bug Fixes

* update stream data example ([01a6acb](https://github.com/openlayer-ai/openlayer-java/commit/01a6acb859853b961556dcc7e51b91a40def3461))


### Chores

* custom code changes ([#44](https://github.com/openlayer-ai/openlayer-java/issues/44)) ([d1a94e9](https://github.com/openlayer-ai/openlayer-java/commit/d1a94e9d34778ca922ce580a0d887201881114ee))
* rebuild project due to codegen change ([#45](https://github.com/openlayer-ai/openlayer-java/issues/45)) ([546951e](https://github.com/openlayer-ai/openlayer-java/commit/546951ef157f61e22168e8bc3caee9e437c27a53))

## 0.1.0-alpha.4 (2024-09-23)

Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/openlayer-ai/openlayer-java/compare/v0.1.0-alpha.3...v0.1.0-alpha.4)
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.openlayer.api/openlayer-java)](https://central.sonatype.com/artifact/com.openlayer.api/openlayer-java/0.1.0-alpha.4)
[![Maven Central](https://img.shields.io/maven-central/v/com.openlayer.api/openlayer-java)](https://central.sonatype.com/artifact/com.openlayer.api/openlayer-java/0.1.0-alpha.5)

<!-- x-release-please-end -->

Expand All @@ -27,7 +27,7 @@ The REST API documentation can be found on [openlayer.com](https://openlayer.co
<!-- x-release-please-start-version -->

```kotlin
implementation("com.openlayer.api:openlayer-java:0.1.0-alpha.4")
implementation("com.openlayer.api:openlayer-java:0.1.0-alpha.5")
```

#### Maven
Expand All @@ -36,7 +36,7 @@ implementation("com.openlayer.api:openlayer-java:0.1.0-alpha.4")
<dependency>
<groupId>com.openlayer.api</groupId>
<artifactId>openlayer-java</artifactId>
<version>0.1.0-alpha.4</version>
<version>0.1.0-alpha.5</version>
</dependency>
```

Expand Down Expand Up @@ -77,16 +77,17 @@ import com.openlayer.api.models.InferencePipelineDataStreamResponse;
import java.util.List;

InferencePipelineDataStreamParams params = InferencePipelineDataStreamParams.builder()
.rows(List.of(InferencePipelineDataStreamParams.Row.builder().build()))
.inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.config(InferencePipelineDataStreamParams.Config.ofLlmData(InferencePipelineDataStreamParams.Config.LlmData.builder()
.outputColumnName("output")
.costColumnName("cost")
.inputVariableNames(List.of("user_query"))
.numOfTokenColumnName("tokens")
.timestampColumnName("timestamp")
.build()))
.row(List.of(InferencePipelineDataStreamParams.Row.builder().build()))
.build();
InferencePipelineDataStreamResponse inferencePipelineDataStreamResponse = client.inferencePipelines().data().stream(params);
InferencePipelineDataStreamResponse response = client.inferencePipelines().data().stream(params);
```

---
Expand Down Expand Up @@ -118,7 +119,7 @@ InferencePipelineDataStreamParams params = InferencePipelineDataStreamParams.bui
When receiving a response, the Openlayer Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `OpenlayerInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model.

```java
InferencePipelineDataStreamResponse inferencePipelineDataStreamResponse = client.inferencePipelines().data().stream().validate();
InferencePipelineDataStreamResponse response = client.inferencePipelines().data().stream().validate();
```

### Response properties as JSON
Expand Down Expand Up @@ -148,7 +149,7 @@ if (field.isMissing()) {
Sometimes, the server response may include additional properties that are not yet available in this library's types. You can access them using the model's `_additionalProperties` method:

```java
JsonValue secret = inferencePipelineDataStreamResponse._additionalProperties().get("secret_field");
JsonValue secret = projectCreateResponse._additionalProperties().get("secret_field");
```

---
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

allprojects {
group = "com.openlayer.api"
version = "0.1.0-alpha.4" // x-release-please-version
version = "0.1.0-alpha.5" // x-release-please-version
}


1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/openlayer.java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ configure<SpotlessExtension> {
importOrder()
removeUnusedImports()
palantirJavaFormat()
toggleOffOn()
}
}

Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ kotlin {
configure<SpotlessExtension> {
kotlin {
ktfmt().kotlinlangStyle()
toggleOffOn()
}
}

Expand Down
1 change: 0 additions & 1 deletion openlayer-java-client-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
dependencies {
api(project(":openlayer-java-core"))

implementation("com.google.guava:guava:33.0.0-jre")
implementation("com.squareup.okhttp3:okhttp:4.12.0")

testImplementation(kotlin("test"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.openlayer.api.client.okhttp

import com.google.common.collect.ListMultimap
import com.google.common.collect.MultimapBuilder
import com.openlayer.api.core.RequestOptions
import com.openlayer.api.core.http.Headers
import com.openlayer.api.core.http.HttpClient
import com.openlayer.api.core.http.HttpMethod
import com.openlayer.api.core.http.HttpRequest
Expand All @@ -16,7 +15,6 @@ import java.time.Duration
import java.util.concurrent.CompletableFuture
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Headers
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType
Expand Down Expand Up @@ -66,7 +64,6 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
request.body?.run { future.whenComplete { _, _ -> close() } }

val call = getClient(requestOptions).newCall(request.toRequest())

call.enqueue(
object : Callback {
override fun onResponse(call: Call, response: Response) {
Expand All @@ -90,13 +87,15 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

private fun HttpRequest.toRequest(): Request {
var body: RequestBody? = body?.toRequestBody()
// OkHttpClient always requires a request body for PUT and POST methods
// OkHttpClient always requires a request body for PUT and POST methods.
if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) {
body = "".toRequestBody()
}

val builder = Request.Builder().url(toUrl()).method(method.name, body)
headers.forEach(builder::header)
headers.names().forEach { name ->
headers.values(name).forEach { builder.header(name, it) }
}

return builder.build()
}
Expand All @@ -108,7 +107,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

val builder = baseUrl.newBuilder()
pathSegments.forEach(builder::addPathSegment)
queryParams.forEach(builder::addQueryParameter)
queryParams.keys().forEach { key ->
queryParams.values(key).forEach { builder.addQueryParameter(key, it) }
}

return builder.toString()
}
Expand All @@ -118,55 +119,34 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
val length = contentLength()

return object : RequestBody() {
override fun contentType(): MediaType? {
return mediaType
}
override fun contentType(): MediaType? = mediaType

override fun contentLength(): Long {
return length
}
override fun contentLength(): Long = length

override fun isOneShot(): Boolean {
return !repeatable()
}
override fun isOneShot(): Boolean = !repeatable()

override fun writeTo(sink: BufferedSink) {
writeTo(sink.outputStream())
}
override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream())
}
}

private fun Response.toResponse(): HttpResponse {
val headers = headers.toHeaders()

return object : HttpResponse {
override fun statusCode(): Int {
return code
}
override fun statusCode(): Int = code

override fun headers(): ListMultimap<String, String> {
return headers
}
override fun headers(): Headers = headers

override fun body(): InputStream {
return body!!.byteStream()
}
override fun body(): InputStream = body!!.byteStream()

override fun close() {
body!!.close()
}
override fun close() = body!!.close()
}
}

private fun Headers.toHeaders(): ListMultimap<String, String> {
val headers =
MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
.arrayListValues()
.build<String, String>()

forEach { pair -> headers.put(pair.first, pair.second) }

return headers
private fun okhttp3.Headers.toHeaders(): Headers {
val headersBuilder = Headers.builder()
forEach { (name, value) -> headersBuilder.put(name, value) }
return headersBuilder.build()
}

companion object {
Expand All @@ -176,7 +156,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
class Builder {

private var baseUrl: HttpUrl? = null
// default timeout is 1 minute
// The default timeout is 1 minute.
private var timeout: Duration = Duration.ofSeconds(60)
private var proxy: Proxy? = null

Expand All @@ -186,8 +166,8 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }

fun build(): OkHttpClient {
return OkHttpClient(
fun build(): OkHttpClient =
OkHttpClient(
okhttp3.OkHttpClient.Builder()
.connectTimeout(timeout)
.readTimeout(timeout)
Expand All @@ -197,6 +177,5 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
.build(),
checkNotNull(baseUrl) { "`baseUrl` is required but was not set" },
)
}
}
}
Loading
Loading