Skip to content

Commit 5b7b3a1

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

File tree

2 files changed

+636
-0
lines changed

2 files changed

+636
-0
lines changed

repro.py

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

0 commit comments

Comments
 (0)