Skip to content

Commit 5110dc8

Browse files
Fix remaining linting issues
- 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)
1 parent 1a03a33 commit 5110dc8

File tree

3 files changed

+5
-56
lines changed

3 files changed

+5
-56
lines changed

examples/tutorials/10_agentic/00_base/080_batch_events/dev.ipynb

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -50,59 +50,7 @@
5050
"id": "3",
5151
"metadata": {},
5252
"outputs": [],
53-
"source": [
54-
"# Send an event to the agent\n",
55-
"from agentex.types import Event\n",
56-
"from agentex.types.agent_rpc_params import ParamsSendEventRequest\n",
57-
"\n",
58-
"# 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",
65-
"\n",
66-
"concurrent_event_messages: list[ParamsSendEventRequest] = [\n",
67-
" {\n",
68-
" \"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)"
10654
},
10755
{
10856
"cell_type": "code",
@@ -153,4 +101,4 @@
153101
},
154102
"nbformat": 4,
155103
"nbformat_minor": 5
156-
}
104+
}

examples/tutorials/10_agentic/10_temporal/030_custom_activities/project/workflow_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def dequeue_pending_data(queue: asyncio.Queue[Any], data_to_process: List[
3737
item = queue.get_nowait()
3838
data_to_process.append(item)
3939
items_dequeued += 1
40-
except:
40+
except Exception:
4141
# Queue became empty while we were dequeuing
4242
break
4343

tests/test_function_tool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Any
33

44
import pytest
5+
from pydantic import ValidationError
56

67
from src.agentex.lib.core.temporal.activities.adk.providers.openai_activities import (
78
FunctionTool,
@@ -225,7 +226,7 @@ def test_deserialization_error_handling(self):
225226
)
226227

227228
# This should raise an error during model validation due to invalid base64
228-
with pytest.raises(Exception): # Could be ValidationError or ValueError
229+
with pytest.raises((ValidationError, ValueError)):
229230
FunctionTool.model_validate(serialized_data)
230231

231232
def test_full_roundtrip_with_serialization(self):

0 commit comments

Comments
 (0)