Skip to content

Commit

Permalink
add changes from #171
Browse files Browse the repository at this point in the history
  • Loading branch information
David Motsonashvili committed Jun 4, 2024
1 parent 54d52cc commit eda2f8f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ data class GenerateContentRequest(
) : Request

@Serializable
data class CountTokensRequest(val generateContentRequest: GenerateContentRequest) : Request
data class CountTokensRequest(
val generateContentRequest: GenerateContentRequest,
val model: String? = null,
val contents: List<Content>? = null,
@SerialName("tool_config") var toolConfig: ToolConfig? = null,
@SerialName("system_instruction") val systemInstruction: Content? = null,
) : Request
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,4 @@ fun textGenerateContentRequest(prompt: String) =
contents = listOf(Content(parts = listOf(TextPart(prompt)))),
)

fun textCountTokenRequest(prompt: String) = CountTokensRequest(textGenerateContentRequest(prompt))
fun textCountTokenRequest(prompt: String) = CountTokensRequest(generateContentRequest = textGenerateContentRequest(prompt))
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ internal constructor(
)

private fun constructCountTokensRequest(vararg prompt: Content) =
CountTokensRequest(constructRequest(*prompt))
CountTokensRequest(generateContentRequest = constructRequest(*prompt))

private fun GenerateContentResponse.validate() = apply {
if (candidates.isEmpty() && promptFeedback == null) {
Expand Down

0 comments on commit eda2f8f

Please sign in to comment.