Skip to content

Commit 4546c0b

Browse files
committed
updated readmes and added a .gitigore
1 parent 9870254 commit 4546c0b

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode

README.md

+30-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
# Gemini API examples
22

3-
This repo contains sample code for key features of the Gemini API. The repo is
4-
organized by programming language.
5-
6-
These samples are embedded in parts of the
7-
[documentation](https://ai.google.dev), most notably in the
8-
[API reference](https://ai.google.dev/api).
9-
10-
Each file is structured as a runnable test case, ensuring that samples are
11-
executable and functional. Each test demonstrates a single concept, and contains
12-
region tags that are used to demarcate the test scaffolding from the spotlight
13-
code. If you are contributing, code within region tags should follow sample code
14-
best practices - being clear, complete and concise.
3+
This repository contains example code for key features of the Gemini API. The
4+
repo is organized by programming language.
5+
6+
The examples are embedded in the
7+
[Gemini API reference](https://ai.google.dev/api) and other places in the
8+
developer documentation.
9+
10+
Each file is structured as a runnable test case, ensuring that examples are
11+
executable and functional. Each test demonstrates a single concept and contains
12+
special comments called _region tags_ that demarcate the test scaffolding from
13+
the example code snippet. Here's a Python example:
14+
15+
```python
16+
def test_text_gen_text_only_prompt(self):
17+
# [START text_gen_text_only_prompt]
18+
from google import genai
19+
20+
client = genai.Client()
21+
response = client.models.generate_content(
22+
model="gemini-2.0-flash", contents="Write a story about a magic backpack."
23+
)
24+
print(response.text)
25+
# [END text_gen_text_only_prompt]
26+
```
27+
28+
The API reference can then be configured to show the code between the region
29+
tags.
30+
31+
If you're contributing, please make sure that the code within region tags
32+
follows best practices for example code: clear, complete, and concise.

python/README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ This directory contains examples of working with the Gemini API using the
55

66
## Install dependencies
77

8-
pip install absl-py google-genai Pillow
8+
pip install absl-py google-genai Pillow pyink
99

1010
## Run a test file
1111

12-
python <filename>.py
12+
python <filename>.py
13+
14+
## Format code
15+
16+
We use [pyink](https://pypi.org/project/pyink/) for code formatting. To format
17+
the all the files in this directory, run:
18+
19+
pyink .

0 commit comments

Comments
 (0)