CLIEventHandler#
dbally.audit.CLIEventHandler
#
Bases: EventHandler
This handler displays all interactions between LLM and user happening during Collection.ask
execution inside the terminal.
Usage#
import dbally
from dbally.audit.event_handlers.cli_event_handler import CLIEventHandler
dbally.event_handlers = [CLIEventHandler()]
my_collection = dbally.create_collection("my_collection", llm)
After using CLIEventHandler
, during every Collection.ask
execution you will see output similar to the one below:
Source code in src/dbally/audit/event_handlers/cli_event_handler.py
request_start
async
#
request_start(user_request: RequestStart) -> None
Displays information about event starting to the terminal.
PARAMETER | DESCRIPTION |
---|---|
user_request |
Object containing name of collection and asked query
TYPE:
|
Source code in src/dbally/audit/event_handlers/cli_event_handler.py
event_start
async
#
event_start(event: Event, request_context: None) -> None
Displays information that event has started, then all messages inside the prompt
PARAMETER | DESCRIPTION |
---|---|
event |
db-ally event to be logged with all the details.
TYPE:
|
request_context |
Optional context passed from request_start method
TYPE:
|
Source code in src/dbally/audit/event_handlers/cli_event_handler.py
event_end
async
#
event_end(event: Optional[Event], request_context: None, event_context: None) -> None
Displays the response from the LLM.
PARAMETER | DESCRIPTION |
---|---|
event |
db-ally event to be logged with all the details.
TYPE:
|
request_context |
Optional context passed from request_start method
TYPE:
|
event_context |
Optional context passed from event_start method
TYPE:
|
Source code in src/dbally/audit/event_handlers/cli_event_handler.py
request_end
async
#
request_end(output: RequestEnd, request_context: Optional[dict] = None) -> None
Displays the output of the request, namely the results
and the context
PARAMETER | DESCRIPTION |
---|---|
output |
The output of the request.
TYPE:
|
request_context |
Optional context passed from request_start method
TYPE:
|