Closed zzstoatzz closed 7 months ago
I love the functionality. I don't love the execution. What do you think of this instead:
@marvin.fn(retries=1, on_errors=[ValidationError])
def get_random_number() -> RandomNumber:
"""returns a random number"""
This would be equivalent to what you did. It could also be extended to this, which is what I'm currently looking for:
@marvin.fn(retries=2, timeout=5.0)
def get_random_number() -> RandomNumber:
"""returns a random number"""
This would try up to three times (2 retries) if any type of error is thrown including a runtime longer than 5 seconds. I think the timeout option is very useful because many requests on the OpenAI API just timeout after a (way too) long time. If I call 100 functions asynchronously, theres usually at least one in there that delays the entire call.
adds a
beta
retry decorator to be used withmarvin.fn
that will include validation errors (as is, by default) in subsequent retriesyou may also configure
max_retries
and a handler to parseValidationError
s to the additional context that is actually passed back to the LLM