rigging.watchers
Common watcher callback makers for use with generators, chats, and completions.
write_chats_to_elastic(client: AsyncElasticsearch, index: str, *, create_index: bool = True, **kwargs: t.Any) -> WatchChatCallback
#
Create a watcher to write each chat to an ElasticSearch index.
Parameters:
-
client
(AsyncElasticsearch
) –The AsyncElasticSearch client to use.
-
index
(str
) –The index to write to.
-
create_index
(bool
, default:True
) –Whether to create the index if it doesn't exist and update its mapping.
-
kwargs
(Any
, default:{}
) –Additional keyword arguments to be passed to the Elasticsearch client.
Returns:
-
WatchChatCallback
–A callback to use in rigging.chat.ChatPipeline.watch
-
WatchChatCallback
–
Source code in rigging/watchers.py
write_chats_to_jsonl(file: str | Path, *, replace: bool = False) -> WatchChatCallback
#
Create a watcher to write each chat as a single JSON line appended to a file.
Parameters:
-
file
(str | Path
) –The file to write to.
-
replace
(bool
, default:False
) –If the file should be replaced if it already exists.
Returns:
-
WatchChatCallback
–A callback to use in rigging.chat.ChatPipeline.watch
-
WatchChatCallback
–
Source code in rigging/watchers.py
write_chats_to_s3(client: S3Client, bucket: str, key: str, replace: bool = False) -> WatchChatCallback
#
Create a watcher to write each chat to an Amazon S3 bucket.
Parameters:
-
client
(S3Client
) –The S3 client to use.
-
bucket
(str
) –The bucket to write to.
-
key
(str
) –The key to write to.
-
replace
(bool
, default:False
) –If the file should be replaced if it already exists.
Returns:
-
WatchChatCallback
–A callback to use in rigging.chat.ChatPipeline.watch
-
WatchChatCallback
–
Source code in rigging/watchers.py
write_messages_to_jsonl(file: str | Path, *, replace: bool = False) -> WatchChatCallback
#
Create a watcher to flatten chats to individual messages (like Dataframes) and append to a file.
Parameters:
-
file
(str | Path
) –The file to write to.
-
replace
(bool
, default:False
) –If the file should be replaced if it already exists.
Returns:
-
WatchChatCallback
–A callback to use in rigging.chat.ChatPipeline.watch
-
WatchChatCallback
–