Skip to content

Commit d52c6c0

Browse files
committed
Add repro.py to show the problem with streaming
1 parent 81eaea5 commit d52c6c0

File tree

2 files changed

+773
-0
lines changed

2 files changed

+773
-0
lines changed

repro.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# /// script
2+
# requires-python = ">=3.9, <3.13"
3+
# dependencies = [
4+
# "google-cloud-aiplatform >= 1.64",
5+
# "numpy>=2",
6+
# "shapely>=2",
7+
# ]
8+
# ///
9+
10+
import vertexai
11+
from vertexai.generative_models import (
12+
Content,
13+
GenerativeModel,
14+
Part,
15+
)
16+
17+
18+
def main() -> None:
19+
vertexai.init(api_transport="rest")
20+
model = GenerativeModel("gemini-1.5-flash-002")
21+
res = list(
22+
model.generate_content(
23+
[
24+
Content(
25+
role="invalid_role",
26+
parts=[Part.from_text("Say this is a test")],
27+
)
28+
],
29+
stream=True,
30+
)
31+
)
32+
print(res)
33+
34+
35+
if __name__ == "__main__":
36+
main()

0 commit comments

Comments
 (0)