Skip to content

Commit b185708

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

File tree

2 files changed

+637
-0
lines changed

2 files changed

+637
-0
lines changed

repro.py

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

0 commit comments

Comments
 (0)