|
81 | 81 | "cell_type": "code", |
82 | 82 | "execution_count": null, |
83 | 83 | "metadata": {}, |
84 | | - "outputs": [], |
| 84 | + "outputs": [ |
| 85 | + { |
| 86 | + "name": "stderr", |
| 87 | + "output_type": "stream", |
| 88 | + "text": [ |
| 89 | + "/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", |
| 90 | + " from .autonotebook import tqdm as notebook_tqdm\n" |
| 91 | + ] |
| 92 | + } |
| 93 | + ], |
85 | 94 | "source": [ |
86 | 95 | "from openlayer.lib.integrations import trace_google_adk\n", |
87 | 96 | "\n", |
|
102 | 111 | "cell_type": "code", |
103 | 112 | "execution_count": null, |
104 | 113 | "metadata": {}, |
105 | | - "outputs": [], |
| 114 | + "outputs": [ |
| 115 | + { |
| 116 | + "name": "stdout", |
| 117 | + "output_type": "stream", |
| 118 | + "text": [ |
| 119 | + "Successfully streamed data to Openlayer. Response: {\n", |
| 120 | + " \"success\": true\n", |
| 121 | + "}\n" |
| 122 | + ] |
| 123 | + } |
| 124 | + ], |
106 | 125 | "source": [ |
107 | 126 | "\n", |
108 | 127 | "from google.genai import types\n", |
|
167 | 186 | "cell_type": "code", |
168 | 187 | "execution_count": null, |
169 | 188 | "metadata": {}, |
170 | | - "outputs": [], |
| 189 | + "outputs": [ |
| 190 | + { |
| 191 | + "name": "stderr", |
| 192 | + "output_type": "stream", |
| 193 | + "text": [ |
| 194 | + "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" |
| 195 | + ] |
| 196 | + }, |
| 197 | + { |
| 198 | + "name": "stdout", |
| 199 | + "output_type": "stream", |
| 200 | + "text": [ |
| 201 | + "Successfully streamed data to Openlayer. Response: {\n", |
| 202 | + " \"success\": true\n", |
| 203 | + "}\n" |
| 204 | + ] |
| 205 | + } |
| 206 | + ], |
171 | 207 | "source": [ |
172 | 208 | "import os\n", |
173 | 209 | "\n", |
|
286 | 322 | "\n", |
287 | 323 | "# 1. Before Agent Callback\n", |
288 | 324 | "# Called before the agent starts processing a request\n", |
289 | | - "def before_agent_callback(callback_context: CallbackContext) -> Optional[Any]:\n", |
| 325 | + "def before_agent_callback(callback_context: CallbackContext, **_kwargs: Any) -> Optional[Any]:\n", |
290 | 326 | " \"\"\"\n", |
291 | 327 | " Called before the agent starts its main work.\n", |
292 | 328 | " \n", |
|
305 | 341 | "\n", |
306 | 342 | "# 2. After Agent Callback\n", |
307 | 343 | "# Called after the agent finishes processing\n", |
308 | | - "def after_agent_callback(callback_context: CallbackContext) -> Optional[Any]:\n", |
| 344 | + "def after_agent_callback(callback_context: CallbackContext, **_kwargs: Any) -> Optional[Any]:\n", |
309 | 345 | " \"\"\"\n", |
310 | 346 | " Called after the agent has finished all its steps.\n", |
311 | 347 | " \n", |
|
324 | 360 | "# 3. Before Model Callback\n", |
325 | 361 | "# Called before each LLM call\n", |
326 | 362 | "def before_model_callback(\n", |
327 | | - " _callback_context: CallbackContext, \n", |
328 | | - " llm_request: LlmRequest\n", |
| 363 | + " _callback_context: CallbackContext,\n", |
| 364 | + " llm_request: LlmRequest,\n", |
| 365 | + " **_kwargs: Any\n", |
329 | 366 | ") -> Optional[LlmResponse]:\n", |
330 | 367 | " \"\"\"\n", |
331 | 368 | " Called before sending a request to the LLM.\n", |
|
346 | 383 | "# 4. After Model Callback\n", |
347 | 384 | "# Called after receiving LLM response\n", |
348 | 385 | "def after_model_callback(\n", |
349 | | - " _callback_context: CallbackContext, \n", |
350 | | - " llm_response: LlmResponse\n", |
| 386 | + " _callback_context: CallbackContext,\n", |
| 387 | + " llm_response: LlmResponse,\n", |
| 388 | + " **_kwargs: Any\n", |
351 | 389 | ") -> Optional[LlmResponse]:\n", |
352 | 390 | " \"\"\"\n", |
353 | 391 | " Called after receiving a response from the LLM.\n", |
|
370 | 408 | "# Called before tool execution\n", |
371 | 409 | "def before_tool_callback(\n", |
372 | 410 | " tool: BaseTool, \n", |
373 | | - " args: Dict[str, Any], \n", |
374 | | - " _tool_context: ToolContext\n", |
| 411 | + " _args: Dict[str, Any], \n", |
| 412 | + " _tool_context: ToolContext,\n", |
| 413 | + " **_kwargs: Any\n", |
375 | 414 | ") -> Optional[Dict]:\n", |
376 | 415 | " \"\"\"\n", |
377 | 416 | " Called before executing a tool.\n", |
|
395 | 434 | " tool: BaseTool, \n", |
396 | 435 | " _args: Dict[str, Any], \n", |
397 | 436 | " _tool_context: ToolContext, \n", |
398 | | - " tool_response: Dict\n", |
| 437 | + " tool_response: Dict,\n", |
| 438 | + " **_kwargs: Any\n", |
399 | 439 | ") -> Optional[Dict]:\n", |
400 | 440 | " \"\"\"\n", |
401 | 441 | " Called after a tool finishes execution.\n", |
|
436 | 476 | "\n", |
437 | 477 | "# Use different session IDs for callback agent\n", |
438 | 478 | "CALLBACK_USER_ID = \"user_789\"\n", |
439 | | - "CALLBACK_SESSION_ID = \"session_789\"\n", |
| 479 | + "CALLBACK_SESSION_ID = \"session_788\"\n", |
440 | 480 | "\n", |
441 | 481 | "# Create agent with ALL 6 callbacks\n", |
442 | 482 | "callback_agent = LlmAgent(\n", |
|
0 commit comments