Sema4AI / actions

AI Actions connect Agents to your existing enterprise systems and applications - all in 🐍 Python.
https://sema4.ai/
Apache License 2.0
49 stars 5 forks source link

Support decorators for `@action` #51

Open kariharju opened 1 month ago

kariharju commented 1 month ago

Issue by fabioz Monday Jan 29, 2024 at 11:34 GMT Originally opened as https://github.com/robocorp/robocorp/issues/202


Target components

action_server, actions

Description

i.e.: As something as:

@my_decorator
@action
def any_action(value: str) -> str:
    ...

is the same as:

def any_action(value: str) -> str:
    ...

any_action = action(any_action) # at this point we save the reference to the function, so, it doesn't work.
any_action = my_decorator(any_action)

and if it was inverted it'd be:

def any_action(value: str) -> str:
    ...

any_action = my_decorator(any_action) 
any_action = action(any_action) # The signature of the my_decorator won't be correct for introspecting.

Describe the solution you'd like to see

We could maybe make it work by not storing the reference and just storing the module/function name to get for calling but still introspecting on the given one (but it does have some caveats too).

Describe alternatives you've considered

No response

kariharju commented 1 month ago

Comment by fabioz Tuesday May 07, 2024 at 10:19 GMT


Note: investigate if functools.wraps adds info on the wrapper so that the original one can be gotten for introspection.