File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,35 @@ class LogCollectorPlugin(BasePlugin):
36
36
"""
37
37
A plugin to programmatically and safely collect execution details from all
38
38
callbacks in async environments, organized by session ID.
39
+
40
+ The `session_id` is a user-defined string that you pass to the `Session`
41
+ object when you create it. This allows you to group all related logs for a
42
+ particular interaction or conversation.
43
+
44
+ Example usage:
45
+ >>> import asyncio
46
+ >>> from google.adk.agents import Agent
47
+ >>> from google.adk.plugins import LogCollectorPlugin
48
+ >>> from google.adk.runners import InMemoryRunner
49
+ >>>
50
+ >>> async def main():
51
+ ... log_plugin = LogCollectorPlugin()
52
+ ... agent = Agent(
53
+ ... # ... other agent parameters
54
+ ... )
55
+ ... runner = InMemoryRunner(agent=agent, plugins=[log_plugin])
56
+ ... session = await runner.session_service.create_session(
57
+ ... app_name=runner.app_name, user_id="test_user"
58
+ ... )
59
+ ... # Run the agent with the session
60
+ ... # await runner.run_async(...)
61
+ ... # Retrieve logs for the specific session
62
+ ... session_logs = log_plugin.get_logs_by_session(session.id)
63
+ ... print(session_logs)
64
+ >>>
65
+ >>> if __name__ == "__main__":
66
+ ... asyncio.run(main())
67
+
39
68
"""
40
69
41
70
def __init__ (self , name : str = "log_collector" ):
You can’t perform that action at this time.
0 commit comments