Skip to content

Commit

Permalink
keep using getWeather to keep align with devsite documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cynthiajoan committed Sep 25, 2024
1 parent 4c15c6d commit f21703a
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ class _ChatWidgetState extends State<ChatWidget> {
_functionCallModel = FirebaseVertexAI.instance.generativeModel(
model: 'gemini-1.5-flash',
tools: [
Tool.functionDeclarationsTool([fetchWeatherTool]),
Tool.functionDeclarationsTool([getWeatherTool]),
],
);
_chat = _model.startChat();
});
}

// This is a hypothetical API to return a fake weather data collection for certain location
Future<Map<String, Object?>> fetchWeather(
Future<Map<String, Object?>> getWeather(
Map<String, Object?> arguments,
) async {
// Possible external api call
Expand All @@ -121,9 +121,9 @@ class _ChatWidgetState extends State<ChatWidget> {
}

/// Actual function to demonstrate the function calling feature.
final fetchWeatherTool = FunctionDeclaration(
final getWeatherTool = FunctionDeclaration(
'fetchCurrentWeather',
'Get the current weather in a given location',
'Get the weather conditions for a specific city on a specific date.',
parameters: {
'location': Schema.string(
description:
Expand Down Expand Up @@ -543,7 +543,7 @@ class _ChatWidgetState extends State<ChatWidget> {
final functionResult = switch (functionCall.name) {
// Forward the structured input data prepared by the model
// to the hypothetical external API.
'fetchCurrentWeather' => await fetchWeather(functionCall.args),
'fetchCurrentWeather' => await getWeather(functionCall.args),
// Throw an exception if the model attempted to call a function that was
// not declared.
_ => throw UnimplementedError(
Expand Down

0 comments on commit f21703a

Please sign in to comment.