Skip to content

Commit 9f359b0

Browse files
authored
feat: refactor text-only Gemini prompt (GoogleCloudPlatform#11756)
* feat: refactor text-only Gemini prompt * keep prompt to one line with no escape char * trigger build * trigger build * add location back into init per DPE
1 parent 39ba327 commit 9f359b0

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

generative_ai/gemini_text_input_example.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def generate_from_text_input(project_id: str) -> str:
1717
# [START generativeaionvertexai_gemini_generate_from_text_input]
1818
import vertexai
19-
from vertexai.generative_models import GenerativeModel, Part
19+
from vertexai.generative_models import GenerativeModel
2020

2121
# TODO(developer): Update and un-comment below line
2222
# project_id = "PROJECT_ID"
@@ -26,22 +26,7 @@ def generate_from_text_input(project_id: str) -> str:
2626
model = GenerativeModel(model_name="gemini-1.0-pro-002")
2727

2828
response = model.generate_content(
29-
[
30-
# Does the returned sentiment score match the reviewer's movie rating?
31-
Part.from_text(
32-
"""Give a score from 1 - 10 to suggest if the
33-
following movie review is negative or positive (1 is most
34-
negative, 10 is most positive, 5 will be neutral). Include an
35-
explanation.
36-
37-
The movie takes some time to build, but that is part of its beauty.
38-
By the time you are hooked, this tale of friendship and hope is
39-
thrilling and affecting, until the very last scene. You will find
40-
yourself rooting for the hero every step of the way. This is the
41-
sharpest, most original animated film I have seen in years.
42-
I would give it 8 out of 10 stars."""
43-
)
44-
]
29+
"What's a good name for a flower shop that specializes in selling bouquets of dried flowers?"
4530
)
4631

4732
print(response.text)

0 commit comments

Comments
 (0)