-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: gemini code samples updates (#11579)
* chore: minor code readability improvements * feat: update region tags and imports * move region tags & imports to inside a function * feat: Add readme notes for Generative AI sample developers * chore: simplify README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
768f82b
commit dfafd5f
Showing
18 changed files
with
134 additions
and
90 deletions.
There are no files selected for viewing
This file contains 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,49 @@ | ||
# Generative AI on Google Cloud | ||
|
||
Product Page: https://cloud.google.com/ai/generative-ai?hl=en | ||
Code samples: https://cloud.google.com/docs/samples?text=Generative%20AI | ||
|
||
## Developer Notes | ||
|
||
In developing code samples for Generative AI products, a scripting style format is recommended. It's important to wrap the code samples and region tags to be with in a function definition. | ||
|
||
This change is motivated by the desire to provide a code format that can effortlessly integrate with popular data science community tools. These tools include Colab, Jupyter Notebooks, and the IPython shell. | ||
|
||
Example: | ||
|
||
```python | ||
def create_hello_world_file(filename): | ||
# <region tag: starts here> | ||
import os | ||
|
||
# TODO(developer): Update and uncomment below code | ||
# filename = `/tmp/test.txt` | ||
|
||
if os.path.isfile(filename): | ||
print(f'Overriding content in file(name: {filename})!') | ||
|
||
with open(filename) as fp: | ||
fp.write('Hello world!') | ||
# <region tag: ends here> | ||
``` | ||
|
||
In Google Cloud documentation page, code sample is shown as below | ||
|
||
```python | ||
import os | ||
|
||
# TODO(developer): Update and uncomment below code | ||
# filename = `/tmp/test.txt` | ||
|
||
if os.path.isfile(filename): | ||
print(f'Overriding content in file(name: {filename})!') | ||
|
||
with open(filename) as fp: | ||
fp.write('Hello world!') | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains 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 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 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.