File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
2025/adk-agentengine-basic Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 77import argparse
88
99from vertexai import agent_engines
10- from vertexai .generative_models ._generative_models import Content
1110
1211# --- 定数定義 ---
1312USER_ID = "test_user01"
14- TARGET_AUTHOR = "podcast_creator"
13+ TARGET_AUTHORS = [ "podcast_creator" , "learning_assistant" ,]
1514
1615# --- カスタム例外定義 ---
1716class AgentEngineError (Exception ):
@@ -72,11 +71,13 @@ def stream_agent_query(agent: agent_engines.AgentEngine, message: str) -> None:
7271 print ("\n --- エージェントからのレスポンス ---\n " )
7372 for event in response_stream :
7473 try :
75- if event .get ("author" ) != TARGET_AUTHOR :
74+ if event .get ("author" ) not in TARGET_AUTHORS :
75+ continue
76+
77+ text = event ["content" ]["parts" ][0 ]["text" ]
78+ if not text :
7679 continue
7780
78- content : Content = event ["content" ]
79- text = content .parts [0 ].text
8081 print (text , end = "" , flush = True )
8182
8283 except (KeyError , IndexError , TypeError , AttributeError ):
You can’t perform that action at this time.
0 commit comments