Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Davidmotson.vertex function fix #6332

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ jobs:
distribution: temurin
cache: gradle

- name: Pull genai-common
if: matrix.module == ':firebase-vertexai'
run: |
git clone https://github.com/google-gemini/generative-ai-android.git
cd generative-ai-android
./gradlew :common:updateVersion common:publishToMavenLocal
cd ..
- name: Clone mock responses
if: matrix.module == ':firebase-vertexai'
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal data class FunctionResponsePart(val functionResponse: FunctionResponse)
@Serializable internal data class FunctionResponse(val name: String, val response: JsonObject)

@Serializable
internal data class FunctionCall(val name: String, val args: Map<String, String?>? = null)
internal data class FunctionCall(val name: String, val args: Map<String, JsonElement?>? = null)

@Serializable
internal data class FileDataPart(@SerialName("file_data") val fileData: FileData) : Part
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ import com.google.firebase.vertexai.type.content
import java.io.ByteArrayOutputStream
import java.util.Calendar
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonNull
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import org.json.JSONObject

private const val BASE_64_FLAGS = Base64.NO_WRAP
Expand Down Expand Up @@ -97,10 +97,7 @@ internal fun Part.toInternal(): com.google.firebase.vertexai.common.shared.Part
}

internal fun FunctionCall.toInternal() =
com.google.firebase.vertexai.common.shared.FunctionCall(
name,
args.orEmpty().mapValues { it.value.toString() }
)
com.google.firebase.vertexai.common.shared.FunctionCall(name, args)

internal fun FunctionResponse.toInternal() =
com.google.firebase.vertexai.common.shared.FunctionResponse(name, response)
Expand Down Expand Up @@ -237,13 +234,7 @@ internal fun com.google.firebase.vertexai.common.shared.Part.toPublic(): Part {
}

internal fun com.google.firebase.vertexai.common.shared.FunctionCall.toPublic() =
FunctionCall(
name,
args.orEmpty().mapValues {
val argValue = it.value
if (argValue == null) JsonPrimitive(null) else Json.parseToJsonElement(argValue)
}
)
FunctionCall(name, args.orEmpty().mapValues { it.value ?: JsonNull })

internal fun com.google.firebase.vertexai.common.shared.FunctionResponse.toPublic() =
FunctionResponse(
Expand Down
Loading