Skip to content

Commit ee8a0ef

Browse files
Apply suggestions from code review
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 2c052e9 commit ee8a0ef

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/firebase_ai/firebase_ai/example/lib/pages/function_calling_page.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ class _FunctionCallingPageState extends State<FunctionCallingPage> {
9191
),
9292
},
9393
callable: (args) async {
94-
final cuisine = args['cuisine']! as String;
95-
final location = args['location']! as String;
96-
return findRestaurants(cuisine, location);
94+
final cuisine = args['cuisine'];
95+
final location = args['location'];
96+
if (cuisine is String && location is String) {
97+
return findRestaurants(cuisine, location);
98+
}
99+
// It's good practice to handle cases where arguments are missing or have the wrong type.
100+
throw Exception('Missing or invalid arguments for findRestaurants');
97101
},
98102
);
99103
_autoGetRestaurantMenuTool = AutoFunctionDeclaration(

packages/firebase_ai/firebase_ai/lib/src/chat.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ final class ChatSession {
3939
: _autoFunctionDeclarations = _tools
4040
?.expand((tool) => tool.autoFunctionDeclarations)
4141
.fold(<String, AutoFunctionDeclaration>{}, (map, function) {
42-
map?[function.name] = function;
42+
map[function.name] = function;
4343
return map;
4444
});
4545
final Future<GenerateContentResponse> Function(Iterable<Content> content,

0 commit comments

Comments
 (0)