File tree Expand file tree Collapse file tree 3 files changed +13
-13
lines changed
firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai Expand file tree Collapse file tree 3 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -153,16 +153,7 @@ internal fun Tool.toInternal() =
153
153
com.google.firebase.vertexai.common.client.Tool (functionDeclarations.map { it.toInternal() })
154
154
155
155
internal fun FunctionDeclaration.toInternal () =
156
- com.google.firebase.vertexai.common.client.FunctionDeclaration (
157
- name,
158
- description,
159
- Schema (
160
- properties = parameters.mapValues { it.value.toInternal() },
161
- required = parameters.keys.minus(optionalParameters.toSet()).toList(),
162
- type = " OBJECT" ,
163
- nullable = false ,
164
- ),
165
- )
156
+ com.google.firebase.vertexai.common.client.FunctionDeclaration (name, " " , schema.toInternal())
166
157
167
158
internal fun com.google.firebase.vertexai.type.Schema.toInternal (): Schema =
168
159
Schema (
Original file line number Diff line number Diff line change @@ -41,4 +41,7 @@ class FunctionDeclaration(
41
41
val description : String ,
42
42
val parameters : Map <String , Schema >,
43
43
val optionalParameters : List <String > = emptyList(),
44
- )
44
+ ) {
45
+ internal val schema: Schema =
46
+ Schema .obj(properties = parameters, optionalProperties = optionalParameters, nullable = false )
47
+ }
Original file line number Diff line number Diff line change @@ -130,14 +130,20 @@ internal constructor(
130
130
optionalProperties : List <String > = emptyList(),
131
131
description : String? = null,
132
132
nullable : Boolean = false,
133
- ) =
134
- Schema (
133
+ ): Schema {
134
+ if (! properties.keys.containsAll(optionalProperties)) {
135
+ throw IllegalArgumentException (
136
+ " All optional properties must be present in properties. Missing: ${optionalProperties.minus(properties.keys)} "
137
+ )
138
+ }
139
+ return Schema (
135
140
description = description,
136
141
nullable = nullable,
137
142
properties = properties,
138
143
required = properties.keys.minus(optionalProperties.toSet()).toList(),
139
144
type = " OBJECT" ,
140
145
)
146
+ }
141
147
142
148
/* *
143
149
* Returns a schema for an array.
You can’t perform that action at this time.
0 commit comments