Skip to content

Commit 0d7e160

Browse files
committed
Make classes internal
1 parent b927b7e commit 0d7e160

File tree

10 files changed

+74
-74
lines changed

10 files changed

+74
-74
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal val JSON = Json {
7373
* @property apiClient The value to pass in the `x-goog-api-client` header.
7474
* @property headerProvider A provider that generates extra headers to include in all HTTP requests.
7575
*/
76-
class APIController
76+
internal class APIController
7777
internal constructor(
7878
private val key: String,
7979
model: String,
@@ -233,7 +233,7 @@ internal constructor(
233233
}
234234
}
235235

236-
interface HeaderProvider {
236+
internal interface HeaderProvider {
237237
val timeout: Duration
238238

239239
suspend fun generateHeaders(): Map<String, String>

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import io.ktor.serialization.JsonConvertException
2020
import kotlinx.coroutines.TimeoutCancellationException
2121

2222
/** Parent class for any errors that occur. */
23-
sealed class GoogleGenerativeAIException(message: String, cause: Throwable? = null) :
23+
internal sealed class GoogleGenerativeAIException(message: String, cause: Throwable? = null) :
2424
RuntimeException(message, cause) {
2525
companion object {
2626

@@ -47,15 +47,15 @@ sealed class GoogleGenerativeAIException(message: String, cause: Throwable? = nu
4747
}
4848

4949
/** Something went wrong while trying to deserialize a response from the server. */
50-
class SerializationException(message: String, cause: Throwable? = null) :
50+
internal class SerializationException(message: String, cause: Throwable? = null) :
5151
GoogleGenerativeAIException(message, cause)
5252

5353
/** The server responded with a non 200 response code. */
54-
class ServerException(message: String, cause: Throwable? = null) :
54+
internal class ServerException(message: String, cause: Throwable? = null) :
5555
GoogleGenerativeAIException(message, cause)
5656

5757
/** The server responded that the API Key is no valid. */
58-
class InvalidAPIKeyException(message: String, cause: Throwable? = null) :
58+
internal class InvalidAPIKeyException(message: String, cause: Throwable? = null) :
5959
GoogleGenerativeAIException(message, cause)
6060

6161
/**
@@ -65,7 +65,7 @@ class InvalidAPIKeyException(message: String, cause: Throwable? = null) :
6565
*
6666
* @property response the full server response for the request.
6767
*/
68-
class PromptBlockedException(val response: GenerateContentResponse, cause: Throwable? = null) :
68+
internal class PromptBlockedException(val response: GenerateContentResponse, cause: Throwable? = null) :
6969
GoogleGenerativeAIException(
7070
"Prompt was blocked: ${response.promptFeedback?.blockReason?.name}",
7171
cause,
@@ -78,23 +78,23 @@ class PromptBlockedException(val response: GenerateContentResponse, cause: Throw
7878
* [list of regions](https://ai.google.dev/available_regions#available_regions) (countries and
7979
* territories) where the API is available.
8080
*/
81-
class UnsupportedUserLocationException(cause: Throwable? = null) :
81+
internal class UnsupportedUserLocationException(cause: Throwable? = null) :
8282
GoogleGenerativeAIException("User location is not supported for the API use.", cause)
8383

8484
/**
8585
* Some form of state occurred that shouldn't have.
8686
*
8787
* Usually indicative of consumer error.
8888
*/
89-
class InvalidStateException(message: String, cause: Throwable? = null) :
89+
internal class InvalidStateException(message: String, cause: Throwable? = null) :
9090
GoogleGenerativeAIException(message, cause)
9191

9292
/**
9393
* A request was stopped during generation for some reason.
9494
*
9595
* @property response the full server response for the request
9696
*/
97-
class ResponseStoppedException(val response: GenerateContentResponse, cause: Throwable? = null) :
97+
internal class ResponseStoppedException(val response: GenerateContentResponse, cause: Throwable? = null) :
9898
GoogleGenerativeAIException(
9999
"Content generation stopped. Reason: ${response.candidates?.first()?.finishReason?.name}",
100100
cause,
@@ -105,17 +105,17 @@ class ResponseStoppedException(val response: GenerateContentResponse, cause: Thr
105105
*
106106
* Usually occurs due to a user specified [timeout][RequestOptions.timeout].
107107
*/
108-
class RequestTimeoutException(message: String, cause: Throwable? = null) :
108+
internal class RequestTimeoutException(message: String, cause: Throwable? = null) :
109109
GoogleGenerativeAIException(message, cause)
110110

111111
/** The quota for this API key is depleted, retry this request at a later time. */
112-
class QuotaExceededException(message: String, cause: Throwable? = null) :
112+
internal class QuotaExceededException(message: String, cause: Throwable? = null) :
113113
GoogleGenerativeAIException(message, cause)
114114

115115
/** The service is not enabled for this project. Visit the Firebase Console to enable it. */
116-
class ServiceDisabledException(message: String, cause: Throwable? = null) :
116+
internal class ServiceDisabledException(message: String, cause: Throwable? = null) :
117117
GoogleGenerativeAIException(message, cause)
118118

119119
/** Catch all case for exceptions not explicitly expected. */
120-
class UnknownException(message: String, cause: Throwable? = null) :
120+
internal class UnknownException(message: String, cause: Throwable? = null) :
121121
GoogleGenerativeAIException(message, cause)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import com.google.firebase.vertexai.common.util.fullModelName
2525
import kotlinx.serialization.SerialName
2626
import kotlinx.serialization.Serializable
2727

28-
sealed interface Request
28+
internal sealed interface Request
2929

3030
@Serializable
31-
data class GenerateContentRequest(
31+
internal data class GenerateContentRequest(
3232
val model: String? = null,
3333
val contents: List<Content>,
3434
@SerialName("safety_settings") val safetySettings: List<SafetySetting>? = null,
@@ -39,7 +39,7 @@ data class GenerateContentRequest(
3939
) : Request
4040

4141
@Serializable
42-
data class CountTokensRequest(
42+
internal data class CountTokensRequest(
4343
val generateContentRequest: GenerateContentRequest? = null,
4444
val model: String? = null,
4545
val contents: List<Content>? = null,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import kotlin.time.toDuration
2828
* first response.
2929
* @property apiVersion the api endpoint to call.
3030
*/
31-
class RequestOptions(
31+
internal class RequestOptions(
3232
val timeout: Duration,
3333
val apiVersion: String = "v1beta",
3434
val endpoint: String = "https://generativelanguage.googleapis.com",

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ import com.google.firebase.vertexai.common.server.GRpcError
2121
import com.google.firebase.vertexai.common.server.PromptFeedback
2222
import kotlinx.serialization.Serializable
2323

24-
sealed interface Response
24+
internal sealed interface Response
2525

2626
@Serializable
27-
data class GenerateContentResponse(
27+
internal data class GenerateContentResponse(
2828
val candidates: List<Candidate>? = null,
2929
val promptFeedback: PromptFeedback? = null,
3030
val usageMetadata: UsageMetadata? = null,
3131
) : Response
3232

3333
@Serializable
34-
data class CountTokensResponse(val totalTokens: Int, val totalBillableCharacters: Int? = null) :
34+
internal data class CountTokensResponse(val totalTokens: Int, val totalBillableCharacters: Int? = null) :
3535
Response
3636

37-
@Serializable data class GRpcErrorResponse(val error: GRpcError) : Response
37+
@Serializable internal data class GRpcErrorResponse(val error: GRpcError) : Response
3838

3939
@Serializable
40-
data class UsageMetadata(
40+
internal data class UsageMetadata(
4141
val promptTokenCount: Int? = null,
4242
val candidatesTokenCount: Int? = null,
4343
val totalTokenCount: Int? = null,

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import kotlinx.serialization.Serializable
2121
import kotlinx.serialization.json.JsonObject
2222

2323
@Serializable
24-
data class GenerationConfig(
24+
internal data class GenerationConfig(
2525
val temperature: Float?,
2626
@SerialName("top_p") val topP: Float?,
2727
@SerialName("top_k") val topK: Int?,
@@ -35,19 +35,19 @@ data class GenerationConfig(
3535
)
3636

3737
@Serializable
38-
data class Tool(
38+
internal data class Tool(
3939
val functionDeclarations: List<FunctionDeclaration>? = null,
4040
// This is a json object because it is not possible to make a data class with no parameters.
4141
val codeExecution: JsonObject? = null,
4242
)
4343

4444
@Serializable
45-
data class ToolConfig(
45+
internal data class ToolConfig(
4646
@SerialName("function_calling_config") val functionCallingConfig: FunctionCallingConfig
4747
)
4848

4949
@Serializable
50-
data class FunctionCallingConfig(val mode: Mode) {
50+
internal data class FunctionCallingConfig(val mode: Mode) {
5151
@Serializable
5252
enum class Mode {
5353
@SerialName("MODE_UNSPECIFIED") UNSPECIFIED,
@@ -58,10 +58,10 @@ data class FunctionCallingConfig(val mode: Mode) {
5858
}
5959

6060
@Serializable
61-
data class FunctionDeclaration(val name: String, val description: String, val parameters: Schema)
61+
internal data class FunctionDeclaration(val name: String, val description: String, val parameters: Schema)
6262

6363
@Serializable
64-
data class Schema(
64+
internal data class Schema(
6565
val type: String,
6666
val description: String? = null,
6767
val format: String? = null,

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,31 @@ import kotlinx.serialization.SerialName
2525
import kotlinx.serialization.Serializable
2626
import kotlinx.serialization.json.JsonNames
2727

28-
object BlockReasonSerializer :
28+
internal object BlockReasonSerializer :
2929
KSerializer<BlockReason> by FirstOrdinalSerializer(BlockReason::class)
3030

31-
object HarmProbabilitySerializer :
31+
internal object HarmProbabilitySerializer :
3232
KSerializer<HarmProbability> by FirstOrdinalSerializer(HarmProbability::class)
3333

34-
object FinishReasonSerializer :
34+
internal object FinishReasonSerializer :
3535
KSerializer<FinishReason> by FirstOrdinalSerializer(FinishReason::class)
3636

3737
@Serializable
38-
data class PromptFeedback(
38+
internal data class PromptFeedback(
3939
val blockReason: BlockReason? = null,
4040
val safetyRatings: List<SafetyRating>? = null,
4141
)
4242

4343
@Serializable(BlockReasonSerializer::class)
44-
enum class BlockReason {
44+
internal enum class BlockReason {
4545
UNKNOWN,
4646
@SerialName("BLOCKED_REASON_UNSPECIFIED") UNSPECIFIED,
4747
SAFETY,
4848
OTHER
4949
}
5050

5151
@Serializable
52-
data class Candidate(
52+
internal data class Candidate(
5353
val content: Content? = null,
5454
val finishReason: FinishReason? = null,
5555
val safetyRatings: List<SafetyRating>? = null,
@@ -58,20 +58,20 @@ data class Candidate(
5858
)
5959

6060
@Serializable
61-
data class CitationMetadata
61+
internal data class CitationMetadata
6262
@OptIn(ExperimentalSerializationApi::class)
63-
constructor(@JsonNames("citations") val citationSources: List<CitationSources>)
63+
internal constructor(@JsonNames("citations") val citationSources: List<CitationSources>)
6464

6565
@Serializable
66-
data class CitationSources(
66+
internal data class CitationSources(
6767
val startIndex: Int = 0,
6868
val endIndex: Int,
6969
val uri: String? = null,
7070
val license: String? = null,
7171
)
7272

7373
@Serializable
74-
data class SafetyRating(
74+
internal data class SafetyRating(
7575
val category: HarmCategory,
7676
val probability: HarmProbability,
7777
val blocked: Boolean? = null, // TODO(): any reason not to default to false?
@@ -81,33 +81,33 @@ data class SafetyRating(
8181
)
8282

8383
@Serializable
84-
data class GroundingMetadata(
84+
internal data class GroundingMetadata(
8585
@SerialName("web_search_queries") val webSearchQueries: List<String>?,
8686
@SerialName("search_entry_point") val searchEntryPoint: SearchEntryPoint?,
8787
@SerialName("retrieval_queries") val retrievalQueries: List<String>?,
8888
@SerialName("grounding_attribution") val groundingAttribution: List<GroundingAttribution>?,
8989
)
9090

9191
@Serializable
92-
data class SearchEntryPoint(
92+
internal data class SearchEntryPoint(
9393
@SerialName("rendered_content") val renderedContent: String?,
9494
@SerialName("sdk_blob") val sdkBlob: String?,
9595
)
9696

9797
@Serializable
98-
data class GroundingAttribution(
98+
internal data class GroundingAttribution(
9999
val segment: Segment,
100100
@SerialName("confidence_score") val confidenceScore: Float?,
101101
)
102102

103103
@Serializable
104-
data class Segment(
104+
internal data class Segment(
105105
@SerialName("start_index") val startIndex: Int,
106106
@SerialName("end_index") val endIndex: Int,
107107
)
108108

109109
@Serializable(HarmProbabilitySerializer::class)
110-
enum class HarmProbability {
110+
internal enum class HarmProbability {
111111
UNKNOWN,
112112
@SerialName("HARM_PROBABILITY_UNSPECIFIED") UNSPECIFIED,
113113
NEGLIGIBLE,
@@ -117,7 +117,7 @@ enum class HarmProbability {
117117
}
118118

119119
@Serializable
120-
enum class HarmSeverity {
120+
internal enum class HarmSeverity {
121121
UNKNOWN,
122122
@SerialName("HARM_SEVERITY_UNSPECIFIED") UNSPECIFIED,
123123
@SerialName("HARM_SEVERITY_NEGLIGIBLE") NEGLIGIBLE,
@@ -127,7 +127,7 @@ enum class HarmSeverity {
127127
}
128128

129129
@Serializable(FinishReasonSerializer::class)
130-
enum class FinishReason {
130+
internal enum class FinishReason {
131131
UNKNOWN,
132132
@SerialName("FINISH_REASON_UNSPECIFIED") UNSPECIFIED,
133133
STOP,
@@ -138,6 +138,6 @@ enum class FinishReason {
138138
}
139139

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

143-
@Serializable data class GRpcErrorDetails(val reason: String? = null)
143+
@Serializable internal data class GRpcErrorDetails(val reason: String? = null)

0 commit comments

Comments
 (0)