Field-level selection for input/output filtering in decorator instead of using update_current_observation/trace #3524
Replies: 4 comments 5 replies
-
|
Thanks for sharing this idea! Agree that both would be a nice alternatives to the current explicit overrides. |
Beta Was this translation helpful? Give feedback.
-
|
@marcklingen can I open issue and create a PR for it? |
Beta Was this translation helpful? Give feedback.
-
|
@micky-amir Thanks a lot for raising this! While I agree that removing instrumentation code from the observed function body via some form of field-level selection would be good, I see significant implementation + maintenance complexity in covering all possible data structures and edge cases which such a generic field access via dot notation requires. I think though there is some elegance in providing an interface for some selector function which would not only allow select but also transform while keeping the decorator interface + implementation clean. Important here would be to have appropriate exception handling. I'm thinking along these lines: @observe(
input_transform=lambda args, kwargs: {'messages': args[0]['messages']},
output_transform=lambda result: result[0]
)
def main(content):
...
return data |
Beta Was this translation helpful? Give feedback.
-
|
@hassiebp regarding the first option I suggested, I completely agree—it could lead to many future issues. @marcklingen I do believe that #3518 could be implemented with the suggestion above. However, I’m wondering if, in addition to input and output transformations, it might be beneficial to include middleware for masking secrets or similar elements in the input and output (since the transformers are intended to modify the format and select specific fields). My LLM secret was sent more than once to the server which is no good. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the feature or potential improvement
This feature lets you pick specific fields from the input and output of a function by using a decorator. It allows you to control which parts of the data you want to keep or exclude, without changing how the function works.
I want to avoid calling the update function inside the function.
Option 1:
Another approach can be to send instead of the field hierarchy a func that extracts the data required for input and output
Option 2:
Additional information
No response
Beta Was this translation helpful? Give feedback.
All reactions