Skip to content

feat(firebase-ai): add function calling example #2678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

thatfiredev
Copy link
Member

This is a follow up to #2667

"fetchWeather",
"Get the weather conditions for a specific US city on a specific date.",
mapOf(
"city" to Schema.string("The US city of the location."),
Copy link
Contributor

@marinacoelho marinacoelho Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid confusion on what string should be sent as "city", "state" and "date", I'd send an empty string on this code sample and add a code comment on the line above, with something along the lines of // Replace this empty string with the US city of choice. (Same for state and date).

import kotlinx.serialization.json.JsonPrimitive

/**
* Hypothetical repository that calls an external weather API.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more accessible option (language-wise) is "Example repository".

suspend fun fetchWeather(
city: String, state: String, date: String
): JsonObject = withContext(Dispatchers.IO) {
// For demo purposes, this hypothetical response is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, I'd rephrase it to something along the lines of // This response is a hardcoded example of the expected format, and should be used for demo purposes only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants