-
Notifications
You must be signed in to change notification settings - Fork 109
Readme update #125
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
Merged
Merged
Readme update #125
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4f18c8c
WIP # Conflicts: # ai-catalog/README.md
lethargicpanda 1107460
Provide sample details
lethargicpanda 29d2f07
Add sample screenshots
lethargicpanda 370710e
Address comments
lethargicpanda 17ddc86
adding chatbot readme
lethargicpanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Gemini Chatbot Sample | ||
|
|
||
| This sample is part of the [AI Sample Catalog](../../). To build and run this sample, you should clone the entire repository. | ||
|
|
||
| ## Description | ||
|
|
||
| This sample demonstrates a basic chat bot using the `Gemini 2.5 Flash` model. Users can send text-based messages, and the generative model will respond, creating an interactive chat experience. This showcases how to build a simple, yet powerful, conversational AI with the Gemini API. | ||
|
|
||
| <div style="text-align: center;"> | ||
| <img width="320" alt="Gemini Chatbot in action" src="gemini_chatbot.png" /> | ||
| </div> | ||
|
|
||
| ## How it works | ||
|
|
||
| The application uses the Firebase AI SDK (see [How to run](../../#how-to-run)) for Android to interact with the `Gemini 2.5 Flash` model. The core logic is in the `GeminiChatbotViewModel.kt` file. A `generativeModel` is initialized, and then a `chat` session is started from it. When a user sends a message, it's passed to the model, which then generates a text response. | ||
|
|
||
| Here is the key snippet of code that calls the generative model: | ||
|
|
||
| ```kotlin | ||
| private val generativeModel by lazy { | ||
| Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel("gemini-2.5-flash") | ||
| } | ||
| private val chat = generativeModel.startChat() | ||
|
|
||
| fun sendMessage(message: String) { | ||
| viewModelScope.launch { | ||
| // ... | ||
| val response = chat.sendMessage(message) | ||
| // ... | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Read more about [getting started with Gemini](https://developer.android.com/ai/gemini/get-started) in the Android Documentation. | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding a hard-coded code snippet here (which can easily go out of date) let's link to the the relevant file instead (you can link to a range of lines IIRC). For maintenance purposes we should try to have a single source of truth, not duplicate it like we do here. Can be done in a follow-up PR if you want to keep moving.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good point. I think we can also rely on Code Assist to help us with this.