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
{{ message }}
Repository navigation
Commit bbc9e02
Browse filesBrowse the repository at this point in the historyBrowse files
"# (REQUIRED) Create a new task. For Async agents, you must create a task for messages to be associated with.\n",
33
+
"import uuid\n",
34
+
"\n",
35
+
"rpc_response = client.agents.create_task(\n",
36
+
" agent_name=AGENT_NAME,\n",
37
+
" params={\n",
38
+
"\"name\": f\"{str(uuid.uuid4())[:8]}-task\",\n",
39
+
"\"params\": {}\n",
40
+
" }\n",
41
+
")\n",
42
+
"\n",
43
+
"task = rpc_response.result\n",
44
+
"print(task)"
45
+
]
46
+
},
47
+
{
48
+
"cell_type": "code",
49
+
"execution_count": null,
50
+
"id": "b03b0d37",
51
+
"metadata": {},
52
+
"outputs": [],
53
+
"source": [
54
+
"# Send an event to the agent\n",
55
+
"\n",
56
+
"# The response is expected to be a list of TaskMessage objects, which is a union of the following types:\n",
57
+
"# - TextContent: A message with just text content \n",
58
+
"# - DataContent: A message with JSON-serializable data content\n",
59
+
"# - ToolRequestContent: A message with a tool request, which contains a JSON-serializable request to call a tool\n",
60
+
"# - ToolResponseContent: A message with a tool response, which contains response object from a tool call in its content\n",
61
+
"\n",
62
+
"# 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",
63
+
"\n",
64
+
"rpc_response = client.agents.send_event(\n",
65
+
" agent_name=AGENT_NAME,\n",
66
+
" params={\n",
67
+
"\"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Hello what can you do?\"},\n",
68
+
"\"task_id\": task.id,\n",
69
+
" }\n",
70
+
")\n",
71
+
"\n",
72
+
"event = rpc_response.result\n",
73
+
"print(event)"
74
+
]
75
+
},
76
+
{
77
+
"cell_type": "code",
78
+
"execution_count": null,
79
+
"id": "a6927cc0",
80
+
"metadata": {},
81
+
"outputs": [],
82
+
"source": [
83
+
"# Subscribe to the async task messages produced by the agent\n",
0 commit comments