-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Implement global event handlers #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
d2d7acf
Feat: Implement global event handlers
karllu3 434e37a
enhancments
karllu3 c5b5f80
fix linters
karllu3 e5a808b
global variables moved to module
karllu3 e1d09c0
event handlers
karllu3 ae5d838
wrap into singleton
karllu3 933a696
collection ehnacmentS
karllu3 200eaf1
singleton remove
karllu3 aa3ea91
fixups
karllu3 0f7a20a
fixups
karllu3 f654d84
fixups
karllu3 7222425
fixups
karllu3 2c5bbd0
fixups
karllu3 70141cc
fixup
karllu3 272a523
fixup
karllu3 068c345
fixups
karllu3 d8466ba
global event handlers
karllu3 18b1637
cirucalr
karllu3 f30c965
pylint check
karllu3 d1aa012
fixups
karllu3 4552d85
comment fixups
karllu3 db3fc6f
Revert "fixups"
karllu3 94ab6c7
move create collections to collections
karllu3 219c52d
pre commit
karllu3 1f0ecbb
review fixups
karllu3 efdca49
event handler type
karllu3 2d08917
Remove cyclic with EventHandlers typing
karllu3 30ef6ee
code review (#69)
mhordynski 97a613e
update docs
micpst 58b9ead
Merge branch 'main' into lk/global_event_handlers
micpst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from io import StringIO | ||
|
||
from rich.console import Console | ||
|
||
from dbally.audit import CLIEventHandler | ||
|
||
|
||
class BufferEventHandler(CLIEventHandler): | ||
""" | ||
This handler stores in buffer all interactions between LLM and user happening during `Collection.ask`\ | ||
execution. | ||
|
||
### Usage | ||
|
||
```python | ||
import dbally | ||
from dbally.audit.event_handlers.buffer_event_handler import BufferEventHandler | ||
|
||
dbally.event_handlers = [BufferEventHandler()] | ||
my_collection = dbally.create_collection("my_collection", llm) | ||
``` | ||
""" | ||
|
||
def __init__(self) -> None: | ||
super().__init__() | ||
|
||
self.buffer = StringIO() | ||
self._console = Console(file=self.buffer, record=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.