Skip to content

Commit 04c50bf

Browse files
authored
add test
1 parent deb7a5e commit 04c50bf

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

genai/text_generation/test_text_generation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@
3131
import textgen_with_txt_stream
3232
import textgen_with_video
3333
import textgen_with_youtube_video
34+
import txt_gen
3435

3536

3637
os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "True"
3738
os.environ["GOOGLE_CLOUD_LOCATION"] = "us-central1"
3839
# The project name is included in the CICD pipeline
3940
# os.environ['GOOGLE_CLOUD_PROJECT'] = "add-your-project-name"
4041

42+
def test_txt_gen() -> None:
43+
response = txt_gen.generate_content()
44+
assert response
4145

4246
def test_textgen_with_txt_stream() -> None:
4347
response = textgen_with_txt_stream.generate_content()

genai/text_generation/txt_gen.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
from google import genai
21

3-
client = genai.Client(http_options={'api_version': 'v1'})
4-
response = client.models.generate_content(
5-
model="gemini-2.0-flash-001",
6-
contents="How does AI work?"
7-
)
8-
print(response.text)
9-
# Example response:
10-
# Okay, let's break down how AI works. It's a broad field, so I'll focus on the ...
11-
#
12-
# Here's a simplified overview:
13-
# ...
2+
def generate_content():
3+
from google import genai
4+
5+
client = genai.Client(http_options={'api_version': 'v1'})
6+
response = client.models.generate_content(
7+
model="gemini-2.0-flash-001",
8+
contents="How does AI work?"
9+
)
10+
return response.text
11+
# Example response:
12+
# Okay, let's break down how AI works. It's a broad field, so I'll focus on the ...
13+
#
14+
# Here's a simplified overview:
15+
# ...

0 commit comments

Comments
 (0)