File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 1717from PIL import Image as PILImage
1818
1919from mellea .helpers .fancy_logger import FancyLogger
20+ import multiprocessing .pool
2021
2122
2223class CBlock :
@@ -653,6 +654,14 @@ class ModelToolCall:
653654 func : Callable
654655 args : Mapping [str , Any ]
655656
656- def call_func (self ) -> Any :
657- """A helper function for calling the function/tool represented by this object."""
658- return self .func (** self .args )
657+ def call_func (self , timeout : float | None = None ) -> Any :
658+ """A helper function for calling the function/tool represented by this object.
659+
660+ Args:
661+ timeout: if set, the tool call will time-out and an exception will be thrown after `timeout` seconds."""
662+ if timeout :
663+ with multiprocessing .pool .ThreadPool () as pool :
664+ result = pool .apply_async (self .func , kwds = self .args ).get (timeout = timeout )
665+ return result
666+ else :
667+ return self .func (** self .args )
You can’t perform that action at this time.
0 commit comments