-
Notifications
You must be signed in to change notification settings - Fork 121
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
base: main
Are you sure you want to change the base?
Conversation
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.
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']; |
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.
My understanding is that GEMINI_API_KEY
is the standard across the SDKS.
exit(1); | ||
} | ||
return apiKey; | ||
}(); | ||
|
||
Future<void> textGenTextOnlyPrompt() async { | ||
// [START text_gen_text_only_prompt] | ||
import 'package:google_generative_ai/google_generative_ai.dart'; |
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.
This is not valid Dart. Imports may only be at the beginning of a library.
#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. |
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.
Review Comments:
- The environment variable was updated from
GEMINI_API_KEY
toGOOGLE_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!
No description provided.