agno icon indicating copy to clipboard operation
agno copied to clipboard

Functions with datetime arguments

Open ashpreetbedi opened this issue 2 years ago • 1 comments

Discussed in https://github.com/orgs/phidatahq/discussions/50

Originally posted by adieyal January 19, 2024 Thanks for an excellent library.

I was wondering what the best approach for defining tools whose functions have datetime arguments. From my reading of the code, it seems that you need to create a custom Function since get_json_schema doesn't handle dates. e.g.

class SalesFunction(Function):
    ...
    parameters: Dict[str, Any] = {
        "type": "object",
        "properties": {
            "start_date": {
                "type": "string",
                "format": "date-time",
                "description": ...
            },
            "end_date": {
                "type": "string",
                "format": "date-time",
                "description": ...
            }
        }
    }

    entrypoint: Callable[[str, str], str] = ...

perhaps an alternative would be to customise get_json_schema and then override from_callable to use the new function? https://github.com/phidatahq/phidata/blob/a598b583769b02a68d79f0a6698c930f51c69f07/phi/tools/function.py#L27-L44

ashpreetbedi avatar Jan 24 '24 09:01 ashpreetbedi

cc @adieyal

ashpreetbedi avatar Jan 24 '24 09:01 ashpreetbedi