From b94f27eeb79964267752173732b412e775ef4e92 Mon Sep 17 00:00:00 2001 From: David Motsonashvili Date: Tue, 4 Jun 2024 11:30:04 -0700 Subject: [PATCH] add optional param for Schema.arr to specify objects in array (#159) Co-authored-by: David Motsonashvili --- .../ai/client/generativeai/type/FunctionDeclarations.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/generativeai/src/main/java/com/google/ai/client/generativeai/type/FunctionDeclarations.kt b/generativeai/src/main/java/com/google/ai/client/generativeai/type/FunctionDeclarations.kt index 21d02b08..b9ede02c 100644 --- a/generativeai/src/main/java/com/google/ai/client/generativeai/type/FunctionDeclarations.kt +++ b/generativeai/src/main/java/com/google/ai/client/generativeai/type/FunctionDeclarations.kt @@ -232,12 +232,17 @@ class Schema( nullable = false, ) - /** Registers a schema for an array */ - fun arr(name: String, description: String) = + /** + * Registers a schema for an array. + * + * @param items can be used to specify the type of the array + */ + fun arr(name: String, description: String, items: Schema? = null) = Schema>( name = name, description = description, type = FunctionType.ARRAY, + items = items, nullable = false, )