You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Replace bare except with Exception (E722)
- Fix unused loop variable in notebook by using actual event_message
- Replace blind Exception assert with specific exceptions (B017)
"# The response is expected to be a list of TaskMessage objects, which is a union of the following types:\n",
59
-
"# - TextContent: A message with just text content \n",
60
-
"# - DataContent: A message with JSON-serializable data content\n",
61
-
"# - ToolRequestContent: A message with a tool request, which contains a JSON-serializable request to call a tool\n",
62
-
"# - ToolResponseContent: A message with a tool response, which contains response object from a tool call in its content\n",
63
-
"\n",
64
-
"# When processing the message/send response, if you are expecting more than TextContent, such as DataContent, ToolRequestContent, or ToolResponseContent, you can process them as well\n",
"\"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Hello, what can you do?\"},\n",
69
-
"\"task_id\": task.id,\n",
70
-
" },\n",
71
-
" {\n",
72
-
"\"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Can you tell me a joke?\"},\n",
73
-
"\"task_id\": task.id,\n",
74
-
" },\n",
75
-
" {\n",
76
-
"\"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"What is the capital of France?\"},\n",
77
-
"\"task_id\": task.id,\n",
78
-
" },\n",
79
-
" {\n",
80
-
"\"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Write a short story about a cat\"},\n",
81
-
"\"task_id\": task.id,\n",
82
-
" },\n",
83
-
" {\n",
84
-
"\"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Tell me how an LLM works\"},\n",
85
-
"\"task_id\": task.id,\n",
86
-
" },\n",
87
-
"]\n",
88
-
"\n",
89
-
"events: list[Event] = []\n",
90
-
"\n",
91
-
"for event_message in concurrent_event_messages:\n",
92
-
" rpc_response = client.agents.send_event(\n",
93
-
" agent_name=AGENT_NAME,\n",
94
-
" params={\n",
95
-
"\"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Hello tell me the latest news about AI and AI startups\"},\n",
96
-
"\"task_id\": task.id,\n",
97
-
" }\n",
98
-
" )\n",
99
-
"\n",
100
-
" event = rpc_response.result\n",
101
-
" events.append(event)\n",
102
-
"\n",
103
-
"for event in events:\n",
104
-
" print(event)"
105
-
]
53
+
"source": "from agentex.lib.utils.dev_tools import subscribe_to_async_task_messages\nfrom agentex.types import Event\nfrom agentex.types.agent_rpc_params import ParamsSendEventRequest\n\n# The response is expected to be a list of TaskMessage objects, which is a union of the following types:\n# - TextContent: A message with just text content \n# - DataContent: A message with JSON-serializable data content\n# - ToolRequestContent: A message with a tool request, which contains a JSON-serializable request to call a tool\n# - ToolResponseContent: A message with a tool response, which contains response object from a tool call in its content\n\n# When processing the message/send response, if you are expecting more than TextContent, such as DataContent, ToolRequestContent, or ToolResponseContent, you can process them as well\n\nconcurrent_event_messages: list[ParamsSendEventRequest] = [\n {\n \"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Hello, what can you do?\"},\n \"task_id\": task.id,\n },\n {\n \"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Can you tell me a joke?\"},\n \"task_id\": task.id,\n },\n {\n \"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"What is the capital of France?\"},\n \"task_id\": task.id,\n },\n {\n \"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Write a short story about a cat\"},\n \"task_id\": task.id,\n },\n {\n \"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Tell me how an LLM works\"},\n \"task_id\": task.id,\n },\n]\n\nevents: list[Event] = []\n\nfor event_message in concurrent_event_messages:\n rpc_response = client.agents.send_event(\n agent_name=AGENT_NAME,\n params=event_message\n )\n\n event = rpc_response.result\n events.append(event)\n\nfor event in events:\n print(event)"
0 commit comments