Skip to content

Commit b5a8a8b

Browse files
committed
updated agentex init templates
1 parent c97fd2f commit b5a8a8b

File tree

8 files changed

+346
-181
lines changed

8 files changed

+346
-181
lines changed

examples/tutorials/00_sync/020_streaming/dev.ipynb

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"id": "36834357",
77
"metadata": {},
88
"outputs": [],
@@ -14,7 +14,7 @@
1414
},
1515
{
1616
"cell_type": "code",
17-
"execution_count": 2,
17+
"execution_count": null,
1818
"id": "d1c309d6",
1919
"metadata": {},
2020
"outputs": [],
@@ -24,7 +24,7 @@
2424
},
2525
{
2626
"cell_type": "code",
27-
"execution_count": 3,
27+
"execution_count": null,
2828
"id": "9f6e6ef0",
2929
"metadata": {},
3030
"outputs": [],
@@ -50,36 +50,10 @@
5050
},
5151
{
5252
"cell_type": "code",
53-
"execution_count": 9,
53+
"execution_count": null,
5454
"id": "b03b0d37",
5555
"metadata": {},
56-
"outputs": [
57-
{
58-
"name": "stdout",
59-
"output_type": "stream",
60-
"text": [
61-
"AGENT [07/27/2025 00:52:20]\n",
62-
"Hello! I can assist you with a variety of tasks, including:\n",
63-
"\n",
64-
"1. **Answering Questions**: I can provide information on a wide range of topics, including science, history, technology, and more.\n",
65-
"\n",
66-
"2. **Providing Explanations**: If you need clarification on a concept or topic, I can help explain it in simpler terms.\n",
67-
"\n",
68-
"3. **Offering Writing Assistance**: I can help you with writing tasks, such as drafting emails, essays, or creative writing, and provide editing suggestions.\n",
69-
"\n",
70-
"4. **Language Help**: I can assist with language learning, including vocabulary, grammar, and translations in multiple languages.\n",
71-
"\n",
72-
"5. **Research Support**: I can help you find facts or summarize information on specific subjects.\n",
73-
"\n",
74-
"6. **General Advice**: I can provide tips or suggestions on various life topics, such as study techniques, productivity, or personal development.\n",
75-
"\n",
76-
"7. **Fun and Games**: If you’re looking for entertainment, I can generate quizzes, riddles, or engage in light-hearted conversation.\n",
77-
"\n",
78-
"Feel free to ask me anything specific you have in mind!\n",
79-
"\n"
80-
]
81-
}
82-
],
56+
"outputs": [],
8357
"source": [
8458
"# Test non streaming response\n",
8559
"from typing import List, cast\n",
@@ -120,28 +94,10 @@
12094
},
12195
{
12296
"cell_type": "code",
123-
"execution_count": 10,
97+
"execution_count": null,
12498
"id": "79688331",
12599
"metadata": {},
126-
"outputs": [
127-
{
128-
"name": "stdout",
129-
"output_type": "stream",
130-
"text": [
131-
"Hello! I can assist you with a variety of tasks, including:\n",
132-
"\n",
133-
"1. Answering questions and providing information on a wide range of topics.\n",
134-
"2. Offering explanations or summaries of concepts.\n",
135-
"3. Helping with writing, including essays, reports, and creative writing.\n",
136-
"4. Assisting with problem-solving in subjects like math and science.\n",
137-
"5. Providing language translation or helping with language learning.\n",
138-
"6. Offering recommendations for books, movies, or other media.\n",
139-
"7. Engaging in conversation and discussion on various topics.\n",
140-
"\n",
141-
"If you have something specific you need help with, just let me know!"
142-
]
143-
}
144-
],
100+
"outputs": [],
145101
"source": [
146102
"# Test streaming response\n",
147103
"import json\n",

examples/tutorials/10_agentic/00_base/020_streaming/dev.ipynb

Lines changed: 7 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 6,
5+
"execution_count": null,
66
"id": "36834357",
77
"metadata": {},
88
"outputs": [],
@@ -14,7 +14,7 @@
1414
},
1515
{
1616
"cell_type": "code",
17-
"execution_count": 7,
17+
"execution_count": null,
1818
"id": "d1c309d6",
1919
"metadata": {},
2020
"outputs": [],
@@ -24,18 +24,10 @@
2424
},
2525
{
2626
"cell_type": "code",
27-
"execution_count": 8,
27+
"execution_count": null,
2828
"id": "9f6e6ef0",
2929
"metadata": {},
30-
"outputs": [
31-
{
32-
"name": "stdout",
33-
"output_type": "stream",
34-
"text": [
35-
"Task(id='fab911e3-47c5-43f2-9942-382a98d45975', created_at=datetime.datetime(2025, 7, 27, 0, 52, 55, 493055, tzinfo=TzInfo(UTC)), name='69297be2-task', status='RUNNING', status_reason='Task created, forwarding to ACP server', updated_at=datetime.datetime(2025, 7, 27, 0, 52, 55, 493055, tzinfo=TzInfo(UTC)))\n"
36-
]
37-
}
38-
],
30+
"outputs": [],
3931
"source": [
4032
"# (REQUIRED) Create a new task. For Agentic agents, you must create a task for messages to be associated with.\n",
4133
"\n",
@@ -64,15 +56,7 @@
6456
"execution_count": null,
6557
"id": "b03b0d37",
6658
"metadata": {},
67-
"outputs": [
68-
{
69-
"name": "stdout",
70-
"output_type": "stream",
71-
"text": [
72-
"Event(id='6f1c066c-f400-49a5-a8bd-afe0f2367b4c', agent_id='ef21f2e7-5bbe-440a-824b-7e89f462a781', sequence_id=203, task_id='fab911e3-47c5-43f2-9942-382a98d45975', content=TextContent(author='user', content='Hello what can you do?', attachments=None, format='plain', style='static', type='text'), created_at=datetime.datetime(2025, 7, 27, 0, 52, 56, 693376, tzinfo=TzInfo(UTC)))\n"
73-
]
74-
}
75-
],
59+
"outputs": [],
7660
"source": [
7761
"# Test non streaming response\n",
7862
"from typing import cast\n",
@@ -101,85 +85,10 @@
10185
},
10286
{
10387
"cell_type": "code",
104-
"execution_count": 10,
88+
"execution_count": null,
10589
"id": "a6927cc0",
10690
"metadata": {},
107-
"outputs": [
108-
{
109-
"data": {
110-
"text/html": [
111-
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #00ffff; text-decoration-color: #00ffff\">╭───────────────────────── </span><span style=\"color: #00ffff; text-decoration-color: #00ffff; font-weight: bold\">USER</span><span style=\"color: #00ffff; text-decoration-color: #00ffff\"> [07/27/2025 00:52:56] ─────────────────────────╮</span>\n",
112-
"<span style=\"color: #00ffff; text-decoration-color: #00ffff\">│</span> Hello what can you do? <span style=\"color: #00ffff; text-decoration-color: #00ffff\">│</span>\n",
113-
"<span style=\"color: #00ffff; text-decoration-color: #00ffff\">╰──────────────────────────────────────────────────────────────────────────────╯</span>\n",
114-
"</pre>\n"
115-
],
116-
"text/plain": [
117-
"\u001b[96m╭─\u001b[0m\u001b[96m────────────────────────\u001b[0m\u001b[96m \u001b[0m\u001b[1;96mUSER\u001b[0m\u001b[96m [07/27/2025 00:52:56] \u001b[0m\u001b[96m────────────────────────\u001b[0m\u001b[96m─╮\u001b[0m\n",
118-
"\u001b[96m│\u001b[0m Hello what can you do? \u001b[96m│\u001b[0m\n",
119-
"\u001b[96m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
120-
]
121-
},
122-
"metadata": {},
123-
"output_type": "display_data"
124-
},
125-
{
126-
"name": "stdout",
127-
"output_type": "stream",
128-
"text": [
129-
" \r"
130-
]
131-
},
132-
{
133-
"data": {
134-
"text/html": [
135-
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #00ff00; text-decoration-color: #00ff00\">╭──────────────────────── </span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">AGENT</span><span style=\"color: #00ff00; text-decoration-color: #00ff00\"> [07/27/2025 00:52:56] ─────────────────────────╮</span>\n",
136-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> Hello! I can assist you with a variety of tasks, such as: <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
137-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
138-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span>Answering questions on a wide range of topics, including science, <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
139-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>history, technology, and more. <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
140-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span>Providing explanations and summaries of complex concepts. <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
141-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span>Assisting with language translations and grammar checks. <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
142-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 4 </span>Offering writing tips, editing assistance, and brainstorming ideas for <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
143-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>creative projects. <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
144-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 5 </span>Giving advice on studying, time management, and organization. <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
145-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 6 </span>Sharing information about books, movies, and other media. <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
146-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 7 </span>Engaging in general conversation or providing entertainment. <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
147-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
148-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> If you have a specific question or need help with something, feel free to <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
149-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span> ask! <span style=\"color: #00ff00; text-decoration-color: #00ff00\">│</span>\n",
150-
"<span style=\"color: #00ff00; text-decoration-color: #00ff00\">╰──────────────────────────────────────────────────────────────────────────────╯</span>\n",
151-
"</pre>\n"
152-
],
153-
"text/plain": [
154-
"\u001b[92m╭─\u001b[0m\u001b[92m───────────────────────\u001b[0m\u001b[92m \u001b[0m\u001b[1;92mAGENT\u001b[0m\u001b[92m [07/27/2025 00:52:56] \u001b[0m\u001b[92m────────────────────────\u001b[0m\u001b[92m─╮\u001b[0m\n",
155-
"\u001b[92m│\u001b[0m Hello! I can assist you with a variety of tasks, such as: \u001b[92m│\u001b[0m\n",
156-
"\u001b[92m│\u001b[0m \u001b[92m│\u001b[0m\n",
157-
"\u001b[92m│\u001b[0m \u001b[1;33m 1 \u001b[0mAnswering questions on a wide range of topics, including science, \u001b[92m│\u001b[0m\n",
158-
"\u001b[92m│\u001b[0m \u001b[1;33m \u001b[0mhistory, technology, and more. \u001b[92m│\u001b[0m\n",
159-
"\u001b[92m│\u001b[0m \u001b[1;33m 2 \u001b[0mProviding explanations and summaries of complex concepts. \u001b[92m│\u001b[0m\n",
160-
"\u001b[92m│\u001b[0m \u001b[1;33m 3 \u001b[0mAssisting with language translations and grammar checks. \u001b[92m│\u001b[0m\n",
161-
"\u001b[92m│\u001b[0m \u001b[1;33m 4 \u001b[0mOffering writing tips, editing assistance, and brainstorming ideas for \u001b[92m│\u001b[0m\n",
162-
"\u001b[92m│\u001b[0m \u001b[1;33m \u001b[0mcreative projects. \u001b[92m│\u001b[0m\n",
163-
"\u001b[92m│\u001b[0m \u001b[1;33m 5 \u001b[0mGiving advice on studying, time management, and organization. \u001b[92m│\u001b[0m\n",
164-
"\u001b[92m│\u001b[0m \u001b[1;33m 6 \u001b[0mSharing information about books, movies, and other media. \u001b[92m│\u001b[0m\n",
165-
"\u001b[92m│\u001b[0m \u001b[1;33m 7 \u001b[0mEngaging in general conversation or providing entertainment. \u001b[92m│\u001b[0m\n",
166-
"\u001b[92m│\u001b[0m \u001b[92m│\u001b[0m\n",
167-
"\u001b[92m│\u001b[0m If you have a specific question or need help with something, feel free to \u001b[92m│\u001b[0m\n",
168-
"\u001b[92m│\u001b[0m ask! \u001b[92m│\u001b[0m\n",
169-
"\u001b[92m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
170-
]
171-
},
172-
"metadata": {},
173-
"output_type": "display_data"
174-
},
175-
{
176-
"name": "stdout",
177-
"output_type": "stream",
178-
"text": [
179-
"Streaming timed out after 5 seconds - returning collected messages\n"
180-
]
181-
}
182-
],
91+
"outputs": [],
18392
"source": [
18493
"from agentex.lib.utils.dev_tools import subscribe_to_async_task_messages\n",
18594
"\n",
@@ -192,14 +101,6 @@
192101
" timeout=5,\n",
193102
")"
194103
]
195-
},
196-
{
197-
"cell_type": "code",
198-
"execution_count": null,
199-
"id": "6470ae58",
200-
"metadata": {},
201-
"outputs": [],
202-
"source": []
203104
}
204105
],
205106
"metadata": {

src/agentex/lib/cli/commands/init.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ def create_project_structure(
7575
root_templates["requirements.txt.j2"] = "requirements.txt"
7676
root_templates["Dockerfile.j2"] = "Dockerfile"
7777

78-
# Add development notebook for sync agents
79-
if template_type == TemplateType.SYNC:
80-
root_templates["dev.ipynb.j2"] = "dev.ipynb"
78+
# Add development notebook for agents
79+
root_templates["dev.ipynb.j2"] = "dev.ipynb"
8180

8281
for template, output in root_templates.items():
8382
output_path = project_dir / output
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "36834357",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"from agentex import Agentex\n",
11+
"\n",
12+
"client = Agentex(base_url=\"http://localhost:5003\")"
13+
]
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": null,
18+
"id": "d1c309d6",
19+
"metadata": {},
20+
"outputs": [],
21+
"source": [
22+
"AGENT_NAME = \"{{ agent_name }}\""
23+
]
24+
},
25+
{
26+
"cell_type": "code",
27+
"execution_count": null,
28+
"id": "9f6e6ef0",
29+
"metadata": {},
30+
"outputs": [],
31+
"source": [
32+
"# (REQUIRED) Create a new task. For Agentic agents, you must create a task for messages to be associated with.\n",
33+
"\n",
34+
"from typing import cast\n",
35+
"import uuid\n",
36+
"\n",
37+
"from agentex.types import Task\n",
38+
"\n",
39+
"TASK_ID = str(uuid.uuid4())[:8]\n",
40+
"\n",
41+
"rpc_response = client.agents.rpc_by_name(\n",
42+
" agent_name=AGENT_NAME,\n",
43+
" method=\"task/create\",\n",
44+
" params={\n",
45+
" \"name\": f\"{TASK_ID}-task\",\n",
46+
" \"params\": {}\n",
47+
" }\n",
48+
")\n",
49+
"\n",
50+
"task = cast(Task, rpc_response.result)\n",
51+
"print(task)"
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": null,
57+
"id": "b03b0d37",
58+
"metadata": {},
59+
"outputs": [],
60+
"source": [
61+
"# Test non streaming response\n",
62+
"from typing import cast\n",
63+
"from agentex.types import Event\n",
64+
"\n",
65+
"# The response is expected to be a list of TaskMessage objects, which is a union of the following types:\n",
66+
"# - TextContent: A message with just text content \n",
67+
"# - DataContent: A message with JSON-serializable data content\n",
68+
"# - ToolRequestContent: A message with a tool request, which contains a JSON-serializable request to call a tool\n",
69+
"# - ToolResponseContent: A message with a tool response, which contains response object from a tool call in its content\n",
70+
"\n",
71+
"# 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",
72+
"\n",
73+
"rpc_response = client.agents.rpc_by_name(\n",
74+
" agent_name=AGENT_NAME,\n",
75+
" method=\"event/send\",\n",
76+
" params={\n",
77+
" \"content\": {\"type\": \"text\", \"author\": \"user\", \"content\": \"Hello what can you do?\"},\n",
78+
" \"task_id\": task.id,\n",
79+
" }\n",
80+
")\n",
81+
"\n",
82+
"event = cast(Event, rpc_response.result)\n",
83+
"print(event)"
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": null,
89+
"id": "a6927cc0",
90+
"metadata": {},
91+
"outputs": [],
92+
"source": [
93+
"from agentex.lib.utils.dev_tools import subscribe_to_async_task_messages\n",
94+
"\n",
95+
"task_messages = subscribe_to_async_task_messages(\n",
96+
" client=client,\n",
97+
" task=task, \n",
98+
" only_after_timestamp=event.created_at, \n",
99+
" print_messages=True,\n",
100+
" rich_print=True,\n",
101+
" timeout=5,\n",
102+
")"
103+
]
104+
}
105+
],
106+
"metadata": {
107+
"kernelspec": {
108+
"display_name": ".venv",
109+
"language": "python",
110+
"name": "python3"
111+
},
112+
"language_info": {
113+
"codemirror_mode": {
114+
"name": "ipython",
115+
"version": 3
116+
},
117+
"file_extension": ".py",
118+
"mimetype": "text/x-python",
119+
"name": "python",
120+
"nbconvert_exporter": "python",
121+
"pygments_lexer": "ipython3",
122+
"version": "3.12.9"
123+
}
124+
},
125+
"nbformat": 4,
126+
"nbformat_minor": 5
127+
}

0 commit comments

Comments
 (0)