Skip to content
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

Update Gemini sample #2846

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

johnpryan
Copy link
Contributor

@johnpryan johnpryan commented Feb 16, 2024

This applies code changes from this PR: google-gemini/generative-ai-dart#69

cc: @khanhnwin

Copy link
Member

@parlough parlough left a comment

Choose a reason for hiding this comment

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

Thanks for incorporating these updates. A few minor considerations, but looks good to me.

)
: ListView(
children: const [
Text('No API key found. Please provide an API Key.'),
Copy link
Member

Choose a reason for hiding this comment

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

Ah good point to add this, since I think the login(?) page currently allows empty submissions.

We don't have a back button, so maybe we should say to restart the sample? However, it's hopefully a rare mistake, so it might be fine to not provide special details or handling to avoid diverging too much from the original sample.

@@ -308,7 +337,10 @@ class MessageWidget extends StatelessWidget {
horizontal: 20,
),
margin: const EdgeInsets.only(bottom: 8),
child: MarkdownBody(data: text),
child: MarkdownBody(
selectable: true,
Copy link
Member

Choose a reason for hiding this comment

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

Woo, I was wanting this yesterday! Nice that the package makes it so easy :)

controller: _scrollController,
itemBuilder: (context, idx) {
final content = history[idx];
final text = content.parts
var content = _chat.history.toList()[idx];
Copy link
Member

@parlough parlough Feb 16, 2024

Choose a reason for hiding this comment

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

As a note, I changed this piece intentionally to avoid recreating the same list, and potentially reevaluating the history iterable for each item, but I'll open an upstream fix so it's not lost.

Edit: google-gemini/generative-ai-dart#77

@@ -157,19 +159,40 @@ class _ChatWidgetState extends State<ChatWidget> {

@override
Widget build(BuildContext context) {
final history = _chat.history.toList();
var textFieldDecoration = InputDecoration(
Copy link
Member

Choose a reason for hiding this comment

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

Is this the same as the textFieldDecoration method you added below to share with the API screen? Do you want to keep sharing that implementation or nah?

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.

None yet

2 participants