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 text_generation.dart #213

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

Conversation

logankilpatrick
Copy link
Member

No description provided.

Copy link
Collaborator

@natebosch natebosch left a comment

Choose a reason for hiding this comment

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

What is the background to this change?

@@ -17,21 +17,28 @@ import 'dart:io';
import 'package:google_generative_ai/google_generative_ai.dart';

final apiKey = () {
final apiKey = Platform.environment['GEMINI_API_KEY'];
final apiKey = Platform.environment['GOOGLE_API_KEY'];
Copy link
Collaborator

Choose a reason for hiding this comment

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

My understanding is that GEMINI_API_KEY is the standard across the SDKS.

#188 (comment)

exit(1);
}
return apiKey;
}();

Future<void> textGenTextOnlyPrompt() async {
// [START text_gen_text_only_prompt]
import 'package:google_generative_ai/google_generative_ai.dart';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not valid Dart. Imports may only be at the beginning of a library.

@natebosch
Copy link
Collaborator

#214 adds the imports in comments in each sample. Does that address your intentions with this change? That looks like what the JS SDK is doing.

Copy link

@iqbalbhatti49 iqbalbhatti49 left a comment

Choose a reason for hiding this comment

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

Review Comments:

  • The environment variable was updated from GEMINI_API_KEY to GOOGLE_API_KEY, aligning with platform conventions.
  • Initialization of the GenerativeModel and the example prompt were added, making the code more comprehensive and user-friendly. Great addition!
  • Error handling has been streamlined, and meaningful output (No $GOOGLE_API_KEY environment variable) improves debugging.

This update is well-executed and enhances functionality—nice work!

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.

3 participants