Skip to content

Commit c16d020

Browse files
committed
Format, changelog, and minor fix
1 parent c7be602 commit c16d020

File tree

11 files changed

+41
-17
lines changed

11 files changed

+41
-17
lines changed

firebase-vertexai/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Unreleased
2+
* [changed] Merged core networking code into VertexAI from a separate library
23
* [feature] added support for `responseSchema` in `GenerationConfig`.
34

45
# 16.0.0-beta03

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/Exceptions.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ internal class InvalidAPIKeyException(message: String, cause: Throwable? = null)
6565
*
6666
* @property response the full server response for the request.
6767
*/
68-
internal class PromptBlockedException(val response: GenerateContentResponse, cause: Throwable? = null) :
68+
internal class PromptBlockedException(
69+
val response: GenerateContentResponse,
70+
cause: Throwable? = null
71+
) :
6972
GoogleGenerativeAIException(
7073
"Prompt was blocked: ${response.promptFeedback?.blockReason?.name}",
7174
cause,
@@ -94,7 +97,10 @@ internal class InvalidStateException(message: String, cause: Throwable? = null)
9497
*
9598
* @property response the full server response for the request
9699
*/
97-
internal class ResponseStoppedException(val response: GenerateContentResponse, cause: Throwable? = null) :
100+
internal class ResponseStoppedException(
101+
val response: GenerateContentResponse,
102+
cause: Throwable? = null
103+
) :
98104
GoogleGenerativeAIException(
99105
"Content generation stopped. Reason: ${response.candidates?.first()?.finishReason?.name}",
100106
cause,

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/Response.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ internal data class GenerateContentResponse(
3131
) : Response
3232

3333
@Serializable
34-
internal data class CountTokensResponse(val totalTokens: Int, val totalBillableCharacters: Int? = null) :
35-
Response
34+
internal data class CountTokensResponse(
35+
val totalTokens: Int,
36+
val totalBillableCharacters: Int? = null
37+
) : Response
3638

3739
@Serializable internal data class GRpcErrorResponse(val error: GRpcError) : Response
3840

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/client/Types.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ internal data class FunctionCallingConfig(val mode: Mode) {
5858
}
5959

6060
@Serializable
61-
internal data class FunctionDeclaration(val name: String, val description: String, val parameters: Schema)
61+
internal data class FunctionDeclaration(
62+
val name: String,
63+
val description: String,
64+
val parameters: Schema
65+
)
6266

6367
@Serializable
6468
internal data class Schema(

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/server/Types.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ internal enum class FinishReason {
138138
}
139139

140140
@Serializable
141-
internal data class GRpcError(val code: Int, val message: String, val details: List<GRpcErrorDetails>)
141+
internal data class GRpcError(
142+
val code: Int,
143+
val message: String,
144+
val details: List<GRpcErrorDetails>
145+
)
142146

143147
@Serializable internal data class GRpcErrorDetails(val reason: String? = null)

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/shared/Types.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ internal data class Content(@EncodeDefault val role: String? = "user", val parts
5555

5656
@Serializable internal data class FunctionCallPart(val functionCall: FunctionCall) : Part
5757

58-
@Serializable internal data class FunctionResponsePart(val functionResponse: FunctionResponse) : Part
58+
@Serializable
59+
internal data class FunctionResponsePart(val functionResponse: FunctionResponse) : Part
5960

6061
@Serializable internal data class ExecutableCodePart(val executableCode: ExecutableCode) : Part
6162

@@ -64,17 +65,20 @@ internal data class CodeExecutionResultPart(val codeExecutionResult: CodeExecuti
6465

6566
@Serializable internal data class FunctionResponse(val name: String, val response: JsonObject)
6667

67-
@Serializable internal data class FunctionCall(val name: String, val args: Map<String, String?>? = null)
68+
@Serializable
69+
internal data class FunctionCall(val name: String, val args: Map<String, String?>? = null)
6870

69-
@Serializable internal data class FileDataPart(@SerialName("file_data") val fileData: FileData) : Part
71+
@Serializable
72+
internal data class FileDataPart(@SerialName("file_data") val fileData: FileData) : Part
7073

7174
@Serializable
7275
internal data class FileData(
7376
@SerialName("mime_type") val mimeType: String,
7477
@SerialName("file_uri") val fileUri: String,
7578
)
7679

77-
@Serializable internal data class Blob(@SerialName("mime_type") val mimeType: String, val data: Base64)
80+
@Serializable
81+
internal data class Blob(@SerialName("mime_type") val mimeType: String, val data: Base64)
7882

7983
@Serializable internal data class ExecutableCode(val language: String, val code: String)
8084

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/util/serialization.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import kotlinx.serialization.encoding.Encoder
3434
* When an unknown enum value is found, the enum itself will be logged to stderr with a message
3535
* about opening an issue on GitHub regarding the new enum value.
3636
*/
37-
internal class FirstOrdinalSerializer<T : Enum<T>>(private val enumClass: KClass<T>) : KSerializer<T> {
37+
internal class FirstOrdinalSerializer<T : Enum<T>>(private val enumClass: KClass<T>) :
38+
KSerializer<T> {
3839
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("FirstOrdinalSerializer")
3940

4041
override fun deserialize(decoder: Decoder): T {

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/util/util.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ package com.google.firebase.vertexai.common.util
2121
*
2222
* Models must be prepended with the `models/` prefix when communicating with the backend.
2323
*/
24-
internal fun fullModelName(name: String): String = name.takeIf { it.contains("/") } ?: "models/$name"
24+
internal fun fullModelName(name: String): String =
25+
name.takeIf { it.contains("/") } ?: "models/$name"

firebase-vertexai/src/test/java/com/google/firebase/vertexai/common/APIControllerTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,11 @@ internal class ModelNamingTests(private val modelName: String, private val actua
343343
}
344344
}
345345

346-
fun textGenerateContentRequest(prompt: String) =
346+
internal fun textGenerateContentRequest(prompt: String) =
347347
GenerateContentRequest(
348348
model = "unused",
349349
contents = listOf(Content(parts = listOf(TextPart(prompt)))),
350350
)
351351

352-
fun textCountTokenRequest(prompt: String) =
352+
internal fun textCountTokenRequest(prompt: String) =
353353
CountTokensRequest(generateContentRequest = textGenerateContentRequest(prompt))

firebase-vertexai/src/test/java/com/google/firebase/vertexai/common/StreamingSnapshotTests.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import io.kotest.matchers.nulls.shouldNotBeNull
2626
import io.kotest.matchers.shouldBe
2727
import io.kotest.matchers.string.shouldContain
2828
import io.ktor.http.HttpStatusCode
29+
import kotlin.time.Duration.Companion.seconds
2930
import kotlinx.coroutines.flow.collect
3031
import kotlinx.coroutines.flow.toList
3132
import kotlinx.coroutines.withTimeout
3233
import org.junit.Test
33-
import kotlin.time.Duration.Companion.seconds
3434

3535
internal class StreamingSnapshotTests {
3636
private val testTimeout = 5.seconds
@@ -76,7 +76,8 @@ internal class StreamingSnapshotTests {
7676
responseList.any {
7777
it.candidates?.any {
7878
it.safetyRatings?.any { it.category == HarmCategory.UNKNOWN } ?: false
79-
} ?: false
79+
}
80+
?: false
8081
} shouldBe true
8182
}
8283
}

firebase-vertexai/src/test/java/com/google/firebase/vertexai/common/UnarySnapshotTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ import io.kotest.matchers.shouldBe
3838
import io.kotest.matchers.shouldNotBe
3939
import io.kotest.matchers.types.shouldBeInstanceOf
4040
import io.ktor.http.HttpStatusCode
41+
import kotlin.time.Duration.Companion.seconds
4142
import kotlinx.coroutines.withTimeout
4243
import kotlinx.serialization.Serializable
4344
import org.junit.Test
44-
import kotlin.time.Duration.Companion.seconds
4545

4646
@Serializable internal data class MountainColors(val name: String, val colors: List<String>)
4747

0 commit comments

Comments
 (0)