-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add a callback to easily track data #238
Comments
My thoughts here:
My first instinct would be something like this: # this would match the finalized callback type
def my_serializer(...):
....
class SerializingOpenAICall(OpenAICall):
serialization_fn = my_serializer One benefit of doing it this way is that you can create different classes for different serialization schemes + lock the scheme to the particular call, which is likely necessary if you're serializing to a DB or something. Need to further flesh this out and play around with things, but I like the feature and general direction. Thanks for the request! |
After further thought and discussion, we're thinking that this feature is actually quite similar to something else we're already working on wrt. ops tooling. Our ops integrations first wrap each method and then (optionally) wrap the LLM client calls themselves internally. I think that the method wrapper functionality would actually cover this callback feature (and the option to add additional LLM client specific wrappers would provide even more customizability if desired). For reference, this would end up looking something like this: # we will include documentation for how to write this function
# this is currently what needs the most additional thought for optimal DX
def saving_fn(...):
...
def with_saving(cls):
return wrap_mirascope_class_functions(cls, saving_fn)
# ^ you would import this (function name tbd) helper utility from mirascope
@with_saving
class SavingCall(OpenAICall):
"""A base call that wraps methods and saves input/output."""
class MyCall(SavingCall):
... There are still aspects of this that need to be further fleshed out (namely wrt. DX), but I like this direction. |
Amazing, thanks Will I'll check it out soon |
Description
Right now we're overriding the extract and call methods of the OpenAIExtractor and OpenAICall classes to handle things like storing in a database or tracking usage. Would be nice to get a standardized way to do this and manage serialization automatically.
Ref (conversation w/ William): https://mirascope-community.slack.com/archives/D0736LQ50E9/p1715651888713359
The text was updated successfully, but these errors were encountered: