Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 53 additions & 13 deletions examples/tracing/google-adk/google_adk_tracing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,16 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you clean the outputs of all cells of the notebook?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

"name": "stderr",
"output_type": "stream",
"text": [
"/Users/vini/Workspace/Openlayer/integrations-sdks/openlayer-python/.venv/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"source": [
"from openlayer.lib.integrations import trace_google_adk\n",
"\n",
Expand All @@ -102,7 +111,17 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Successfully streamed data to Openlayer. Response: {\n",
" \"success\": true\n",
"}\n"
]
}
],
"source": [
"\n",
"from google.genai import types\n",
Expand Down Expand Up @@ -167,7 +186,24 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Warning: there are non-text parts in the response: ['function_call', 'function_call'], returning concatenated text result from text parts. Check the full candidates.content.parts accessor to get the full model response.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Successfully streamed data to Openlayer. Response: {\n",
" \"success\": true\n",
"}\n"
]
}
],
"source": [
"import os\n",
"\n",
Expand Down Expand Up @@ -286,7 +322,7 @@
"\n",
"# 1. Before Agent Callback\n",
"# Called before the agent starts processing a request\n",
"def before_agent_callback(callback_context: CallbackContext) -> Optional[Any]:\n",
"def before_agent_callback(callback_context: CallbackContext, **_kwargs: Any) -> Optional[Any]:\n",
" \"\"\"\n",
" Called before the agent starts its main work.\n",
" \n",
Expand All @@ -305,7 +341,7 @@
"\n",
"# 2. After Agent Callback\n",
"# Called after the agent finishes processing\n",
"def after_agent_callback(callback_context: CallbackContext) -> Optional[Any]:\n",
"def after_agent_callback(callback_context: CallbackContext, **_kwargs: Any) -> Optional[Any]:\n",
" \"\"\"\n",
" Called after the agent has finished all its steps.\n",
" \n",
Expand All @@ -324,8 +360,9 @@
"# 3. Before Model Callback\n",
"# Called before each LLM call\n",
"def before_model_callback(\n",
" _callback_context: CallbackContext, \n",
" llm_request: LlmRequest\n",
" _callback_context: CallbackContext,\n",
" llm_request: LlmRequest,\n",
" **_kwargs: Any\n",
") -> Optional[LlmResponse]:\n",
" \"\"\"\n",
" Called before sending a request to the LLM.\n",
Expand All @@ -346,8 +383,9 @@
"# 4. After Model Callback\n",
"# Called after receiving LLM response\n",
"def after_model_callback(\n",
" _callback_context: CallbackContext, \n",
" llm_response: LlmResponse\n",
" _callback_context: CallbackContext,\n",
" llm_response: LlmResponse,\n",
" **_kwargs: Any\n",
") -> Optional[LlmResponse]:\n",
" \"\"\"\n",
" Called after receiving a response from the LLM.\n",
Expand All @@ -370,8 +408,9 @@
"# Called before tool execution\n",
"def before_tool_callback(\n",
" tool: BaseTool, \n",
" args: Dict[str, Any], \n",
" _tool_context: ToolContext\n",
" _args: Dict[str, Any], \n",
" _tool_context: ToolContext,\n",
" **_kwargs: Any\n",
") -> Optional[Dict]:\n",
" \"\"\"\n",
" Called before executing a tool.\n",
Expand All @@ -395,7 +434,8 @@
" tool: BaseTool, \n",
" _args: Dict[str, Any], \n",
" _tool_context: ToolContext, \n",
" tool_response: Dict\n",
" tool_response: Dict,\n",
" **_kwargs: Any\n",
") -> Optional[Dict]:\n",
" \"\"\"\n",
" Called after a tool finishes execution.\n",
Expand Down Expand Up @@ -436,7 +476,7 @@
"\n",
"# Use different session IDs for callback agent\n",
"CALLBACK_USER_ID = \"user_789\"\n",
"CALLBACK_SESSION_ID = \"session_789\"\n",
"CALLBACK_SESSION_ID = \"session_788\"\n",
"\n",
"# Create agent with ALL 6 callbacks\n",
"callback_agent = LlmAgent(\n",
Expand Down
Loading