Observe
Functions to observe and store LLM calls and Tapes in a persistent storage
Classes:
Functions:
-
init_sqlite_if_not_exists
–Ensure that the tables exist in the sqlite database.
-
sqlite_store_llm_call
–Standalone function to store LLM calls.
SQLiteWriterThread
Methods:
-
__enter__
–Start the SQLite queue writer when entering the context.
-
__exit__
–Stop the SQLite queue writer when exiting the context.
-
wait_for_empty
–Wait for the queue to be empty and all tasks to be processed.
Attributes:
Source code in tapeagents/observe.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
is_empty: bool
property
Check if the queue is empty.
queue: Optional[queue.Queue]
property
Access the write queue.
__enter__()
Start the SQLite queue writer when entering the context.
Source code in tapeagents/observe.py
261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
__exit__(exc_type, exc_val, exc_tb)
Stop the SQLite queue writer when exiting the context.
Source code in tapeagents/observe.py
275 276 277 278 279 280 281 282 283 284 285 286 |
|
wait_for_empty(timeout=None)
Wait for the queue to be empty and all tasks to be processed.
Source code in tapeagents/observe.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
init_sqlite_if_not_exists(only_once=True)
Ensure that the tables exist in the sqlite database.
This is only done once per Python process. If you want to change the SQLite path during at run time, you can run this function manually with only_once=False.
Source code in tapeagents/observe.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
sqlite_store_llm_call(call)
Standalone function to store LLM calls.
Will use the queue if available (within context manager), otherwise falls back to single-threaded mode.
Source code in tapeagents/observe.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|