Skip to content

Commit

Permalink
Support Java
Browse files Browse the repository at this point in the history
  • Loading branch information
daymxn committed Feb 8, 2024
1 parent e7b7a0c commit 52dd95d
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ package com.google.ai.client.generativeai.type

import io.ktor.client.plugins.HttpTimeout
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.DurationUnit
import kotlin.time.toDuration

/**
* Configurable options unique to how requests to the backend are performed.
Expand All @@ -27,7 +28,13 @@ import kotlin.time.Duration.Companion.milliseconds
* first response.
* @property apiVersion the api endpoint to call.
*/
class RequestOptions(
val timeout: Duration = HttpTimeout.INFINITE_TIMEOUT_MS.milliseconds,
val apiVersion: String = "v1"
)
class RequestOptions(val timeout: Duration, val apiVersion: String = "v1") {
@JvmOverloads
constructor(
timeout: Long? = HttpTimeout.INFINITE_TIMEOUT_MS,
apiVersion: String = "v1"
) : this(
(timeout ?: HttpTimeout.INFINITE_TIMEOUT_MS).toDuration(DurationUnit.MILLISECONDS),
apiVersion
)
}

0 comments on commit 52dd95d

Please sign in to comment.