Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed May 10, 2024
1 parent 1789858 commit 2472bdc
Show file tree
Hide file tree
Showing 16 changed files with 3 additions and 79 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,18 @@ implementation("com.braintrust.api:braintrust-java:0.2.0")

### Configure the client

Use `BraintrustOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()` and `.baseUrl()`:
Use `BraintrustOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()`:

```java
import com.braintrust.api.client.BraintrustClient;
import com.braintrust.api.client.okhttp.BraintrustOkHttpClient;

BraintrustClient client = BraintrustOkHttpClient.builder()
.apiKey("My API Key")
.baseUrl("My Base URL")
.build();
```

Alternately, set the environment with `BRAINTRUST_API_KEY` or `BRAINTRUST_APP_URL`, and use `BraintrustOkHttpClient.fromEnv()` to read from the environment.
Alternately, set the environment with `BRAINTRUST_API_KEY`, and use `BraintrustOkHttpClient.fromEnv()` to read from the environment.

```java
BraintrustClient client = BraintrustOkHttpClient.fromEnv();
Expand All @@ -71,7 +70,6 @@ BraintrustClient client = BraintrustOkHttpClient.builder()
| Property | Environment variable | Required | Default value |
| -------- | -------------------- | -------- | ------------- |
| apiKey | `BRAINTRUST_API_KEY` | true ||
| baseUrl | `BRAINTRUST_APP_URL` | true ||

Read the documentation for more configuration options.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ class BraintrustOkHttpClient private constructor() {

fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }

fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) }

fun fromEnv() = apply { clientOptions.fromEnv() }

fun build(): BraintrustClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ class BraintrustOkHttpClientAsync private constructor() {

fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }

fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) }

fun fromEnv() = apply { clientOptions.fromEnv() }

fun build(): BraintrustClientAsync {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ private constructor(
@get:JvmName("clock") val clock: Clock,
@get:JvmName("baseUrl") val baseUrl: String,
@get:JvmName("apiKey") val apiKey: String,
@get:JvmName("baseUrl") val baseUrl: String,
@get:JvmName("headers") val headers: ListMultimap<String, String>,
@get:JvmName("responseValidation") val responseValidation: Boolean,
) {
Expand All @@ -40,7 +39,6 @@ private constructor(
private var responseValidation: Boolean = false
private var maxRetries: Int = 2
private var apiKey: String? = null
private var baseUrl: String? = null

fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient }

Expand Down Expand Up @@ -77,17 +75,11 @@ private constructor(

fun apiKey(apiKey: String) = apply { this.apiKey = apiKey }

fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl }

fun fromEnv() = apply {
System.getenv("BRAINTRUST_API_KEY")?.let { apiKey(it) }
System.getenv("BRAINTRUST_APP_URL")?.let { baseUrl(it) }
}
fun fromEnv() = apply { System.getenv("BRAINTRUST_API_KEY")?.let { apiKey(it) } }

fun build(): ClientOptions {
checkNotNull(httpClient) { "`httpClient` is required but was not set" }
checkNotNull(apiKey) { "`apiKey` is required but was not set" }
checkNotNull(baseUrl) { "`baseUrl` is required but was not set" }

val headers = ArrayListMultimap.create<String, String>()
headers.put("X-Stainless-Lang", "java")
Expand All @@ -111,7 +103,6 @@ private constructor(
clock,
baseUrl,
apiKey!!,
baseUrl!!,
headers.toUnmodifiable(),
responseValidation,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class ErrorHandlingTest {
BraintrustOkHttpClient.builder()
.baseUrl(wmRuntimeInfo.getHttpBaseUrl())
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class ServiceParamsTest {
client =
BraintrustOkHttpClient.builder()
.apiKey("My API Key")
.baseUrl("My Base URL")
.baseUrl(wmRuntimeInfo.getHttpBaseUrl())
.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class AclServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val aclService = client.acl()
val acl =
Expand All @@ -43,7 +42,6 @@ class AclServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val aclService = client.acl()
val acl =
Expand All @@ -60,7 +58,6 @@ class AclServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val aclService = client.acl()
val response =
Expand All @@ -77,7 +74,6 @@ class AclServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val aclService = client.acl()
val acl =
Expand All @@ -94,7 +90,6 @@ class AclServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val aclService = client.acl()
val acl =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
val dataset =
Expand All @@ -40,7 +39,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
val dataset =
Expand All @@ -59,7 +57,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
val dataset =
Expand All @@ -80,7 +77,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
val response = datasetService.list(DatasetListParams.builder().build())
Expand All @@ -94,7 +90,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
val dataset =
Expand All @@ -113,7 +108,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
datasetService.feedback(
Expand All @@ -139,7 +133,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
val datasetFetchResponse =
Expand All @@ -162,7 +155,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
val datasetFetchPostResponse =
Expand Down Expand Up @@ -195,7 +187,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
val datasetInsertResponse =
Expand Down Expand Up @@ -234,7 +225,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
val dataset =
Expand All @@ -255,7 +245,6 @@ class DatasetServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val datasetService = client.dataset()
val datasetSummarizeResponse =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
val experiment =
Expand Down Expand Up @@ -59,7 +58,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
val experiment =
Expand All @@ -78,7 +76,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
val experiment =
Expand Down Expand Up @@ -117,7 +114,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
val response = experimentService.list(ExperimentListParams.builder().build())
Expand All @@ -131,7 +127,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
val experiment =
Expand All @@ -150,7 +145,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
experimentService.feedback(
Expand Down Expand Up @@ -178,7 +172,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
val experimentFetchResponse =
Expand All @@ -201,7 +194,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
val experimentFetchPostResponse =
Expand Down Expand Up @@ -234,7 +226,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
val experimentInsertResponse =
Expand Down Expand Up @@ -316,7 +307,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
val experiment =
Expand Down Expand Up @@ -356,7 +346,6 @@ class ExperimentServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val experimentService = client.experiment()
val experimentSummarizeResponse =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class GroupServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val groupService = client.group()
val group =
Expand All @@ -41,7 +40,6 @@ class GroupServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val groupService = client.group()
val group =
Expand All @@ -60,7 +58,6 @@ class GroupServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val groupService = client.group()
val group =
Expand All @@ -83,7 +80,6 @@ class GroupServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val groupService = client.group()
val response = groupService.list(GroupListParams.builder().build())
Expand All @@ -97,7 +93,6 @@ class GroupServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val groupService = client.group()
val group =
Expand All @@ -114,7 +109,6 @@ class GroupServiceTest {
BraintrustOkHttpClient.builder()
.baseUrl(TestServerExtension.BASE_URL)
.apiKey("My API Key")
.baseUrl("My Base URL")
.build()
val groupService = client.group()
val group =
Expand Down
Loading

0 comments on commit 2472bdc

Please sign in to comment.