Skip to content

Commit

Permalink
remove use of VertexCountTokensRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
David Motsonashvili committed Jun 4, 2024
1 parent 0e15bb7 commit ef8cda5
Showing 1 changed file with 0 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,10 @@ internal constructor(
throw GoogleGenerativeAIException.from(e)
}

suspend fun vertexCountTokens(request: VertexCountTokensRequest): CountTokensResponse =
try {
client
.post("${requestOptions.endpoint}/${requestOptions.apiVersion}/$model:countTokens") {
applyCommonConfiguration(request)
applyHeaderProvider()
}
.also { validateResponse(it) }
.body()
} catch (e: Throwable) {
throw GoogleGenerativeAIException.from(e)
}

private fun HttpRequestBuilder.applyCommonConfiguration(request: Request) {
when (request) {
is GenerateContentRequest -> setBody<GenerateContentRequest>(request)
is CountTokensRequest -> setBody<CountTokensRequest>(request)
is VertexCountTokensRequest -> setBody<VertexCountTokensRequest>(request)
}
contentType(ContentType.Application.Json)
header("x-goog-api-key", key)
Expand Down

0 comments on commit ef8cda5

Please sign in to comment.