Ниже приведен код от DOC Firebase-AI, демонстрирующий использование функциональных вызовов с моделью Gemini на Android < /p>
// This function calls a hypothetical external API that returns
// a collection of weather information for a given location on a given date.
// `location` is an object of the form { city: string, state: string }
public JsonObject fetchWeather(Location location, String date) {
// TODO(developer): Write a standard function that would call to an external weather API.
// For demo purposes, this hypothetical response is hardcoded here in the expected format.
return new JsonObject(Map.of(
"temperature", JsonPrimitive(38),
"chancePrecipitation", JsonPrimitive("56%"),
"cloudConditions", JsonPrimitive("partlyCloudy")));
}
< /code>
Поэтому я хочу знать, могу ли я просто вернуть строку JSON или даже любой другой объект, такой как String, Boolean и т. Д. Хотя я не пробовал ничего другого, потому что я не знаю, если не использует jsonObject, считается не лучшей практикой
Подробнее здесь: https://stackoverflow.com/questions/797 ... ction-call